Skip to content

Commit 4b918e5

Browse files
authored
o2-qc-repo-delete-objects-in-runs filter by metadata (#2490)
* o2-qc-repo-delete-objects-in-runs filter by metadata * Update README.md * Update o2-qc-repo-delete-objects-in-runs
1 parent 11c4ced commit 4b918e5

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Framework/script/RepoCleaner/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ The configuration for ccdb-test is described [here](../../../doc/DevelopersTips.
3535

3636
## Setup virtual environment for development and test (venv)
3737

38-
1. cd Framework/script/RepoCleaner
39-
2. python3 -m venv env
40-
3. source env/bin/activate
41-
4. python -m pip install -r requirements.txt
42-
5. python3 -m pip install .
38+
1. `cd Framework/script/RepoCleaner`
39+
2. `python3 -m venv env`
40+
3. `source env/bin/activate`
41+
4. `python -m pip install -r requirements.txt`
42+
5. `python3 -m pip install . `
4343
6. You can execute and work. Next time just do "activate" and then you are good to go
44+
7. If you modify the code, then rerun `python3 -m pip install .`
4445

4546
## Unit Tests
4647

@@ -50,6 +51,9 @@ source env/bin/activate
5051
5152
# Run a test:
5253
python -m unittest tests.test_Ccdb.TestCcdb.test_getObjectsList
54+
55+
# Run all tests:
56+
python3 -m unittest discover
5357
```
5458

5559
`cd QualityControl/Framework/script/RepoCleaner ; python3 -m unittest discover`

Framework/script/RepoCleaner/qcrepocleaner/o2-qc-repo-delete-objects-in-runs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def parseArgs():
2828
parser.add_argument('--one-by-one', action='store_true', help='Ask confirmation for each deletion')
2929
parser.add_argument('--print-list', action='store_true', help='Only print the list of objects that would be deleted')
3030
parser.add_argument('--yes', action='store_true', help='Answers yes to all. You should really not use that.')
31+
parser.add_argument('--metadata', dest='metadata', action='store', default="",
32+
help='Delete only versions matching these metadata. Format: "[/key=value]*"')
3133
args = parser.parse_args()
3234
dryable.set(args.dry_run)
3335
logging.info(args)
@@ -47,7 +49,7 @@ def run(args):
4749
run_number = row["runNumber"]
4850
logging.info(f"Run : {run_number}")
4951

50-
versions = ccdb.getVersionsList(args.path + "/.*", "", "", run_number)
52+
versions = ccdb.getVersionsList(args.path + "/.*", "", "", run_number, metadata=args.metadata)
5153
logging.info("Here are the objects that are going to be deleted: ")
5254
for v in versions:
5355
logging.info(v)

0 commit comments

Comments
 (0)