From c05f3b635b4f8d85d737e1e1352d348406266e9c Mon Sep 17 00:00:00 2001 From: Fabrizio Grosa Date: Mon, 5 Jun 2023 10:39:11 +0200 Subject: [PATCH 1/3] Add protection for input data --- EventFiltering/PWGHF/Macros/train_hf_triggers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/EventFiltering/PWGHF/Macros/train_hf_triggers.py b/EventFiltering/PWGHF/Macros/train_hf_triggers.py index 815127f1983..0c8629976f0 100644 --- a/EventFiltering/PWGHF/Macros/train_hf_triggers.py +++ b/EventFiltering/PWGHF/Macros/train_hf_triggers.py @@ -64,11 +64,11 @@ def get_list_input_files(indirs, channel): - file_lists: dictionary with lists of input files for prompt, nonprompt, and bkg """ + file_lists = {"Prompt": None, "Nonprompt": None, "Bkg": None} if channel not in ["D0ToKPi", "DplusToPiKPi", "DsToKKPi", "LcToPKPi", "XicToPKPi"]: print(f"ERROR: channel {channel} not implemented, return None") - return None, None, None + return file_lists - file_lists = {} for cand_type in indirs: # pylint: disable=too-many-nested-blocks file_lists[cand_type] = [] for indir in indirs[cand_type]: @@ -115,6 +115,9 @@ def data_prep(config): os.mkdir(out_dir) file_lists = get_list_input_files(input_dirs, channel) + for file_list in file_lists: + if file_list is None: + sys.exit() hdl_prompt = TreeHandler(file_lists["Prompt"]) hdl_nonprompt = TreeHandler(file_lists["Nonprompt"]) From 8c38443932ffa2d6f0ca96c643eba340f9f3cdf0 Mon Sep 17 00:00:00 2001 From: Fabrizio Grosa Date: Mon, 5 Jun 2023 10:44:11 +0200 Subject: [PATCH 2/3] Make MegaLinter happy --- EventFiltering/PWGHF/Macros/train_hf_triggers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EventFiltering/PWGHF/Macros/train_hf_triggers.py b/EventFiltering/PWGHF/Macros/train_hf_triggers.py index 0c8629976f0..d9195316d7a 100644 --- a/EventFiltering/PWGHF/Macros/train_hf_triggers.py +++ b/EventFiltering/PWGHF/Macros/train_hf_triggers.py @@ -64,10 +64,10 @@ def get_list_input_files(indirs, channel): - file_lists: dictionary with lists of input files for prompt, nonprompt, and bkg """ - file_lists = {"Prompt": None, "Nonprompt": None, "Bkg": None} + file_lists = if channel not in ["D0ToKPi", "DplusToPiKPi", "DsToKKPi", "LcToPKPi", "XicToPKPi"]: print(f"ERROR: channel {channel} not implemented, return None") - return file_lists + return {"Prompt": None, "Nonprompt": None, "Bkg": None} for cand_type in indirs: # pylint: disable=too-many-nested-blocks file_lists[cand_type] = [] From 5194a1c5ea6c99d88b373b5af7b6ea33cb939cb3 Mon Sep 17 00:00:00 2001 From: Fabrizio Grosa Date: Mon, 5 Jun 2023 10:45:24 +0200 Subject: [PATCH 3/3] Remove whitespace --- EventFiltering/PWGHF/Macros/train_hf_triggers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventFiltering/PWGHF/Macros/train_hf_triggers.py b/EventFiltering/PWGHF/Macros/train_hf_triggers.py index d9195316d7a..10bd100ecce 100644 --- a/EventFiltering/PWGHF/Macros/train_hf_triggers.py +++ b/EventFiltering/PWGHF/Macros/train_hf_triggers.py @@ -64,11 +64,11 @@ def get_list_input_files(indirs, channel): - file_lists: dictionary with lists of input files for prompt, nonprompt, and bkg """ - file_lists = if channel not in ["D0ToKPi", "DplusToPiKPi", "DsToKKPi", "LcToPKPi", "XicToPKPi"]: print(f"ERROR: channel {channel} not implemented, return None") return {"Prompt": None, "Nonprompt": None, "Bkg": None} + file_lists = {} for cand_type in indirs: # pylint: disable=too-many-nested-blocks file_lists[cand_type] = [] for indir in indirs[cand_type]: