-
Notifications
You must be signed in to change notification settings - Fork 216
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
Create env_postprocessing.xml in case root #4742
Merged
jedwards4b
merged 11 commits into
ESMCI:master
from
mnlevy1981:add_postprocessing_env_file
Mar 5, 2025
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
80102ad
Create env_postprocessing.xml in case root
mnlevy1981 44e4b46
Merge tag 'cime6.1.67' into add_postprocessing_env_file
mnlevy1981 1e9b23e
Add _file_exists to Postprocessing class
mnlevy1981 cac27fe
create env_postprocessing.xml if spec file exists
mnlevy1981 3517d8a
Update action/cached to v3
mnlevy1981 d393f0c
Move logic to remove empty env_postprocessing.xml
mnlevy1981 b2bbd83
Fix CI
mnlevy1981 f9da5bb
Only append EnvPostprocessing in two situations:
mnlevy1981 abbff8a
Update logic for removing env_postprocessing.xml
mnlevy1981 b1f8a44
Model may not define POSTPROCESSING_SPEC_FILE
mnlevy1981 d58c5ea
Merge branch 'master' into add_postprocessing_env_file
mnlevy1981 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
Interface to the env_postprocessing.xml file. This class inherits from EnvBase | ||
""" | ||
from CIME.XML.standard_module_setup import * | ||
|
||
from CIME.XML.env_base import EnvBase | ||
|
||
from CIME import utils | ||
from CIME.utils import convert_to_type | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class EnvPostprocessing(EnvBase): | ||
def __init__( | ||
self, case_root=None, infile="env_postprocessing.xml", read_only=False | ||
): | ||
""" | ||
initialize an object interface to file env_postprocessing.xml in the case directory | ||
""" | ||
schema = os.path.join(utils.get_schema_path(), "env_entry_id.xsd") | ||
|
||
EnvBase.__init__(self, case_root, infile, schema=schema, read_only=read_only) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Interface to the config_postprocessing.xml file. This class inherits from EntryID | ||
""" | ||
|
||
from CIME.XML.standard_module_setup import * | ||
from CIME.XML.entry_id import EntryID | ||
from CIME.XML.files import Files | ||
from CIME.utils import expect | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Postprocessing(EntryID): | ||
def __init__(self, infile=None, files=None): | ||
""" | ||
initialize an object | ||
""" | ||
if files is None: | ||
files = Files() | ||
if infile is None: | ||
infile = files.get_value("POSTPROCESSING_SPEC_FILE") | ||
expect(infile, "No postprocessing file defined in {}".format(files.filename)) | ||
|
||
schema = files.get_schema("POSTPROCESSING_SPEC_FILE") | ||
|
||
EntryID.__init__(self, infile, schema=schema) | ||
|
||
# Append the contents of $HOME/.cime/config_postprocessing.xml if it exists | ||
# This could cause problems if node matchs are repeated when only one is expected | ||
infile = os.path.join(os.environ.get("HOME"), ".cime", "config_postprocessing.xml") | ||
if os.path.exists(infile): | ||
EntryID.read(self, infile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Here I think that you want to make sure POSTPROCESSING_SPEC_FILE exists before you create an EnvPostprocessing object.
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 mentioned this on Slack, but realized I should keep this thread going as well...
self.get_value("POSTPROCESSING_SPEC_FILE")
isNone
at this point. I tried otherenv_case.xml
variables likeMODEL
and gotNone
as well, so I thinkget_values()
doesn't work in theCase.read_xml()
method. How can I get the value ofPOSTPROCESSING_SPEC_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.
Maybe generate the almost empty env_postprocessing.xml here and then delete it (or not) when POSTPROCESSING_SPEC_FILE is available.
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.
We'll see how testing goes, but I think the logic for removing
env_postprocessing.xml
if it is empty actually belongs inCase.flush()
instead ofCase.configure()
; that's what d393f0c does (though I realized I spun up a new sandbox on my laptop to test this off the supercomputer and didn't runpre-commit
... so there will be at least one more "fix CI" commit coming)