From d52639d6cee34501a4c8c74b7090eb72719863f0 Mon Sep 17 00:00:00 2001 From: Mathis Frahm Date: Thu, 3 Aug 2023 15:51:44 +0200 Subject: [PATCH 1/4] fix default config and selector reqs for the dense_classifier --- hbw/ml/dense_classifier.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hbw/ml/dense_classifier.py b/hbw/ml/dense_classifier.py index f1e5ccfb..45e1aab8 100644 --- a/hbw/ml/dense_classifier.py +++ b/hbw/ml/dense_classifier.py @@ -160,7 +160,7 @@ def training_configs(self, requested_configs: Sequence[str]) -> list[str]: return list(requested_configs) else: # use config_2017 per default - return ["config_2017"] + return ["c17"] def training_calibrators(self, config_inst: od.Config, requested_calibrators: Sequence[str]) -> list[str]: # fix MLTraining Phase Space @@ -168,7 +168,7 @@ def training_calibrators(self, config_inst: od.Config, requested_calibrators: Se def training_selector(self, config_inst: od.Config, requested_selector: str) -> str: # fix MLTraining Phase Space - return "default" + return "sl" if self.config_inst.has_tag("is_sl") else "dl" def training_producers(self, config_inst: od.Config, requested_producers: Sequence[str]) -> list[str]: # fix MLTraining Phase Space From 4da68fbcb02ab179d0ad387e2a99cb184bb5b76b Mon Sep 17 00:00:00 2001 From: Mathis Frahm Date: Thu, 3 Aug 2023 15:54:51 +0200 Subject: [PATCH 2/4] improve definition of default selector,producer,ml_model --- hbw/config/defaults_and_groups.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/hbw/config/defaults_and_groups.py b/hbw/config/defaults_and_groups.py index e9b31582..74041e1d 100644 --- a/hbw/config/defaults_and_groups.py +++ b/hbw/config/defaults_and_groups.py @@ -6,6 +6,15 @@ from columnflow.tasks.framework.base import RESOLVE_DEFAULT +def default_selector(cls, container, task_params): + if container.has_tag("is_sl"): + selector = "sl" + elif container.has_tag("is_dl"): + selector = "dl" + + return selector + + def default_ml_model(cls, container, task_params): """ Function that chooses the default_ml_model based on the inference_model if given """ # for most tasks, do not use any default ml model @@ -13,7 +22,7 @@ def default_ml_model(cls, container, task_params): # the ml_model parameter is only used by `MLTraining` and `MLEvaluation`, therefore use some default # NOTE: default_ml_model does not work for the MLTraining task - if cls.task_family in ("cf.MLTraining", "cf.MLEvaulation"): + if cls.task_family in ("cf.MLTraining", "cf.MLEvaulation", "cf.MergeMLEvents", "cf.PrepareMLEvents"): # TODO: we might want to distinguish between two default ML models (sl vs dl) default_ml_model = "dense_default" @@ -37,7 +46,10 @@ def default_producers(cls, container, task_params): # per default, use the ml_inputs and event_weights # TODO: we might need two ml_inputs producers in the future (sl vs dl) - default_producers = ["ml_inputs", "event_weights"] + default_producers = ["ml_inputs"] + if task_params["dataset_inst"].is_mc: + # run event weights producer only if it's a MC dataset + default_producers.add("event_weights") # check if a ml_model has been set ml_model = task_params.get("mlmodel", None) or task_params.get("mlmodels", None) @@ -87,7 +99,7 @@ def set_config_defaults_and_groups(config_inst): # TODO: the default dataset is currently still being set up by the law.cfg config_inst.x.default_dataset = default_signal_dataset = f"{default_signal_process}_{signal_generator}" config_inst.x.default_calibrator = "skip_jecunc" - config_inst.x.default_selector = f"{signal_tag}" + config_inst.x.default_selector = default_selector config_inst.x.default_producer = default_producers config_inst.x.default_ml_model = default_ml_model config_inst.x.default_inference_model = "default" From 20c92f1a6d5ffb1603c3f7a81c6ab3e9236631fa Mon Sep 17 00:00:00 2001 From: Mathis Frahm Date: Thu, 3 Aug 2023 19:09:37 +0200 Subject: [PATCH 3/4] fix typo --- hbw/config/defaults_and_groups.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hbw/config/defaults_and_groups.py b/hbw/config/defaults_and_groups.py index 74041e1d..00bd013d 100644 --- a/hbw/config/defaults_and_groups.py +++ b/hbw/config/defaults_and_groups.py @@ -49,7 +49,7 @@ def default_producers(cls, container, task_params): default_producers = ["ml_inputs"] if task_params["dataset_inst"].is_mc: # run event weights producer only if it's a MC dataset - default_producers.add("event_weights") + default_producers.append("event_weights") # check if a ml_model has been set ml_model = task_params.get("mlmodel", None) or task_params.get("mlmodels", None) From fa31954b2960a2b4d8656c59d76276c457d403ea Mon Sep 17 00:00:00 2001 From: Mathis Frahm Date: Fri, 4 Aug 2023 10:55:17 +0200 Subject: [PATCH 4/4] bugfix in default producer setup --- hbw/config/defaults_and_groups.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hbw/config/defaults_and_groups.py b/hbw/config/defaults_and_groups.py index 00bd013d..547815ca 100644 --- a/hbw/config/defaults_and_groups.py +++ b/hbw/config/defaults_and_groups.py @@ -43,11 +43,12 @@ def default_ml_model(cls, container, task_params): def default_producers(cls, container, task_params): """ Default producers chosen based on the Inference model and the ML Model """ + dataset_inst = task_params.get("dataset_inst", None) # per default, use the ml_inputs and event_weights # TODO: we might need two ml_inputs producers in the future (sl vs dl) default_producers = ["ml_inputs"] - if task_params["dataset_inst"].is_mc: + if dataset_inst and dataset_inst.is_mc: # run event weights producer only if it's a MC dataset default_producers.append("event_weights")