Skip to content

Could cut rules be more modular? #1105

@wilsonmr

Description

@wilsonmr

Not entirely detached from #818

Would it make more sense to store rules like

<rule key>:
 reason: <some reason>
 rule: <some rule>

where at the moment rule key would be either the dataset name or the process_type. Then the production rule which produces the Rule objects would just return the relevant rules for a single dataset

def produce_processed_rules_dataset(self, dataset, default_rules, explicit_rules, theoryid, defaults):
    dataset_rules = []
    ...
    keys = [str(dataset), dataset.commondata.process_type]
    for key in keys:
        if key in explicit_rules:
            dataset_rules.append(Rule(
                    initial_data=explicit_rules[str(dataset)],
                    defaults=defaults, # these should be renamed considering we will have many defaults
                    theory_parameters=theory_parameters,
                    loader=self.loader,
                ))
        elif key in default_rules:
            dataset_rules.append(Rule(
                    initial_data=default_rules[str(dataset)],
                    defaults=defaults,
                    theory_parameters=theory_parameters,
                    loader=self.loader,
                ))
        return dataset_rules

I think this would make the rules a bit more modular because I could redefine a subset of rules in explicit_rules but not have to redefine all of them.

Obvious trip ups are:

  • if any process_type == str(dataset)
  • if there is another way in which a rule is linked to a dataset other than by the name or process type

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions