Skip to content

Commit

Permalink
change default producer order and minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mafrahm committed Aug 18, 2023
1 parent bb6d72d commit 691a021
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
3 changes: 2 additions & 1 deletion hbw/config/defaults_and_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def default_producers(cls, container, task_params):
# if a ML model is set, and the task is neither MLTraining nor MLEvaluation,
# use the ml categorization producer
if ml_model not in (None, law.NO_STR, RESOLVE_DEFAULT, tuple()) and not is_ml_task:
default_producers.insert(0, f"ml_{ml_model}")
# NOTE: this producer needs to be added as the last element! otherwise, category_ids will be overwritten
default_producers.append(f"ml_{ml_model}")

# if we're running the inference_model, we don't need the ml_inputs
# NOTE: we cannot skip ml_inputs, because it is needed for cf.MLEvaluation
Expand Down
18 changes: 5 additions & 13 deletions hbw/production/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ def pre_ml_cats(self: Producer, events: ak.Array, **kwargs) -> ak.Array:

@pre_ml_cats.init
def pre_ml_cats_init(self: Producer) -> None:
if self.config_inst.x("add_categories_production", True):
# add categories but only on first call
add_categories_production(self.config_inst)
self.config_inst.x.add_categories_production = False
# add categories to config inst
add_categories_production(self.config_inst)


@producer(
Expand Down Expand Up @@ -76,15 +74,9 @@ def ml_cats_init(self: Producer) -> None:
if not self.ml_model_name:
self.ml_model_name = "dense_default"

if self.config_inst.x("add_categories_production", True):
# add categories but only on first call
add_categories_production(self.config_inst)
self.config_inst.x.add_categories_production = False

if self.config_inst.x("add_categories_ml", True):
# add ml categories but only on first call
add_categories_ml(self.config_inst, dense_test)
self.config_inst.x.add_categories_ml = False
# add categories to config inst
add_categories_production(self.config_inst)
add_categories_ml(self.config_inst, dense_test)


# get all the derived DenseClassifier models and instantiate a corresponding producer
Expand Down

0 comments on commit 691a021

Please sign in to comment.