Skip to main content

Set of tools to clean up the QCDB repository.

Project description

Here are the tools to clean up the CCDB of the QC.

Entry point

It is o2-qc-repo-cleaner. See the long comment at the beginning.

Usage

usage: o2-qc-repo-cleaner [-h] [--config CONFIG] [--config-git] [--config-consul CONFIG_CONSUL] [--log-level LOG_LEVEL] 
                          [--dry-run] [--only-path ONLY_PATH] [--workers WORKERS]

Configuration

The file config.yaml contains the CCDB URL and the rules to be followed to clean up the database. An example is provided along this README (config.yaml). A typical rule in the config file looks like:

  - object_path: qc/ITS/.*
    delay: 240
    policy: 1_per_hour

There can be any number of these rules. The order is important as we use the first matching rule for each element in the QCDB (caveat the use of the flag continue_with_next_rule, see below).

  • object_path: a pattern to be matched to know if the rule applies
  • delay: the duration in minutes of the grace period during which an object is not removed, even if it matches the above path.
  • policy: the name of a policy to apply on the matching objects. Here are the currently available policies (full description in the corresponding files):
    • 1_per_hour: keep the first and extend its validity to 1 hour, remove everything in the next hour, repeat.
    • 1_per_run: requires the "Run" or "RunNumber" metadata to be set. Keep only the most recent version of an object for a given run.
    • last_only: keep only the last version, remove everything else.
    • none_kept: keep none, remove everything
    • skip: keep everything
  • from_timestamp: the rule only applies to versions whose valid_from is older than this timestamp
  • to_timestamp: the rule only applies to versions whose valid_from is younger than this timestamp
  • continue_with_next_rule: if True, the next matching rule is also applied.
  • xyz: any extra argument necessary for a given policy. This is the case of the argument delete_when_no_run required by the policy 1_per_run.

The configuration for ccdb-test is described here.

Unit Tests

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

and to test only one of them: python3 -m unittest tests/test_NewProduction.py -k test_2_runs

In particular there is a test for the production rule that is pretty extensive. It hits the ccdb though and it needs the following path to be truncated: qc/TST/MO/repo/test*

Other tests

Most of the classes and Rules have a main to help test them. To run do e.g. python3 1_per_run.py.

Installation

CMake will install the python scripts in bin and the config file in etc.

Example

PYTHONPATH=./rules:$PYTHONPATH ./o2-qc-repo-cleaner --dry-run --config config-test.yaml --dry-run --only-path qc/DAQ --log-level 10

Development

To install locally

cd Framework/script/RepoCleaner
python3 -m pip install . 

Upload new version

Prerequisite

  1. Create an account on https://pypi.org

Create new version

  1. Update version number in setup.py
  2. python3 setup.py sdist bdist_wheel
  3. python3 -m twine upload --repository pypi dist/*

Use 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 .
  6. You can execute and work. Next time just do "activate" and then you are good to go

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qcrepocleaner-1.9.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

qcrepocleaner-1.9-py3-none-any.whl (71.3 kB view details)

Uploaded Python 3

File details

Details for the file qcrepocleaner-1.9.tar.gz.

File metadata

  • Download URL: qcrepocleaner-1.9.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for qcrepocleaner-1.9.tar.gz
Algorithm Hash digest
SHA256 3b0b2a2d4a1459016525eaea8d93cbf718455c1f04c14a333e2703439e3f31a3
MD5 d7040e4623f869f97cb25474cc0834b9
BLAKE2b-256 5b3219888218c2329ee908d95166e9f078007d8e8e8ebd5c7c16658f6d5c5e82

See more details on using hashes here.

File details

Details for the file qcrepocleaner-1.9-py3-none-any.whl.

File metadata

  • Download URL: qcrepocleaner-1.9-py3-none-any.whl
  • Upload date:
  • Size: 71.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.9

File hashes

Hashes for qcrepocleaner-1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 9a03d148b036356e0f9c286e9aa7358bb179e8dd903165d72d17d0026819f62b
MD5 55a7d72fd6a5f0884ed7d89a72878197
BLAKE2b-256 5062234687f5fa53466a20a489498c83725c6578a06ec7cfd96367b11ef1f5c8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page