[com4]: allow executing FlowPy from a different repo with cfg overwrite#1298
[com4]: allow executing FlowPy from a different repo with cfg overwrite#1298PaulaSp3 wants to merge 3 commits into
Conversation
|
Coverage Impact ⬆️ Merging this pull request will increase total coverage on 🛟 Help
|
There was a problem hiding this comment.
Good addition - should work as a quick hack and not break any current usage of the script.
For a more permanent solution I would suggest at least to address the following points:
- instead of just returning
uidat every exit point of the function we can return sth. like a named tuple or dictionary with the uid and a function exit status, that lets the caller now if the function executed com4FlowPy successfully or did not run the model - because input was incorrect, result folders already exist --> see extra comment below - write a small test that confirms the expected behavior of the functionality for different scenarios
in addition we could use this to think about how we want to handle the situation of already existing results with the same uid, which is currently also not solved well. Maybe we could:
- add an additional check, that also looks if the existing result folder with the
uidis populated with valid resultFiles instead of just checking if the folder already exists (now this could also result from a previously started, but aborted model run) --> this would fix Issue #1135 - add an additional function parameter
overwritewhere the user can specify e.g.default--> don't run simulation if results with sameuidalready there;overwriteif sims should be performed any way
|
|
||
| def main(avalancheDir=""): | ||
| def main(avalancheDir="", cfg=None): | ||
| """this is a wrapper around com4FlowPy.py that handles the following tasks: |
There was a problem hiding this comment.
since main is now designed to be also callable from outside runCom4FlowPy.py pls update the docstring of the function to include this info:
- Parameters
- add
avalancheDirand expected dataType - add
cfgand describe expected type of cfg
- add
- Returns
- add
uidor any updated return values and describe
- add
| ) | ||
| ) | ||
| sys.exit(1) | ||
| return uid |
There was a problem hiding this comment.
In this case if there is already a resultFolder with the same uid there is currently no way for a caller of the function to tell if the simulation was actually run (returns uid) or not performend, because an existing ResultsFolder with the same uid is already present (also returns uid).
maybe we can return a dictionary / named tuple or sth. similar instead, where alongside uid we also provide an exitStatus that tells the caller if:
- model was run successfully
- model was not run, because input parameters were incorrect
- model was not run, because results for model run with the same
uidalready exist
same comment applies to the other return uid statements
could look sth. like this
# necessary additional imports
from enum import Enum, auto
class Status(Enum):
SUCCESS = auto()
SIMULATION_ALREADY_EXISTS = auto()
ERROR = auto()
WHATEVER_ELSE = auto()
def main():
...
return{"uid": uid, "status": Status.SUCCESS}
...
return{"uid": uid, "status: Status.SIMULATION_ALREADY_EXISTS
...
in this way caller functions know, if the model ran successfully or not + we can also update the code inside if __name__ == "__main__": accordingly

No description provided.