Skip to content

[com4]: allow executing FlowPy from a different repo with cfg overwrite#1298

Open
PaulaSp3 wants to merge 3 commits into
masterfrom
PS_FP_changeCfgRead
Open

[com4]: allow executing FlowPy from a different repo with cfg overwrite#1298
PaulaSp3 wants to merge 3 commits into
masterfrom
PS_FP_changeCfgRead

Conversation

@PaulaSp3

Copy link
Copy Markdown
Contributor

No description provided.

@PaulaSp3 PaulaSp3 requested a review from ahuber-bfw June 22, 2026 15:26
@PaulaSp3 PaulaSp3 self-assigned this Jun 22, 2026
@PaulaSp3 PaulaSp3 added the flowPyDev Ideas for future development label Jun 22, 2026
@qltysh

qltysh Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Qlty


Coverage Impact

⬆️ Merging this pull request will increase total coverage on master by 0.10%.

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@ahuber-bfw ahuber-bfw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 uid at 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 uid is 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 overwrite where the user can specify e.g. default --> don't run simulation if results with same uid already there; overwrite if sims should be performed any way

Comment thread avaframe/runCom4FlowPy.py

def main(avalancheDir=""):
def main(avalancheDir="", cfg=None):
"""this is a wrapper around com4FlowPy.py that handles the following tasks:

@ahuber-bfw ahuber-bfw Jun 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 avalancheDir and expected dataType
    • add cfg and describe expected type of cfg
  • Returns
    • add uid or any updated return values and describe

Comment thread avaframe/runCom4FlowPy.py
)
)
sys.exit(1)
return uid

@ahuber-bfw ahuber-bfw Jun 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 uid already 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flowPyDev Ideas for future development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants