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_DBStatusUpdate', formatter_class=argparse.RawTextHelpFormatter,
26 description=
'''Update TRT conditions:
27 python -m TRT_ConditionsAlgs.TRT_DBStatusUpdate -> for testing
28 python -m TRT_ConditionsAlgs.TRT_DBStatusUpdate --prod -> for data production
29 python -m TRT_ConditionsAlgs.TRT_DBStatusUpdate --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(
'--tag', default=
"" ,help=
"COOL DB password - used by experts only")
35 parser.add_argument(
'-s',
'--skipToken',action=
'store_true' ,help=
"Skips auth-get-user-token if provided (you must have one active)")
36 args = parser.parse_args()
39 os.environ[
"COOL_FLASK"] =
"https://cool-proxy-app.cern.ch"
42 if not args.skipToken:
43 run_command(
"auth-get-user-token -c cool-flask-client -o ~/.client-exchange-token.json")
45 print(
"Token skipped. Is supposed to be active..")
47 if not args.prod
and not args.isMC:
49 nextstep(
"Publishing: \033[31;5;7m TEST \033[0m upload")
51 if input(
"Do you want to upload new Status constants as a test tag (enter 1)? ") ==
"1":
52 retag= (args.tag
if args.tag
else "TrtStrawStatus-WebTest-RUN2-UPD2-00-01")
53 print(f
"Uploading constants to tag {retag} :")
54 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/Status --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
56 print(
"Different input provided. It should be 1 to run the actions.")
60 nextstep(
"Publishing: \033[31;5;7m MC \033[0m upload")
61 myupload = input(
"Uploading MC constants to /TRT/Cond/. Is it for Status (enter 1), is it for StatusHT (2) or is it for StatusPermanent (3)? ")
64 retag = input(
"Uploading Status. What is the name of target tag (example: TRTCondStatus-MC-run2-run3_00-02)? ")
65 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --folder=/TRT/Cond/Status --tag=TextStatus --retag={retag} mycool.db OFLP200 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
68 retag = input(
"Uploading StatusHT. What is the name of target tag (example: TrtStrawStatusHT-MC-run2-run3-01)? ")
69 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --folder=/TRT/Cond/StatusHT --tag=Textrt --retag={retag} mycool.db OFLP200 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
72 retag = input(
"Uploading StatusPermanent. What is the name of target tag (example: TrtStrawStatusPermCol-02)? ")
73 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --folder=/TRT/Cond/StatusPermanent --tag=TextStatus --retag={retag} mycool.db OFLP200 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
76 print(
"Different input provided. It should be 1 (Status), 2 (StatusHT) or 3 (StatusPermanent)")
78 print(
"\n"+
"#"*100+
"\n")
79 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")
80 print(
"with all the IoVs from TrtCalib-MC-run2-run3-00-01 PLUS a new IoV with the payload of the tag just written")
81 print(
"This way we have the entire MC history in one tag" )
82 print(
"\n"+
"#"*100+
"\n")
86 nextstep(
"Publishing: \033[31;5;7m PRODUCTION \033[0m upload")
88 myupload = input(
"Uploading data production constants to /TRT/Cond/. Is it for Status (enter 1), is it for StatusHT (2) or is it for StatusPermanent (3)? ")
92 if input(
"Do you want to upload new Status constants to the production ES1 tag (enter 1)? ") ==
"1":
93 retag= args.tag
if args.tag
else "TRTCondStatus-RUN2-ES1-UPD1-00-00"
94 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/Status --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
96 if input(
"Do you want to upload new Status constants to the production BLK tag (enter 1)? ") ==
"1":
97 retag= args.tag
if args.tag
else "TRTCondStatus-RUN2-BLK-UPD4-00-00"
98 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/Status --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
100 elif myupload ==
"2":
102 if input(
"Do you want to upload new StatusHT constants to the production ES1 tag (enter 1)? ") ==
"1":
103 retag= args.tag
if args.tag
else "TRTCondStatusHT-RUN2-UPD1-00-00"
104 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/StatusHT --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
106 if input(
"Do you want to upload new Status constants to the production BLK tag (enter 1)? ") ==
"1":
107 retag= args.tag
if args.tag
else "TrtStrawStatusHT-RUN2-UPD4-02-00"
108 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/StatusHT --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
110 elif myupload ==
"3":
112 if input(
"Do you want to upload new StatusPermanent constants to the production BLK tag (enter 1)? ") ==
"1":
113 retag= args.tag
if args.tag
else "TRTCondStatusPermanent-RUN2-BLK-UPD4-02-00"
114 run_command(f
"~atlcond/utilsproxy/AtlCoolMerge.py --flask --rs=999999 --folder=/TRT/Cond/StatusPermanent --tag=TextStatus --retag={retag} mycool.db CONDBR2 ATONR_COOLOFL_GPN ATLAS_COOLOFL_TRT_W {args.pwd}")
117 print(
"Different input provided. It should be 1 (Status), 2 (StatusHT) or 3 (StatusPermanent)")
120 print(
"Environment setup complete.")