WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@pgierz
Copy link
Member

@pgierz pgierz commented Mar 18, 2025

Checks if the pipelines attached to a rule fulfill in any way some tagged requirements.

Requirements look like this in the steps:

def my_awesome_step(data, rule):
    _satisfies_cell_methods = "mean: time"
    data = data.mean(dim="time")
    return data

A step could satisfy multiple requirements. These should be internal variables, and might be used, but I think that they probably should just be used for checking.

A RuleRequirement helper class is available in rule.py, which is used to parse the requirements. Then, each step of each pipeline is checked for such tags:

my_requirements = {"requirement_name": "cell_methods", "requirement_value": "mean: time"}
rule_requirement = RuleRequirement(**my_requirements)
my_pipeline = Pipeline([my_awesome_step])
rule_requirements.pipeline_fulfills_requirements(my_pipeline)

I think that the checking method could use a better name, suggestions are welcome.

This idea is still untested, just a starting point for discussion....

@pgierz pgierz requested review from mandresm and siligam March 18, 2025 11:37
@pgierz pgierz self-assigned this Mar 18, 2025
@pgierz pgierz added backend enhancement New feature or request labels Mar 18, 2025
Comment on lines +231 to +232
if not req_satisfied:
raise ValueError(f"Rule {self.name} does not satisfy requirement {rr}")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should gather all requirements, instead of exiting at the first one.

Comment on lines +57 to +58
if f"_satisfies_{self.requirement_name}" in line:
if str(self.requirement_value) in line:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not terribly convinced by this, it requires that the name and value are strictly defined to be on the same line. That might not be the best way of doing it.

@pgierz pgierz marked this pull request as ready for review March 31, 2025 13:18
@pgierz
Copy link
Member Author

pgierz commented Mar 31, 2025

This technically does what it is supposed to, but we need to discuss the implications of the crosschecking function.

At the moment, everything fails because none of our steps implement the cell_methods described in the integration tests. I think we could do something "dirty" like this:

def maybe_mask_fesom(data, rule):
    _satisfies_cell_methods = "area: mean where sea"
    if "fesom" in data.attrs:
        return data
    else:
        raise ValueError("No idea how to mask the ocean")

@pgierz pgierz added this to the Release 1.1 milestone May 12, 2025
@pgierz pgierz marked this pull request as draft November 24, 2025 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants