You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we now get False, even though nothing has changed on the filesystem. This is because the setup method also calls methods like get on InputDataset and AdditionalCode objects that set attributes like InputDataset.working_path that are related to the local state of the Case, but aren't relevant information to include in a blueprint file. These attributes are thus lost when exiting the session, unless the user runs Case.setup() again. The local working file associated with an InputDataset may be different to the source version (for instance, local netCDF generated from remote yaml), so the distinction between the source material (described in the blueprint) and the local state is nontrivial.
Proposed solution:
Rename the current Case.persist() method to Case.to_blueprint(). This is consistent with the existing Case.from_blueprint() complement method.
Add some sort of local_file_hash attribute that is set when get() is called on objects like InputDatasets and AdditionalCode. This becomes part of the state to be reloaded and can verify that files on disk have not changed between sessions
Add an include_state=True/False parameter on the to_dict methods of fundamental classes. to_dict is used heavily by Case.persist() but currently just includes information for recreating the object from scratch (as is required for blueprint export), not restoring it to its current state.
Define a new Case.persist() that exports the entire local state to a {caseroot}/{case_name}_state.yaml file. This could be called automatically at the successful end of certain methods that update the state, like Case.setup()
Define a Case.restore(caseroot="wherever") method that looks in the caseroot for the state file and re-establishes the exact state that was persisted.
The text was updated successfully, but these errors were encountered:
Issue:
Currently, there is no support for persisting C-Star objects in their current state between python sessions.
Example
If we run
Then
Case.is_setup
returnsTrue
as expected.However, if you exit this session and run
we now get
False
, even though nothing has changed on the filesystem. This is because thesetup
method also calls methods likeget
onInputDataset
andAdditionalCode
objects that set attributes likeInputDataset.working_path
that are related to the local state of theCase
, but aren't relevant information to include in a blueprint file. These attributes are thus lost when exiting the session, unless the user runsCase.setup()
again. The local working file associated with anInputDataset
may be different to the source version (for instance, local netCDF generated from remote yaml), so the distinction between the source material (described in the blueprint) and the local state is nontrivial.Proposed solution:
Case.persist()
method toCase.to_blueprint()
. This is consistent with the existingCase.from_blueprint()
complement method.local_file_hash
attribute that is set whenget()
is called on objects likeInputDatasets
andAdditionalCode
. This becomes part of the state to be reloaded and can verify that files on disk have not changed between sessionsinclude_state=True/False
parameter on theto_dict
methods of fundamental classes.to_dict
is used heavily byCase.persist()
but currently just includes information for recreating the object from scratch (as is required for blueprint export), not restoring it to its current state.Case.persist()
that exports the entire local state to a{caseroot}/{case_name}_state.yaml
file. This could be called automatically at the successful end of certain methods that update the state, likeCase.setup()
Case.restore(caseroot="wherever")
method that looks in the caseroot for the state file and re-establishes the exact state that was persisted.The text was updated successfully, but these errors were encountered: