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
Deprecate defining write_plots and write_netcdf in config-user file #808
Conversation
…fig-user.yml Please define those settings in the diagnostic script setting of the recipe instead, for those diagnostic scripts that support these settings
@stefsmeets Do you think it still makes sense to implement unit tests for this, given that you're going to change everything anyway in #785? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I was thinking just marking the config parameters is enough (see comments).
@@ -1242,15 +1242,22 @@ def _initialize_scripts(self, diagnostic_name, raw_scripts, | |||
if self._cfg['write_ncl_interface']: | |||
settings['exit_on_ncl_warning'] = self._cfg['exit_on_warning'] | |||
for key in ( | |||
'output_file_type', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is enough to just mark the parameters as deprecated in the config and raise a warning. I think it would be better to keep this part of the code 'as-is' for now. The checks to re-add the keys below adds clutter. Save these for a later patch, and apply it to remove the parameters from the entire codebase for 2.3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with keeping this as is, is that the parameters from config-user.yml then overwrite what it says in the recipe, and people might get confused that it doesn't work if they add the setting in the recipe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if the warning is given for the config, then that should be enough in my opinion. Maybe it would be then a good idea to do a double check in the recipe runner and re-issue the warning there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be then a good idea to do a double check in the recipe runner and re-issue the warning there.
Do you mean here by the 'recipe runner'? Wouldn't that result in the same amount of code clutter, but less user friendly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I was thinking if that is the problem, we can also warn users as late as possible -- when the recipe is being executed by what I called the recipe runner 😅
I did not understand that the variables from the user config overwrite the recipe, which I guess is what added the complexity in the first place. Whatever is added here, we should make sure it is easy to undo.
@@ -367,10 +367,7 @@ def _write_ncl_settings(self): | |||
'run_dir', | |||
'plot_dir', | |||
'work_dir', | |||
'output_file_type', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, don't delete these variables just yet and remove the block to add them back below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some change is needed here, because otherwise these settings will not be available as variable diag_script_info@write_plots
etc, making it impossible to adjust diagnostic scripts to the new situtation before they are removed in 2.3. As an intermediate step, I thought I would make them available as both diag_script_info@write_plots
and config_user_info@write_plots
and then remove the latter in version 2.3.
esmvalcore/_task.py
Outdated
@@ -549,15 +553,12 @@ def _collect_provenance(self): | |||
'exit_on_ncl_warning', | |||
'input_files', | |||
'log_level', | |||
'output_file_type', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would ignore recording their value in the provenance, so it would break the idea that all diagnostic script settings are recorded in the provenance
Should be alright. The fact that they are deprecated means we should not be testing for it anyway. |
Thanks for reviewing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
am not actually requesting changes, I am just thinking these options are indeed not needed anymore but the functional infrastructure they offer is useful - am thinking for the future when we may get to a point where we use a web based interface that runs diagnostics in the backend and the user gets a nice output that they can immediately use for a paper or presentation etc - the write_netcdf
and output_format
would be nice to be a tunable button
I vote strongly against removing I don't have a strong opinion about the other two options (more in favor of removing them), but I would really like to keep |
albeit never used by me (but then again I don't do science), am glad to see this being used and with a good potential for the future quick-run WPS user. Cheers for commenting @schlunma 🍺 |
Thanks for the comments @valeriupredoi and @schlunma! Did you also have a look at issue #93 for the reasoning behind removing these settings?
@schlunma It would be even more convenient if the diagnostic simply wrote both file formats, because then you wouldn't even need to re-run or change a setting to get the plots in a different the format. Since plotting is not a very time-consuming process, I think the time saving is very minimal. The arguments against having the feature are that it provides a poor user experience because many of the diagnostics do not respect the setting and the user needs to select the right output type before running. Also, it might not be so easy to implement this feature consistently across all diagnostics, for example: I doubt whether the R plotting library supports the same output file types as the Python plotting library or the NCL plotting library. I can add a small plotting function to the ESMValTool diag_scripts/shared function that plots several types by default and use it from the example recipe for demonstration purposes, would that make sense? Do you think
@valeriupredoi |
Alright, that does make sense for me. A small function that writes import matplotlib.pyplot as plt
def savefig(basename, cfg, fig=None, ext=None **kwargs):
if ext is None:
ext = ['png', 'pdf']
paths = ... # get correct paths with basename, ext and cfg
plot_object = plt if fig is None else fig
for path in paths:
plot_object.savefig(path, **kwargs) Just as a small side note: Plotting might be time-consuming in rare cases, e.g. I have an example where I plot a scatterplot with ~200'000 points. In this case it's also not useful to save the file as '*.pdf', since this has more than 100 MB and takes 10min to open on my local machine. However, I think is a rare exception. |
cheers for the debate, guys - always useful to discuss things this way 👍 I agree with you all - I am happy the defaults are back and as for the plots file types I think there's more than two right? - eps, png, jpg, pdf, gif (yeah we should implement a gif, we can make climate change memes 😁 - no but seriously, for looking at moving stuff in plots) - so I think that should be tunable since I don't see the need to output all these out. I reckon it's best kept under the hood now (hence remove the optionality from config) but keep the functionality 🍺 |
might not be as rare as David Attenborough would say - the Autoassess diags output hundreds of plots 🍺 |
This needs to be adjusted to take into account #868 and the feature will now be removed in v2.4, because it didn't make it for the 2.1 release. |
No, there is no big plan for what will be deprecated when, but once something is deprecated this should be written down in the changelog for that release, including a note on when the feature will be removed.
I updated the issue |
Can you please update these, so we can do it for this release? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed a couple of 2.3, but nothing really serious
Co-authored-by: Javier Vegas-Regidor <javier.vegas@bsc.es>
…cate-write-plots-netcdf-type
Just wondering if these are still up-to-date:
I marked them for 2.2, but I think it should be 2.3 or 2.4 now also? |
I think they're fine, deprecate in 2.2 (the upcoming release) and remove in 2.4 (in autumn). |
…cate-write-plots-netcdf-type
After looking through the code of ESMValTool to see what it would take to remove |
@jvegasbsc @valeriupredoi @stefsmeets Could you have another look at this please to see if anything remains to be done before this can be merged? It would be nice if we could include it in the v2.2 release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, cheers @bouweandela - do we have an issue in ESMValTool about this (to remove the bits in the diags that are deprecated)?
Good point! See ESMValGroup/ESMValTool#2005 |
noice! I added a "future release" label there because it's cool to have one 😁 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This two should point to 2.4, no?
Co-authored-by: Javier Vegas-Regidor <javier.vegas@bsc.es>
Deprecate use of write_plots, write_netcdf, output_file_type config-user file
Please define those settings in the diagnostic script setting of the recipe instead, for those diagnostic scripts that support these settings
See #93
Tasks
Add unit testsSkipped because all this code is going to be replaced in Implement importable config object #785 soon