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

MetaCode brainstorming #241

Closed
phackstock opened this issue May 2, 2023 · 6 comments
Closed

MetaCode brainstorming #241

phackstock opened this issue May 2, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@phackstock
Copy link
Contributor

Following our discussion earlier, I'm sketching out some ideas for a MetaCodeList.
I think it's easiest to start at what the yaml file is supposed to look like:

- Meta category with boolean values:
  allowed_values: [true, false]
  default: false
- Meta category for tracking versions:
  data_type: int
  required: true
- Meta category only required for Downscaling:
  apply_to: "Downscaling*"
  required: True

the three above examples illustrate some of the use cases that I can see, listing them in order:

  1. Meta category with boolean values has allowed values true and false, defaulting to false
  2. Meta category for tracking versions is required and requires an integer. Allowed values not really make sense here since we expect increasing integer numbers.
  3. Meta category only required for Downscaling should only be applied to models matching the pattern Downscaling*, in which case, however, it is required.

Looking at this again @danielhuppmann I'll retract my previous suggestion of making the entries in allowed_values MetaCodes as that seems too complicated and not every entry in the sample MetaCodeList even features allowed_values.

It's probably better to translate the above structure into something like:

class MetaCode(Code):
    allowed_values: Optional(list[any])
    default: Optional(any)
    data_type: Optional(type)
    required: Optional(bool)

then we'd have a MetaCodeList to hold a list of MetaCodes.

@phackstock phackstock added the enhancement New feature or request label May 2, 2023
@danielhuppmann
Copy link
Member

I think that this is a good model to follow, but I suggest to implement it step by step.

The first PR should be the MetaCode and MetaCodeList classes read from all yaml files in a meta folder, with only the attribute allowed_values.

@danielhuppmann
Copy link
Member

The second PR should be a MetaValidator (with an apply function), which can be passed to the the processor-list in the process-function...

@phackstock
Copy link
Contributor Author

phackstock commented May 3, 2023

@danielhuppmann sounds like a sensible approach to me

@danielhuppmann
Copy link
Member

@GretchenSchowalter, can you take a first stab at this? Please look at this tutorial to better understand the "meta" indicators: https://pyam-iamc.readthedocs.io/en/stable/tutorials/pyam_first_steps.html

@phackstock
Copy link
Contributor Author

@danielhuppmann, I'd say we can close this, right?

@danielhuppmann
Copy link
Member

Closing, with a follow-up at #270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants