-
Notifications
You must be signed in to change notification settings - Fork 2
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
add Flood engine for 2d and couple models #77
Conversation
US100380: Run 2D models from MIKE+Py
Task100891: Write notebook example to run 2d simulation and coupling simulation.
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 tested and it works fine :) My only comment is to follow PEP 8 convention. This is something we need to clean up for the whole package, but please update it for added code.
You can use ruff to check where PEP 8 isn't used (e.g. snake case over camel case for variables):
$ uv run ruff check --select N .\mikeplus\engines\floodEngine.py
mikeplus\engines\floodEngine.py:1:1: N999 Invalid module name: 'floodEngine'
mikeplus\engines\floodEngine.py:14:24: N803 Argument name `dataTables` should be lowercase
|
12 | """The FloodEngine class can run 1D/2D/FLOOD simulation, print log files, and get the result files path"""
13 |
14 | def __init__(self, dataTables):
| ^^^^^^^^^^ N803
15 | self._dataTables = dataTables
16 | self._result_files = None
|
mikeplus\engines\floodEngine.py:18:19: N803 Argument name `simMuid` should be lowercase
|
16 | self._result_files = None
17 |
18 | def run(self, simMuid=None, verbose=False):
| ^^^^^^^ N803
19 | """Run 1D/2D/Flood simulation
|
mikeplus\engines\floodEngine.py:37:13: N806 Variable `simMuid` in function should be lowercase
|
35 | """
36 | if simMuid is None:
37 | simMuid = self._get_active_muid()
| ^^^^^^^ N806
38 | if simMuid is None:
39 | raise ValueError("Simulation id can't be none.")
|
mikeplus\engines\floodEngine.py:57:9: N806 Variable `engineStart` in function should be lowercase
|
55 | self._result_files = self._get_result_files(simMuid)
56 |
57 | engineStart = False
| ^^^^^^^^^^^ N806
58 | while not launcher.IsEngineRunning:
59 | time.sleep(1)
|
mikeplus\engines\floodEngine.py:60:9: N806 Variable `engineStart` in function should be lowercase
|
58 | while not launcher.IsEngineRunning:
59 | time.sleep(1)
60 | engineStart = True
| ^^^^^^^^^^^ N806
61 |
62 | while engineStart and not launcher.IsEngineExit:
|
mikeplus\engines\floodEngine.py:75:33: N803 Argument name `simMuid` should be lowercase
|
73 | return muid[0]
74 |
75 | def _get_result_files(self, simMuid):
| ^^^^^^^ N803
76 | project = self._dataTables["msm_Project"]
77 | prj = IMsmProjectTable(project)
|
mikeplus\engines\floodEngine.py:84:30: N803 Argument name `simMuid` should be lowercase
|
82 | return res_files
83 |
84 | def _get_log_files(self, simMuid, simOption):
| ^^^^^^^ N803
85 | dbOrMuppFile = Path(self._dataTables.DataSource.BaseFullPath)
86 | dir = dbOrMuppFile.parent
|
mikeplus\engines\floodEngine.py:84:39: N803 Argument name `simOption` should be lowercase
|
82 | return res_files
83 |
84 | def _get_log_files(self, simMuid, simOption):
| ^^^^^^^^^ N803
85 | dbOrMuppFile = Path(self._dataTables.DataSource.BaseFullPath)
86 | dir = dbOrMuppFile.parent
|
mikeplus\engines\floodEngine.py:85:9: N806 Variable `dbOrMuppFile` in function should be lowercase
|
84 | def _get_log_files(self, simMuid, simOption):
85 | dbOrMuppFile = Path(self._dataTables.DataSource.BaseFullPath)
| ^^^^^^^^^^^^ N806
86 | dir = dbOrMuppFile.parent
87 | file_name = dbOrMuppFile.stem
|
mikeplus\engines\floodEngine.py:127:13: N806 Variable `simMuid` in function should be lowercase
|
125 | """
126 | if self._result_files is None:
127 | simMuid = self._get_active_muid()
| ^^^^^^^ N806
128 | self._result_file = self._get_result_files(simMuid)
129 | return self._result_files
|
Found 11 errors.
tests/test_engine.py
Outdated
@@ -58,3 +59,23 @@ def test_swmm_engine(): | |||
data_access.close_database() | |||
os.chdir(current_dir) | |||
assert os.path.exists(result_file) | |||
|
|||
|
|||
@pytest.mark.skip |
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.
This is being skipped because it requires a license. Please use the marker that's appropriate for this so that we can still run the test locally.
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.
Which of the following markers do you prefer? Or do you have any other suggestions?
@pytest.mark.xfail(reason="Test run fail if there's no license")
@pytest.mark.require_license(reason="Test run fail if there's no license")
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.
You can use a marker like this one. A reason is optional (the marker name is explicit).
mikepluspy/tests/test_tools.py
Lines 99 to 102 in a595c07
@pytest.mark.license_required | |
def test_import_tool(): | |
dbFile = os.path.join("tests", "testdata", "import", "import.sqlite") | |
data_access = DataTableAccess(dbFile) |
We don't use xfail since we don't always expect it to fail. We skip it when there's no license, but we can run the test suite without skipping it locally if there's a license 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.
Thanks. I have updated the marker.
change camel case to snake case
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.
Thanks @jue-hu , nice work!
No description provided.