7 """Run a shell command and handle errors."""
8 print(f
"\n>>> Running: {command}\n")
10 subprocess.run(command, shell=
True)
11 except subprocess.CalledProcessError
as e:
12 print(f
"Error: Command failed: {e}")
18 print(
"# %s" % (text))
22 if __name__ ==
"__main__":
25 parser = argparse.ArgumentParser(prog=
'python -m TRT_ConditionsAlgs.TRT_DBUpdate', formatter_class=argparse.RawTextHelpFormatter,
26 description=
'''Update TRT conditions:
27 python -m TRT_ConditionsAlgs.TRT_DBUpdate -> for testing
28 python -m TRT_ConditionsAlgs.TRT_DBUpdate --prod -> for data production
29 python -m TRT_ConditionsAlgs.TRT_DBUpdate --prod --isMC -> for MC production''')
31 parser.add_argument(
'--prod',action=
'store_true' ,help=
"Meant for production only")
32 parser.add_argument(
'--isMC',action=
'store_true' ,help=
"By default is DATA. If set then MC")
33 parser.add_argument(
'--pwd', required=
True ,help=
"COOL DB password - used by experts only")
34 parser.add_argument(
'-s',
'--skipToken',action=
'store_true' ,help=
"Skips auth-get-user-token if provided (you must have one active)")
35 args = parser.parse_args()
38 os.environ[
"COOL_FLASK"] =
"https://cool-proxy-app.cern.ch"
41 if not args.skipToken:
42 run_command(
"auth-get-user-token -c cool-flask-client -o ~/.client-exchange-token.json")
44 print(
"Token skipped. Is supposed to be active..")
46 if not args.prod
and not args.isMC:
48 nextstep(
"Publishing: \033[31;5;7m TEST \033[0m upload")
50 tagt0=
"TrtCalibT0-Webtest-RUN2-UPD1-00-00"
51 tagrt=
"TrtCalibRt-Webtest-RUN2-UPD1-00-00"
53 if input(
"Are you all set to upload test T0 and RT constants? (1=yes):") ==
"1":
54 print(
"Uploading T0s:")
55 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/T0 --tag=Textt0 --retag={tagt0} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
57 print(
"Uploading RTs:")
58 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/RT --tag=Textrt --retag={tagrt} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
60 print(
"Skipping... set all the necessary")
64 nextstep(
"Publishing: \033[31;5;7m MC \033[0m upload")
66 if input(
"Are you all set to upload MC T0 and RT constants (1=yes)? ") ==
"1":
67 tag = input(
"\nUploading T0s. What is the name of target tag (example: TrtCalibT0-MC-run3-test-00)? ")
68 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --folder=/TRT/Calib/T0 --tag=Textt0 --retag={tag} mycool.db OFLP200 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
70 tag = input(
"\nUploading RTs. What is the name of target tag (example: TrtCalibRT-MC-run3-test-00)? ")
71 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --folder=/TRT/Calib/RT --tag=Textrt --retag={tag} mycool.db OFLP200 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
73 print(
"\n"+
"#"*100+
"\n")
74 print(
"Note that for a new MC campaign with new TRT gas, you will need to make a new tag eg TrtCalibxx-MC-run2-run3-00-02")
75 print(
"with all the IoVs from TrtCalib-MC-run2-run3-00-01 PLUS a new IoV with the payload of the tag just written")
76 print(
"This way we have the entire MC history in one tag")
77 print(
"\n"+
"#"*100+
"\n")
79 print(
"Skipping... set all the necessary")
83 nextstep(
"Publishing: \033[31;5;7m PRODUCTION \033[0m upload")
85 if input(
"Do you want to upload new T0s to the production ES1 tag (1=yes)? ") ==
"1":
86 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/T0 --tag=Textt0 --retag=TrtCalibT0-RUN2-Physics-UPD1-FieldOn-00-00 mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
88 print(
"Skipping upload new T0s to the production ES1 tag\n")
90 if input(
"Do you want to upload new RT relations to the production ES1 tag (1=yes)? ") ==
"1":
91 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/RT --tag=Textrt --retag=TrtCalibRt-RUN2-Physics-UPD1-FieldOn-00-00 mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
93 print(
"Skipping upload new RT relations to the production ES1 tag\n")
95 if input(
"Do you want to upload new T0s to the production BLK UPD4 tag (1=yes)? ") ==
"1":
96 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/T0 --tag=Textt0 --retag=TrtCalibT0-RUN2-Physics-BLK-UPD4-00-03 mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
98 print(
"Skipping upload new T0s to the production BLK UPD4 tag\n")
100 if input(
"Do you want to upload new RT constants to the BLK UPD4 tag (1=yes)? ") ==
"1":
101 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Calib/RT --tag=Textrt --retag=TrtCalibRt-RUN2-Physics-BLK-UPD4-00-03 mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
103 print(
"Skipping upload new RT constants to the BLK UPD4 tag\n")
106 print(
"Environment setup complete.")