From 31119af34809a4471128907a3ff14408d29d7a8e Mon Sep 17 00:00:00 2001 From: Sandro Wenzel Date: Wed, 18 Nov 2026 09:23:34 +0100 Subject: [PATCH] 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. --- MC/bin/o2dpg_sim_workflow.py | 2 +- MC/config/PWGUD/ini/makeStarlightConfig.py | 52 +++++----------------- MC/config/PWGUD/ini/makeUpcgenConfig.py | 9 +--- MC/prodinfo/mcprodinfo_harvester.py | 1 + 4 files changed, 16 insertions(+), 48 deletions(-) diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index b1c44b7d2..375b8e873 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -988,7 +988,7 @@ def getDPL_global_options(bigshm=False, ccdbbackend=True, runcommand=True): if eventOffset == None: eventOffset = 0 cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/InitHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(eventOffset) + ');' - elif tf > 1: + else: # determine the skip number cmd = 'export HEPMCEVENTSKIP=$(${O2DPG_ROOT}/UTILS/ReadHepMCEventSkip.sh ../HepMCEventSkip.json ' + str(tf) + ');' SGNGENtask['cmd'] = cmd diff --git a/MC/config/PWGUD/ini/makeStarlightConfig.py b/MC/config/PWGUD/ini/makeStarlightConfig.py index 31f79357c..f5b6848d1 100755 --- a/MC/config/PWGUD/ini/makeStarlightConfig.py +++ b/MC/config/PWGUD/ini/makeStarlightConfig.py @@ -39,46 +39,18 @@ if args.nOOn: args.extraPars = 'BREAKUP_MODE = 4' -if 'PbPb' in args.collType: - pZ = 82 - pA = 208 - tZ = 82 - tA = 208 -if 'pPb' in args.collType: - pZ = 1 - pA = 1 - tZ = 82 - tA = 208 -if 'Pbp' in args.collType: - pZ = 82 - pA = 208 - tZ = 1 - tA = 1 -if 'pp' in args.collType: - pZ = 1 - pA = 1 - tZ = 1 - tA = 1 -if 'OO' in args.collType: - pZ = 8 - pA = 16 - tZ = 8 - tA = 16 -if 'pO' in args.collType: - pZ = 1 - pA = 1 - tZ = 8 - tA = 16 -if 'Op' in args.collType: - pZ = 8 - pA = 16 - tZ = 1 - tA = 1 -if 'NeNe' in args.collType: - pZ = 10 - pA = 20 - tZ = 10 - tA = 20 +# (projectile Z, A, target Z, A) for each collision system +beams = { + 'PbPb': (82, 208, 82, 208), + 'pPb': (1, 1, 82, 208), + 'Pbp': (82, 208, 1, 1), + 'pp': (1, 1, 1, 1), + 'OO': (8, 16, 8, 16), + 'pO': (1, 1, 8, 16), + 'Op': (8, 16, 1, 1), + 'NeNe': (10, 20, 10, 20), +} +pZ, pA, tZ, tA = beams[args.collType] ### open output file fout = open(args.output, 'w') diff --git a/MC/config/PWGUD/ini/makeUpcgenConfig.py b/MC/config/PWGUD/ini/makeUpcgenConfig.py index 9915b2f35..85b30b46f 100755 --- a/MC/config/PWGUD/ini/makeUpcgenConfig.py +++ b/MC/config/PWGUD/ini/makeUpcgenConfig.py @@ -27,13 +27,8 @@ args = parser.parse_args() -if 'PbPb' in args.collType: - pZ = 82 - pA = 208 - -if 'OO' in args.collType: - pZ = 8 - pA = 16 +# (projectile Z, A) for each collision system +pZ, pA = {'PbPb': (82, 208), 'OO': (8, 16)}[args.collType] ### open output file fout = open(args.output, 'w') diff --git a/MC/prodinfo/mcprodinfo_harvester.py b/MC/prodinfo/mcprodinfo_harvester.py index 426bdb767..0b4ff89a3 100755 --- a/MC/prodinfo/mcprodinfo_harvester.py +++ b/MC/prodinfo/mcprodinfo_harvester.py @@ -82,6 +82,7 @@ def extract_from_zip(local_zip_path): def build_info(prod_tag, run_number, wf_data, env_vars): meta=wf_data.get("meta") + int_rate = col_system = orbits_per_tf = None if meta != None: int_rate = meta.get("interactionRate") col_system = meta.get("col")