Comments (12)
This is now implemented in REFACTORING_backend_developconfig
.
@valeriupredoi and @bouweandela: it would be good if you could test it on your machines.
@bouweandela: please have a look at the error messages, I am not sure what is the best practice here.
@axel-lauer: you could try to add CMIP3 as a test, I will send you a config file for our cluster.
Thanks!
from esmvaltool.
from esmvaltool.
Hi Valeriu, I think these fixes do not apply to REFACTORING_backend_developconfig
, since the root paths definitions have been moved out of the code.
from esmvaltool.
from esmvaltool.
Hi Mattia,
Looks good, you manage to do the same thing with 500 lines of code less!
Testing
it works fine with namelist_MyVar.yml, but I had to change config-user.yml a bit to make it work, did you forget to commit the updated config-user.yml file?
Error messages
I think this covers two topics: (1) logging and raising exceptions and (2) how to do string formatting
Logging and raising exceptions
I think we may need to define a few custom exceptions that we can raise if a user does something wrong. As far as I can see there are four places where we depend on user input:
- config-user.yml
- input data
- namelist
- diagnostic code
so I think we could add four custom exceptions and for these cases make sure we check the user input and we raise those if the user does something wrong and catch them with nice error message in the log. Probably all of those exceptions would need to inherit from a single ESMValToolError exception.
Apart from that, I think we do not need to raise many exceptions, just log what you are doing and run your code assuming everything is fine. E.g. I think that this style of code:
logger.info("CMIP5: mapping mip %s to realm", mip)
return mipdict[mip]
is preferred to this:
if mip in mipdict:
return mipdict[mip]
raise KeyError("CMIP5: cannot map mip {} to realm".format(mip))
because it is shorter and therefore much more readable and it is often very difficult to cover all the possible things that can go wrong (and code becomes very difficult to read if you try to do this).
String formatting
- Best practice is to always use new style string formatting (i.e. using the
format
method of a string), see https://docs.python.org/3.6/library/string.html#format-examples for examples - Except in log messages, there the format string should be specified using old style formatting, but the formatting arguments should be passed as arguments to the logging function. For example:
yes:logger.info("x has value %s", x)
no:logger.info("x has value %s" % x)
no:logger.info("x has value {}".format(x))
from esmvaltool.
from esmvaltool.
from esmvaltool.
Thanks for testing!
I will take note of your suggestions, but we should merge this now.
We have a working version which is a good basis for starting the integration of the diagnostics.
from esmvaltool.
from esmvaltool.
This is merged now.
Issue closed. :-)
from esmvaltool.
from esmvaltool.
from esmvaltool.
Related Issues (20)
- Results of Su et al. (2014) emergent constraints are wrong HOT 7
- Retire support for python==3.9
- Final sanity check and reorganisation of RTW
- IPCC region extraction for multiple models HOT 3
- Update the version number and release notes for v2.11.0
- Update AERONET data version
- CMIP5 Omon CESM1 data on DKRZ has gone walkies 😕 HOT 13
- Unable to convert units issue with `recipe_climwip_brunner2019_med.yml` HOT 5
- Pin importlib_metadata <8
- Update `scipy.integrate.simps` import HOT 1
- Recipe failures on DKRZ: `OSError: [Errno -101] NetCDF: HDF error` HOT 5
- Data download failure for `recipe_easy_ipcc.yml` HOT 3
- Update ESACCI-SST cmorizer
- Add DKRZ as a site to RTW
- `recipe_preprocessor_derive_test.yml` is broken for CMIP6 toz HOT 12
- Recipes fail when using matplotlib v3.9.0
- Setting global attributes in cmorizers
- fix_metadata for cmip6 awi_esm_1_1_lr fails if "parent_time_units" isn't in attributes dict
- Handle removal of Sphinx context injection at build time deprecation
- Remove `recipe_preprocessor_derive_test.yml` from the list of broken recipes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esmvaltool.