Skip to content

Commit

Permalink
o2-qc-repo-delete-objects-in-runs filter by metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Barthelemy committed Jan 6, 2025
1 parent 036bc2f commit 3ca30c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Framework/script/RepoCleaner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ The configuration for ccdb-test is described [here](../../../doc/DevelopersTips.

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

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

## Unit Tests

Expand All @@ -50,6 +51,9 @@ source env/bin/activate
# Run a test:
python -m unittest tests.test_Ccdb.TestCcdb.test_getObjectsList
# Run all tests:
python3 -m unittest discover`
```

`cd QualityControl/Framework/script/RepoCleaner ; python3 -m unittest discover`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def parseArgs():
parser.add_argument('--one-by-one', action='store_true', help='Ask confirmation for each deletion')
parser.add_argument('--print-list', action='store_true', help='Only print the list of objects that would be deleted')
parser.add_argument('--yes', action='store_true', help='Answers yes to all. You should really not use that.')
parser.add_argument('--metadata', dest='metadata', action='store', default="",
help='Delete only versions matching these metadata. Format: "[/key=value]*"')
args = parser.parse_args()
dryable.set(args.dry_run)
logging.info(args)
Expand All @@ -47,7 +49,11 @@ def run(args):
run_number = row["runNumber"]
logging.info(f"Run : {run_number}")

<<<<<<< Updated upstream
versions = ccdb.getVersionsList(args.path + "/.*", "", "", run_number)
=======
versions = ccdb.get_versions_list(args.path + "/.*", "", "", run_number, metadata=args.metadata)
>>>>>>> Stashed changes
logging.info("Here are the objects that are going to be deleted: ")
for v in versions:
logging.info(v)
Expand Down

0 comments on commit 3ca30c7

Please sign in to comment.