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

484 error handeling in case of empty yaml block #1024

Merged
merged 7 commits into from
Aug 28, 2023

Conversation

nwieters
Copy link
Contributor

Closes #484

@nwieters nwieters linked an issue Aug 18, 2023 that may be closed by this pull request
@nwieters
Copy link
Contributor Author

If there is an empty component in the user runscript:
amip:
or
amip: ""
the entry for this components in the user_config dictionary will be set to an empty dictionary.
user_config[model] = {}

and a user_note will be displayed to stdout:

Warning: YAML syntax
--------------------
The component amip in your configuration file /work/ab0995/a270089/runtime/awicm3-v3.1/run_issue_484_001/scripts/awicm3-v3.1-levante-TCO95L91-CORE2_initial_issue_484.yaml is empty. No further variables are set for this component in your runscript.

@nwieters
Copy link
Contributor Author

Is there a way to prevent the user_note to be displayed twice?
I tried isinteractive but this is not available there.

Besides setting user_config[model] = {} I though about removing it from user_config:
del user_config[model]

What do you think is the better option?

@nwieters nwieters marked this pull request as ready for review August 18, 2023 12:47
Copy link
Member

@pgierz pgierz left a comment

Choose a reason for hiding this comment

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

Looks good! Can go in :-)

@pgierz
Copy link
Member

pgierz commented Aug 18, 2023

Is there a way to prevent the user_note to be displayed twice? I tried isinteractive but this is not available there.

You would need to cache all the warnings and notes and dump them all at the same time to cleanly do that. Don't build that.

Besides setting user_config[model] = {} I though about removing it from user_config: del user_config[model]

What do you think is the better option?

I would rather throw it away. Then we at least get KerError instead of something else that goes bad down the chain.

@nwieters
Copy link
Contributor Author

Thank you @pgierz .

I now remove the empty components from user_config.

This is done before all other config files are merged in.
If you set for example:
oasis3mct:
in the runscript, it will be removed before the oasis configuration will be merged to user_config.

@nwieters nwieters requested a review from pgierz August 18, 2023 13:27
@JanStreffing JanStreffing removed their request for review August 21, 2023 12:06
Copy link
Contributor

@mandresm mandresm left a comment

Choose a reason for hiding this comment

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

It works well, and I'm okay with having a duplication here. I was looking at the code changes that would be needed to avoid the duplication of the warning and I don't think they are worth the time. Ideally this warning will be there for brief time, then people will fix their yaml files and then they won't need to see the double warning anymore.

@mandresm
Copy link
Contributor

#bump

@mandresm mandresm merged commit 61fca0a into release Aug 28, 2023
@mandresm mandresm deleted the 484-error-handeling-in-case-of-empty-yaml-block branch August 28, 2023 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error handeling in case of empty yaml block.
3 participants