Skip to content

Commit 31119af

Browse files
committed
Fix pylint used-before-assignment errors
This fixes the four files that fail the pylint check in CI. - mcprodinfo_harvester.py used Col, IntRate and OrbitsPerTF unset when the workflow has no meta block; they now default to None. - makeStarlightConfig.py and makeUpcgenConfig.py pick the beam Z and A from a lookup table instead of a chain of ifs. - o2dpg_sim_workflow.py uses else instead of elif tf > 1 for the HepMC event skip.
1 parent 712da77 commit 31119af

4 files changed

Lines changed: 16 additions & 48 deletions

File tree

‎MC/bin/o2dpg_sim_workflow.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True, runcommand=True):
988988
if eventOffset == None:
989989
eventOffset = 0
990990
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/InitHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(eventOffset) + ');'
991-
elif tf > 1:
991+
else:
992992
# determine the skip number
993993
cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/ReadHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(tf) + ');'
994994
SGNGENtask['cmd'] = cmd

‎MC/config/PWGUD/ini/makeStarlightConfig.py‎

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,18 @@
3939
if args.nOOn:
4040
args.extraPars = 'BREAKUP_MODE = 4'
4141

42-
if 'PbPb' in args.collType:
43-
pZ = 82
44-
pA = 208
45-
tZ = 82
46-
tA = 208
47-
if 'pPb' in args.collType:
48-
pZ = 1
49-
pA = 1
50-
tZ = 82
51-
tA = 208
52-
if 'Pbp' in args.collType:
53-
pZ = 82
54-
pA = 208
55-
tZ = 1
56-
tA = 1
57-
if 'pp' in args.collType:
58-
pZ = 1
59-
pA = 1
60-
tZ = 1
61-
tA = 1
62-
if 'OO' in args.collType:
63-
pZ = 8
64-
pA = 16
65-
tZ = 8
66-
tA = 16
67-
if 'pO' in args.collType:
68-
pZ = 1
69-
pA = 1
70-
tZ = 8
71-
tA = 16
72-
if 'Op' in args.collType:
73-
pZ = 8
74-
pA = 16
75-
tZ = 1
76-
tA = 1
77-
if 'NeNe' in args.collType:
78-
pZ = 10
79-
pA = 20
80-
tZ = 10
81-
tA = 20
42+
# (projectile Z, A, target Z, A) for each collision system
43+
beams = {
44+
'PbPb': (82, 208, 82, 208),
45+
'pPb': (1, 1, 82, 208),
46+
'Pbp': (82, 208, 1, 1),
47+
'pp': (1, 1, 1, 1),
48+
'OO': (8, 16, 8, 16),
49+
'pO': (1, 1, 8, 16),
50+
'Op': (8, 16, 1, 1),
51+
'NeNe': (10, 20, 10, 20),
52+
}
53+
pZ, pA, tZ, tA = beams[args.collType]
8254

8355
### open output file
8456
fout = open(args.output, 'w')

‎MC/config/PWGUD/ini/makeUpcgenConfig.py‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,8 @@
2727

2828
args = parser.parse_args()
2929

30-
if 'PbPb' in args.collType:
31-
pZ = 82
32-
pA = 208
33-
34-
if 'OO' in args.collType:
35-
pZ = 8
36-
pA = 16
30+
# (projectile Z, A) for each collision system
31+
pZ, pA = {'PbPb': (82, 208), 'OO': (8, 16)}[args.collType]
3732

3833
### open output file
3934
fout = open(args.output, 'w')

‎MC/prodinfo/mcprodinfo_harvester.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def extract_from_zip(local_zip_path):
8282

8383
def build_info(prod_tag, run_number, wf_data, env_vars):
8484
meta=wf_data.get("meta")
85+
int_rate = col_system = orbits_per_tf = None
8586
if meta != None:
8687
int_rate = meta.get("interactionRate")
8788
col_system = meta.get("col")

0 commit comments

Comments
 (0)