From 3ca30c76578adc3c45b6fffb163873c8a3296208 Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Mon, 6 Jan 2025 16:07:47 +0100 Subject: [PATCH 1/3] o2-qc-repo-delete-objects-in-runs filter by metadata --- Framework/script/RepoCleaner/README.md | 14 +++++++++----- .../o2-qc-repo-delete-objects-in-runs | 6 ++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Framework/script/RepoCleaner/README.md b/Framework/script/RepoCleaner/README.md index 173ef56349..cfe3451730 100644 --- a/Framework/script/RepoCleaner/README.md +++ b/Framework/script/RepoCleaner/README.md @@ -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 @@ -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` diff --git a/Framework/script/RepoCleaner/qcrepocleaner/o2-qc-repo-delete-objects-in-runs b/Framework/script/RepoCleaner/qcrepocleaner/o2-qc-repo-delete-objects-in-runs index ce6f416461..86e5f99710 100755 --- a/Framework/script/RepoCleaner/qcrepocleaner/o2-qc-repo-delete-objects-in-runs +++ b/Framework/script/RepoCleaner/qcrepocleaner/o2-qc-repo-delete-objects-in-runs @@ -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) @@ -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) From f3e16ccbcb17d80562bb9449d93aec0aaf73afd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20von=20Haller?= Date: Tue, 7 Jan 2025 08:53:26 +0100 Subject: [PATCH 2/3] Update README.md --- Framework/script/RepoCleaner/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/script/RepoCleaner/README.md b/Framework/script/RepoCleaner/README.md index cfe3451730..fa5a24a711 100644 --- a/Framework/script/RepoCleaner/README.md +++ b/Framework/script/RepoCleaner/README.md @@ -53,7 +53,7 @@ source env/bin/activate python -m unittest tests.test_Ccdb.TestCcdb.test_getObjectsList # Run all tests: -python3 -m unittest discover` +python3 -m unittest discover ``` `cd QualityControl/Framework/script/RepoCleaner ; python3 -m unittest discover` From d708da6bb8722489fb3f476ea660bbf43bc68d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20von=20Haller?= Date: Tue, 7 Jan 2025 09:20:21 +0100 Subject: [PATCH 3/3] Update o2-qc-repo-delete-objects-in-runs --- .../qcrepocleaner/o2-qc-repo-delete-objects-in-runs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Framework/script/RepoCleaner/qcrepocleaner/o2-qc-repo-delete-objects-in-runs b/Framework/script/RepoCleaner/qcrepocleaner/o2-qc-repo-delete-objects-in-runs index 86e5f99710..60b9592359 100755 --- a/Framework/script/RepoCleaner/qcrepocleaner/o2-qc-repo-delete-objects-in-runs +++ b/Framework/script/RepoCleaner/qcrepocleaner/o2-qc-repo-delete-objects-in-runs @@ -49,11 +49,7 @@ 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 + versions = ccdb.getVersionsList(args.path + "/.*", "", "", run_number, metadata=args.metadata) logging.info("Here are the objects that are going to be deleted: ") for v in versions: logging.info(v)