Skip to content

Commit 795e686

Browse files
authored
RepoCleaner: Get config file from git (#351)
1 parent 34283b9 commit 795e686

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

Framework/script/RepoCleaner/repoCleaner.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
import argparse
2323
import logging
24+
import requests
25+
import os
2426
import re
2527
from typing import List
2628

@@ -60,6 +62,8 @@ def parseArgs():
6062
parser = argparse.ArgumentParser(description='Clean the QC database.')
6163
parser.add_argument('--config', dest='config', action='store', default="config.yaml",
6264
help='Path to the config file')
65+
parser.add_argument('--config-git', action='store_true',
66+
help='Check out the config file from git (branch repo_cleaner), ignore --config.')
6367
parser.add_argument('--log-level', dest='log_level', action='store', default="20",
6468
help='Log level (CRITICAL->50, ERROR->40, WARNING->30, INFO->20,DEBUG->10)')
6569
parser.add_argument('--dry-run', action='store_true',
@@ -97,6 +101,22 @@ def parseConfig(config_file_path):
97101

98102
return {'rules': rules, 'ccdb_url': ccdb_url}
99103

104+
def downloadConfigFromGit():
105+
"""
106+
Download a config file from git.
107+
:param config_git: True if the file must be downloaded from git.
108+
:return: the path to the config file
109+
"""
110+
111+
logging.debug("Get it from git")
112+
r = requests.get('https://raw.github.com/AliceO2Group/QualityControl/repo_cleaner/Framework/script/RepoCleaner/config.yaml')
113+
logging.debug(f"config file from git : \n{r.text}")
114+
path = "/tmp/config.yaml"
115+
with open(path, 'w') as f:
116+
f.write(r.text)
117+
logging.info(f"Config path : {path}")
118+
return path
119+
100120

101121
def findMatchingRule(rules, object_path):
102122
"""Return the first matching rule for the given path or None if none is found."""
@@ -124,7 +144,10 @@ def main():
124144
logging.getLogger().setLevel(int(args.log_level))
125145

126146
# Read configuration
127-
config = parseConfig(args.config)
147+
path = args.config
148+
if args.config_git:
149+
path = downloadConfigFromGit()
150+
config = parseConfig(path)
128151
rules: List[Rule] = config['rules']
129152
ccdb_url = config['ccdb_url']
130153

doc/DevelopersTips.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ here. It is not sanitized or organized. Just a brain dump.
1212

1313
### Where and how to configure the repo_cleaner of the ccdb-test
1414

15-
The config file is in `aldaqci@aidrefflp01:~/alice-ccdb/config.yaml`. Simply edit it and it will be picked up the next time the repo_cleaner runs.
15+
The config file is stored in git in the branch `repo_cleaner` (careful not to update in master instead !). Check out the branch, update the file Framework/script/RepoCleaner/config.yaml and commit it. A PR is necessary but in case of emergency, force-merge it. As soon as it is merged, it will be used by the script.
1616

17-
The repo_cleaner is launched every 5 minutes by [Jenkins](https://alijenkins.cern.ch/job/FLP/job/CCDB%20Clean%20up/).
17+
The config file used to be in `aldaqci@aidrefflp01:~/alice-ccdb/config.yaml` but it is not the case any more.
1818

19-
It is a good practice to update [config.yaml](../Framework/script/RepoCleaner/config.yaml) in this repo when updating the file on `aidrefflp01`.
19+
The repo_cleaner is launched every 5 minutes by [Jenkins](https://alijenkins.cern.ch/job/FLP/job/CCDB%20Clean%20up/).
2020

2121
Documentation of the repo_cleaner can be found [here](../Framework/script/RepoCleaner/README.md).
2222

0 commit comments

Comments
 (0)