Skip to content

Commit 69d0bdd

Browse files
authored
Merge pull request #38 from DHI/dev_fixed
Changes from Dev with a proper merge of main
2 parents 6bfc141 + f503f17 commit 69d0bdd

File tree

10 files changed

+30
-26
lines changed

10 files changed

+30
-26
lines changed

CHANGELOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22

33
## [Unreleased]
44

5-
## [2024.0.0] - 2024-01-30
5+
## [2024.1.0] - 2024-01-30
66

77
### Added
88

99
- Ability to read/write MIKE+ database
1010
- Ability to run engines (MIKE 1D, EPANET, SWMM)
1111
- Ability to run some initial tools
12+
13+
## [2024.1.0] - 2024-06-02
14+
15+
### Added
16+
17+
- Fix Opening and closing a database in a loop takes increasingly long time
18+
- Fix setting the value of a database does not auto cast values. Int value can accept as double value now.
19+
- Fix inserting fails silently when no value is provided for 'Seq'
20+
- Handle Nullable value more user friendly

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ MIKE+Py is a python interface for MIKE+. Its main features include:
1313
> * If you encounter any issues or have any feedback, please report them on [GitHub Issues](https://github.com/DHI/mikepluspy/issues).
1414
1515
## Requirements
16-
* MIKE+ 2024 (or greater) with valid license
16+
* MIKE+ 2024 update 1 (or greater) with valid license
1717
* Python x64 3.8 to 3.12
1818
* Windows operating system
1919

@@ -26,7 +26,7 @@ The version of MIKE+Py you install must match the version of MIKE+ installed on
2626
2727
| MIKE+ Version | Install command|
2828
|:--------------|:---------------|
29-
| MIKE+ 2024 | `pip install https://github.com/DHI/mikepluspy/archive/refs/tags/v2024.0-latest.zip` |
29+
| MIKE+ 2024 update 1 | `pip install https://github.com/DHI/mikepluspy/archive/refs/tags/v2024.1-latest.zip` |
3030

3131

3232
## Examples

mikeplus/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import clr
22

3-
__version__ = "2024.0.0"
3+
__version__ = "2024.1.0"
44

55
clr.AddReference("DHI.Mike.Install, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c513450b5d0bf0bf")
66
from DHI.Mike.Install import MikeImport, MikeProducts

mikeplus/datatableaccess.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os.path
2+
import System
23
from System import Object
34
from System import String
45
from System.Collections.Generic import Dictionary
@@ -196,7 +197,10 @@ def insert(self, table_name, muid, values=None):
196197
value_dict = Dictionary[String, Object]()
197198
if values is not None:
198199
for col in values:
199-
value_dict[col] = values[col]
200+
if isinstance(values[col], int):
201+
value_dict[col] = System.Nullable[int](values[col])
202+
else:
203+
value_dict[col] = values[col]
200204
result, new_muid = self._datatables[table_name].InsertByCommand(muid, None, value_dict, False, False)
201205

202206
def delete(self, table_name, muid):

mikeplus/engines/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
clr.AddReference("DHI.Amelia.DataModule.Interface")
99
clr.AddReference("DHI.Amelia.Infrastructure.Interface")
1010
clr.AddReference("DHI.Amelia.GlobalUtility")
11-
clr.AddReference("DHI.Amelia.DomainServices")
12-
clr.AddReference("DHI.Amelia.DomainServices.Interface")
11+
clr.AddReference("DHI.Amelia.Tools.EngineTool")
1312

1413
from .engine1d import Engine1D
1514
from .epanet import EPANET

mikeplus/engines/epanet.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os.path
2-
from DHI.Amelia.DomainServices.Services import AmeliaEngineService
3-
from DHI.Amelia.DomainServices.Services import AmeliaDataService
2+
from DHI.Amelia.Tools.EngineTool import EngineTool
43
from DHI.Amelia.GlobalUtility.DataType import MUSimulationOption
54
from DHI.Amelia.DataModule.Interface.Services import IMwProjectTable
65
from System.Threading import CancellationTokenSource
@@ -41,14 +40,11 @@ def run_engine_epanet(self,
4140

4241
if verbose:
4342
print("Simulation id is " + simMuid)
44-
data_service = AmeliaDataService()
45-
data_service.DataTables = self._dataTables
46-
engine_service = AmeliaEngineService()
47-
engine_service.DataTables = self._dataTables
48-
engine_service.DataService = data_service
43+
engine_tool = EngineTool()
44+
engine_tool.DataTables = self._dataTables
4945
cancel_source = CancellationTokenSource()
5046
msg = List[str]()
51-
success = engine_service.RunEngine_AllEpanet(MUSimulationOption.WD_EPANET, cancel_source.Token, msg, None, None, None, simMuid, None, None)
47+
success = engine_tool.RunEngine_AllEpanet(MUSimulationOption.WD_EPANET, cancel_source.Token, msg, None, None, None, simMuid, None, None)
5248
if self._result_file is None:
5349
self._result_file = self._get_result_file(simMuid)
5450
dir = os.path.dirname(os.path.abspath(self._result_file))

mikeplus/engines/swmm.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os.path
2-
from DHI.Amelia.DomainServices.Services import AmeliaEngineService
3-
from DHI.Amelia.DomainServices.Services import AmeliaDataService
2+
from DHI.Amelia.Tools.EngineTool import EngineTool
43
from DHI.Amelia.DataModule.Interface.Services import IMProjectTable
54
from System.Threading import CancellationTokenSource
65
from System.Collections.Generic import List
@@ -40,14 +39,11 @@ def run(self,
4039

4140
if verbose:
4241
print("Simulation id is " + simMuid)
43-
data_service = AmeliaDataService()
44-
data_service.DataTables = self._dataTables
45-
engine_service = AmeliaEngineService()
46-
engine_service.DataTables = self._dataTables
47-
engine_service.DataService = data_service
42+
engine_tool = EngineTool()
43+
engine_tool.DataTables = self._dataTables
4844
cancel_source = CancellationTokenSource()
4945
msg = List[str]()
50-
success = engine_service.RunEngine_AllSWMM(cancel_source.Token, msg, None, None, None, simMuid, None, None)
46+
success = engine_tool.RunEngine_AllSWMM(cancel_source.Token, msg, None, None, None, simMuid, None, None)
5147
if self._result_file is None:
5248
self._result_file = self._get_result_file(simMuid)
5349
dir = os.path.dirname(os.path.abspath(self._result_file))

notebooks/ToolsAccessor.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
"\n",
182182
"catch_ids = [\"imp3\"]\n",
183183
"tool = CathSlopeLengthProcess(data_access.datatables)\n",
184-
"tool.run(catch_ids, \"../tests/testdata/catchSlopeLen/Catch_Slope.shp\", \"tests/testdata/catchSlopeLen/dem.dfs2\", 0)"
184+
"tool.run(catch_ids, \"../tests/testdata/catchSlopeLen/Catch_Slope.shp\", \"../tests/testdata/catchSlopeLen/dem.dfs2\", 0)"
185185
]
186186
},
187187
{

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exclude = ["notebooks", "tests"]
77

88
[project]
99
name = "mikeplus"
10-
version = "2024.0.0"
10+
version = "2024.1.0"
1111
dependencies = [
1212
"numpy",
1313
'pythonnet<=2.5.2; python_version < "3.7.0"',

tests/test_engine.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def test_mike1d_engine():
9-
res_1d_file = os.path.join("tests", "testdata", "Db", "Sirius", "Sirius_RR_and_HDBaseDefault_Network_HD.res1d")
9+
res_1d_file = os.path.join("tests", "testdata", "Db", "Sirius", "Sirius_1_DEMOBaseDefault_Network_HD.res1d")
1010
if os.path.exists(res_1d_file):
1111
os.remove(res_1d_file)
1212
dbFile = os.path.join("tests", "testdata", "Db", "Sirius", "Sirius.sqlite")

0 commit comments

Comments
 (0)