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

Make it possible to use write_plots and write_netcdf from recipe instead of config-user.yml #2018

Merged
merged 7 commits into from Feb 16, 2021

Conversation

bouweandela
Copy link
Member

@bouweandela bouweandela commented Feb 11, 2021

Description

Make it possible to use write_plots and write_netcdf from recipe instead of config-user.yml and update the Python example recipe so it does this.


Before you get started

Checklist

It is the responsibility of the author to make sure the PR is ready to review. The icons indicate whether the item will be subject to the πŸ›  Technical or πŸ§ͺ Scientific review.

New or updated recipe/diagnostic:


To help with the number pull requests:

@bouweandela
Copy link
Member Author

@esmvalbot Please run examples/recipe_python.yml

@esmvalbot
Copy link

esmvalbot bot commented Feb 11, 2021

Since @bouweandela asked, ESMValBot will run recipe examples/recipe_python.yml as soon as possible, output will be generated here

@bouweandela bouweandela added this to the v2.2.0 milestone Feb 11, 2021
@esmvalbot
Copy link

esmvalbot bot commented Feb 11, 2021

ESMValBot is happy to report recipe examples/recipe_python.yml ran OK, output has been generated here

@bouweandela bouweandela marked this pull request as ready for review February 11, 2021 16:44
@bettina-gier
Copy link
Contributor

Following the conversations in the other related pull requests and issues - shouldn't it be a default to write netcdf/plot files, so add it more as an optional argument to turn it off ("no_plots"/"no_netcdf"), rather than on? This would feel more in line with the diagnostics that currently don't have the on/off capabilities.

I don't think changing the example recipe that new developers might look at to include an option to turn it on when it should be on by default is a good idea. Might also just be me nitpicking though ^^

@schlunma
Copy link
Contributor

@esmvalbot Please run recipe_seaice.yml

@esmvalbot
Copy link

esmvalbot bot commented Feb 12, 2021

Since @schlunma asked, ESMValBot will run recipe recipe_seaice.yml as soon as possible, output will be generated here

@esmvalbot
Copy link

esmvalbot bot commented Feb 12, 2021

ESMValBot is sorry to report it failed to run recipe recipe_seaice.yml: exit is 1, output has been generated here

Copy link
Contributor

@schlunma schlunma left a comment

Choose a reason for hiding this comment

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

Some general comments in addition to the comments on the code:

  • I agree that write_netcdf and write_plots might not be optimal names, but since some python diagnostics are using them we should stick to it for consistency.
  • I agree with @bettina-gier that we should not use write_netcdf in an example recipe if we think that user's should not use it.
  • The new optional attributes for all affected diagnostics need to documented in the docstring/header of the diagnostic and in the rst file of the corresponding recipe.
  • We should make sure that all python diagnostics still run when write_plots and write_netcdf are not added to cfg automatically, e.g. by making sure to use cfg.get('write_plots', True) instead of cfg['write_plots'].
  • I think we should not use custom diagnostic options in code that affects all diagnostics, i.e. remove this check here:
    if cfg.get('write_netcdf', True):

esmvaltool/diag_scripts/austral_jet/asr.ncl Show resolved Hide resolved
esmvaltool/diag_scripts/shared/_base.py Outdated Show resolved Hide resolved
esmvaltool/recipes/examples/recipe_python.yml Outdated Show resolved Hide resolved
@bouweandela
Copy link
Member Author

Thanks for your feedback @bettina-gier and @schlunma.

Following the conversations in the other related pull requests and issues - shouldn't it be a default to write netcdf/plot files, so add it more as an optional argument to turn it off ("no_plots"/"no_netcdf"), rather than on? This would feel more in line with the diagnostics that currently don't have the on/off capabilities.
I don't think changing the example recipe that new developers might look at to include an option to turn it on when it should be on by default is a good idea.

I agree that write_netcdf and write_plots might not be optimal names, but since some python diagnostics are using them we should stick to it for consistency.

That latter remark was also my thinking in keeping the name write_netcdf. It's not just Python diagnostics, it's also quite a few NCL and R diagnostics. Note that what is deprecated is setting this function in the config-user.yml file, diagnostics developers are free to add whatever options they feel are suitable to their diagnostics. In particular, some authors feel that writing NetCDF output at all is a bad idea #727 (comment). I would like to encourage writing NetCDF output, because I think it would be really useful if at some point we want to present the output with interactive plotting functionality on a website and it will also make it more easy to implement regression tests for recipes. My thought in adding it to the example was that those people might also be convinced to add it to their diagnostics, but maybe you're right and it's too complicated for a first example, I removed it for now.

  • The new optional attributes for all affected diagnostics need to documented in the docstring/header of the diagnostic and in the rst file of the corresponding recipe.
  • We should make sure that all python diagnostics still run when write_plots and write_netcdf are not added to cfg automatically, e.g. by making sure to use cfg.get('write_plots', True) instead of cfg['write_plots'].
  • Otherwise this will fail in version 2.4 when the write_plots attribute is not added to diag_script_info automatically anymore. Applies to all similar changes

@schlunma I would prefer to leave this for now. I think it is up to the recipe maintainers to update their recipes and associated documentation before the feature is removed. I just made the changes to the .ncl files so it's actually possible to run the recipe by just updating that, without the need to change code. Would that be acceptable for you?

@schlunma
Copy link
Contributor

Thanks for the changes!

@schlunma I would prefer to leave this for now. I think it is up to the recipe maintainers to update their recipes and associated documentation before the feature is removed. I just made the changes to the .ncl files so it's actually possible to run the recipe by just updating that, without the need to change code. Would that be acceptable for you?

This would of course be the optimal solution, but in practice this is most likely not feasible. All of the affected recipes/diagnostics will fail in v2.4 and one person (probably the poor release manager) will have to fix the majority of them. Moreover, I fear that diagnostic developers will use the existing diagnostics as templates for developing new ones, which will create more diagnostics/recipes that need to be changed in the future.

Do we have a proper documentation for the deprecation (an issue and maybe also in the documentation itself)? If yes, I can live with that, but I'm not super happy with it.

Can you please remove the write_netcdf option here

if cfg.get('write_netcdf', True):

? I don't like this hidden condition on diagnostic specific variables. I think if this feature is desired it should be used in the diagnostic like this:

if cfg.get('write_netcdf', True):
    save_data(...)

@bouweandela
Copy link
Member Author

Do we have a proper documentation for the deprecation (an issue and maybe also in the documentation itself)?

Yes, we have issue #2005, a mention in the ESMValCore changelog and it is also mentioned in the documentation on config-user.yml here, though for some reason the documentation build looks outdated.

Moreover, I fear that diagnostic developers will use the existing diagnostics as templates for developing new ones, which will create more diagnostics/recipes that need to be changed in the future.

There is the documentation that describes the feature as deprecated and technical reviewers should be aware of this too.

Can you please remove the write_netcdf option here

ESMValTool/esmvaltool/diag_scripts/shared/_base.py

Will do

@schlunma
Copy link
Contributor

@esmvalbot Please run examples/recipe_python.yml

@esmvalbot
Copy link

esmvalbot bot commented Feb 16, 2021

Since @schlunma asked, ESMValBot will run recipe examples/recipe_python.yml as soon as possible, output will be generated here

@esmvalbot
Copy link

esmvalbot bot commented Feb 16, 2021

ESMValBot is happy to report recipe examples/recipe_python.yml ran OK, output has been generated here

Copy link
Contributor

@schlunma schlunma left a comment

Choose a reason for hiding this comment

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

Great! Ready to merge now πŸŽ‰

@bouweandela
Copy link
Member Author

Thanks for reviewing!

@bouweandela bouweandela merged commit 48bb1e9 into master Feb 16, 2021
@bouweandela bouweandela deleted the deprecate-write-plots-netcdf branch February 16, 2021 13:25
remi-kazeroni pushed a commit that referenced this pull request Oct 11, 2021
* add woa18 cmorizer

* fix units

* add test

* fixes after review

* fixing test

* remove commented out lines

* fixing style

* Consolidate WOA cmorizer for 2018 dataset (#1812)

- use WOA 2018 data at 1 degree monthly fields
- set to OBS6 Info to enable the derivation of surface and Oyr variables
- add automatic download if raw data are not available

* fix codacy

* update reference and input.rst for WOA (#1812)

* try to fix test check for woa (#1812)

* add missing docstring to functions

* remove obsolete _fix_data function (#1812)

* put back unit fix for WOA nutrients (#1812)

* try to fix test_cmorize_obs.py for woa

* fix codacy

* add correct size command

* redo fix test woa

* still working on test

* fix nfile number count

* Always derive WOA Oyr data and fix related small bug in computation.

* adjust WOA dict in recipe_check_obs.yml

* add more cases to bgc units handling

* step back on woa cmorizer and create a single script for WOA13 and WOA18

* comment multimodel in preprocessor as only one model is used

* fix bug in surface variable extraction for cmorize_obs_woa.py

* update references and docs for WOA obs

* use WOA2018 observations in recipe_ocean_bgc.yml

* add woa2013v2 bibtex reference

* fix indentation in bgc_units of diagnostic_tools

* correct commented lines in cmor_config/WOA.yml

* update list of variables for WOA in recipe_check_obs.yml

* revise comments in header of cmorize_obs_woa.py (see #1812)

* update recipe_check_obs.yml with WOA data and vars (see #1812)

* set correct number of woa datafiles in test_cmorize_obs.py (#1812)

* update recipe_ocean_bgc.yml with use of write_plots (see #2018)

* revert recipe_ocean_bgc.yml to use WOA2013v2

* remove changes to recipe_ocean_bgc, update to the recipe will follow in #2324

* revert deleted datasets

* added vars to test

Co-authored-by: Valeriu Predoi <valeriu.predoi@gmail.com>
Co-authored-by: Tomas Lovato <tomas.lovato@cmcc.it>
Co-authored-by: remi-kazeroni <remi.kazeroni@dlr.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants