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

Refactor esmvalcore.Recipe #934

Closed
stefsmeets opened this issue Jan 11, 2021 · 2 comments
Closed

Refactor esmvalcore.Recipe #934

stefsmeets opened this issue Jan 11, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@stefsmeets
Copy link
Contributor

stefsmeets commented Jan 11, 2021

Is your feature request related to a problem? Please describe.
esmvalcore.Recipe contains a lot of functionality related to parsing / setting up a recipe, but it is somewhat difficult to use.

class Recipe:

For #907 we want to re-use much of the code and data in Recipe (e.g. accessing diagnostics / settings data), but the design of the class in its current state prohibits this.

At present, Recipe is only used once in the entire code base.

return Recipe(raw_recipe,

I propose we refactor Recipe to make the functionality and data more accessible to other objects, so that we can subclass or delegate to it more easily. This will also help in part to address #639

Would you be able to help out?
👍

@stefsmeets stefsmeets added the enhancement New feature or request label Jan 11, 2021
@stefsmeets stefsmeets self-assigned this Jan 11, 2021
@stefsmeets
Copy link
Contributor Author

stefsmeets commented Jan 26, 2021

One of the key challenges with esmvalcore.Recipe is that it is not designed to be run multiple times in the same process. In its current state, Recipe must be initialized with a user config.

A simple use case that we would want in the API (in #962): obtain a list of diagnostic or preprocessor tasks that can be run. At the moment, this required initializing Recipe.tasks , which is only possible with a config_user dict. In other words, to obtain a list of tasks, we must create the entire work directory. This seems a little bit excessive.

Ideally, we would decouple config_user entirely from the creation of tasks, and only update the paths / user parameters at the last possible moment. But this is hardly possible, because config_user is passed down all the way to the data finder.

I had a good discussion with @Peter9192 about this and our conclusion was that esmvalcore.Recipe should be initialized without config_user, and delay passing config_user to the latest moment. We came to the conclusion that a good first step would be to pass config_user only when running the recipe (i.e. recipe.run(cfg='config_user'). This means that a recipe can be parsed and initialized for the most part (provenance, datasets, scripts, etc), but the tasks would only be derived at the last moment.

@stefsmeets
Copy link
Contributor Author

stefsmeets commented Jan 27, 2021

Had a good discussion with @bouweandela @nielsdrost and @Peter9192 about what the design of Recipe should be. Conclusion was that it is too much work to do right now, and to go a different way for #962

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

1 participant