Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve output_callback data recognition #9

Open
HCookie opened this issue Sep 9, 2024 · 0 comments
Open

Improve output_callback data recognition #9

HCookie opened this issue Sep 9, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@HCookie
Copy link
Member

HCookie commented Sep 9, 2024

As output_callback is called for input_fields, prognostic and diagnostics, it may be unclear for a provided function what data is being passed through.

Current Solution

Examples using anemoi-inference look for steps in the kwargs

if 'steps' in kwargs:
   do_things()

Proposed Solution

  • Data class including information about source and type of data
class ModelDataType(Enum):
    """Model Data Type Enum"""

    PROGNOSTIC = 0
    DIAGNOSTIC = 1
    FORCING = 2

class ModelDataSource(Enum):
    """Model Data Source Enum"""

    INPUT = 0
    PREDICTION = 1

@dataclass
class ModelDataInfo():
    """Model Data Info Dataclass"""

    type: ModelDataType
    source: ModelDataSource

    def __str__(self):
        return f"{self.type} {self.source}"

Usage:

model_info = ModelDataInfo(ModelDataType.PROGNOSTIC, ModelDataSource.PREDICTION)
if ModelDataSource.INPUT = model_info.source:
    do_other_things()

Output_callback

def output_callback(data, model_info: ModelDataInfo, *args, **kwargs):
    ...

Looking for thoughts

  • Will this limit the output callback too much?
  • Will this scale well?
@HCookie HCookie self-assigned this Sep 9, 2024
@HCookie HCookie added enhancement New feature or request help wanted Extra attention is needed question Further information is requested labels Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant