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
Allow multiple references for a cmorizer script #1953
Conversation
@axel-lauer, @zklaus and @stefsmeets I am wondering if one of you can review this PR. Thanks in advance. |
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 to me! Just a small suggestion to re-factor the failure condition.
if bibtex_file.is_file(): | ||
reference_entry = bibtex_file.read_text() | ||
if re.search("doi", reference_entry): | ||
reference_doi.append( | ||
f'doi:{re.search(pattern, reference_entry).group(1)}' | ||
) | ||
else: | ||
reference_doi.append('doi not found') | ||
logger.warning( | ||
'The reference file %s does not have a doi.', bibtex_file | ||
) | ||
else: | ||
reference_doi.append('doi not found') | ||
logger.warning( | ||
'The reference file %s does not exist.', bibtex_file |
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'm just wondering if we can do this to get rid of the double failure condition:
if bibtex_file.is_file(): | |
reference_entry = bibtex_file.read_text() | |
if re.search("doi", reference_entry): | |
reference_doi.append( | |
f'doi:{re.search(pattern, reference_entry).group(1)}' | |
) | |
else: | |
reference_doi.append('doi not found') | |
logger.warning( | |
'The reference file %s does not have a doi.', bibtex_file | |
) | |
else: | |
reference_doi.append('doi not found') | |
logger.warning( | |
'The reference file %s does not exist.', bibtex_file | |
success = False | |
if bibtex_file.is_file(): | |
reference_entry = bibtex_file.read_text() | |
if re.search("doi", reference_entry): | |
reference_doi.append( | |
f'doi:{re.search(pattern, reference_entry).group(1)}' | |
) | |
success = True | |
if not success: | |
reference_doi.append('doi not found') | |
logger.warning( | |
'The reference file %s does not exist.', bibtex_file |
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.
@stefsmeets thank you for the suggestion. Please note the failure and logger messages are not the same. The first failure is when there is not any doi in the bibtex file whereas the second indicates there is no a bibtex file for the tag. I think that clear logger messages are useful, what do you think?
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.
Oh, I completely looked over that. I agree with you, I just think this function got a bit too complicated for what it does.
I just tested this new feature and it works nicely. @SarahAlidoost thanks for your quick help! Would you like to consider the changes proposed by @stefsmeets ? This could be merged then and resolves the problem we ran into in PR #1895. |
Co-authored-by: Stef Smeets <stefsmeets@users.noreply.github.com>
Thanks @SarahAlidoost and @stefsmeets. This looks great and if there are no objections I would like to get this merged very soon. |
Please discuss your idea with the development team before getting started, to avoid disappointment later. The way to do this is to open a new issue on GitHub.
If you are planning to modify existing functionality, please discuss it with the original author(s) by tagging them in the issue.
Before you start, please read our contribution guidelines.
To understand how we review and merge pull requests, have a look at our review guidelines.
Closes #1951
Checklist for technical review
Please useyamllint
to check that your YAML files do not contain mistakes(Only if really necessary) Add any additional dependencies needed for the diagnostic script to setup.py, esmvaltool/install/R/r_requirements.txt or esmvaltool/install/Julia/Project.toml (depending on the language of your script) and also to package/meta.yaml for conda dependencies (includes Python and others, but not R/Julia). Also check that the license of the dependency you want to add and any of its dependencies are compatible with Apache2.0.New or updated recipe/diagnostic:doc/sphinx/source/recipes
folder and an entry has been added toindex.rst
New or updated data reformatting script:Automated checks pass, status can be seen below the pull request:
Details
link to find out why.Details
link to see it.Checklist for scientific review
New or updated recipe/diagnostic:@esmvalbot
without any modifications to the recipe and with all data specified in the recipeNew or updated data reformatting script:If you need help with any of the items on the checklists above, please do not hesitate to ask by commenting in the issue or pull request.