Skip to content

Commit

Permalink
Merge branch 'main' into feature/621_extforce_converter
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurvd committed Nov 11, 2024
2 parents 26e6d9b + 1ef664e commit 2fb8c8b
Show file tree
Hide file tree
Showing 24 changed files with 1,897 additions and 1,675 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.12"]
python-version: ["3.9", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macos-13]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Run image
uses: abatilo/actions-poetry@v2
uses: abatilo/actions-poetry@v2.3.0
with:
poetry-version: 1.8.2
poetry-version: 1.8.3
- name: Cache Poetry virtualenv
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: ~/.virtualenvs
Expand All @@ -40,11 +40,16 @@ jobs:
run: poetry install
if: steps.cache.outputs.cache-hit != 'true'

- name: list env contents
run: |
poetry show
pip list
- name: Test with pytest
run: poetry run pytest --cov . --cov-report xml:coverage-reports/coverage-hydrolib-core.xml --junitxml=xunit-reports/xunit-result-hydrolib-core.xml

- name: Autoformat code if the check fails
if: ${{ (matrix.os == 'ubuntu-latest') && (matrix.python-version == 3.8) }}
if: ${{ (matrix.os == 'ubuntu-latest') && (matrix.python-version == 3.12) }}
run: |
poetry run isort .
poetry run black .
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Run image
uses: abatilo/[email protected]
with:
poetry-version: 1.4.0
poetry-version: 1.8.3
- name: Cache Poetry virtualenv
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: ~/.virtualenvs
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docs_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Run image
uses: abatilo/[email protected]
with:
poetry-version: 1.4.0
poetry-version: 1.8.3
- name: Cache Poetry virtualenv
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: ~/.virtualenvs
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.9]
python-version: [3.12]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Run image
uses: abatilo/[email protected]
with:
poetry-version: 1.4.0
poetry-version: 1.8.3

- name: Cache Poetry virtualenv
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: ~/.virtualenvs
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Run image
uses: abatilo/[email protected]
with:
poetry-version: 1.4.0
poetry-version: 1.8.3

- name: Cache Poetry virtualenv
uses: actions/cache@v3
uses: actions/cache@v4
id: cache
with:
path: ~/.virtualenvs
key: venv-ubuntu-latest-3.8-${{ hashFiles('**/poetry.lock') }}
key: venv-ubuntu-latest-${{ hashFiles('**/poetry.lock') }}

- name: Set Poetry config
run: |
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ When starting development on a branch, a pull request should be created for revi
In the description text area on GitHub, use a [closing keyword](https://docs.github.com/articles/closing-issues-using-keywords) such that this PR will be automatically linked to the issue.
For example: `Fixes #160`.

During continuous integration, the checks will be run with python 3.8, 3.9 and 3.12 on Windows, Ubuntu and MacOS. The checks consist of running the tests, checking the code formatting and running SonarCloud.
During continuous integration, the checks will be run with several Python versions on Windows, Ubuntu and MacOS. The checks consist of running the tests, checking the code formatting and running SonarCloud.
We advise to use a draft pull request, to prevent the branch to be merged back before developement is finished. When the branch is ready for review, you can update the status of the pull request to "ready for review".

### Reviews
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pip install hydrolib-core

If you want to create a fresh test environment for hydrolib-core, you could use the following command (only once):
``` bash
conda create -n hydrolib python=3.8 -c conda-forge
conda create -n hydrolib python=3.12 -c conda-forge
```
Prior to the `pip install`, first activate the desired environment:
``` bash
Expand Down
1 change: 1 addition & 0 deletions hydrolib/core/basemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
also represents a file on disk.
"""

import logging
import shutil
from abc import ABC, abstractclassmethod, abstractmethod
Expand Down
1 change: 0 additions & 1 deletion hydrolib/core/dflowfm/extold/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def serialize(
config: SerializerConfig,
save_settings: ModelSaveSettings,
) -> None:

"""
Serialize the given data and write it to a file at the given path.
Expand Down
2 changes: 2 additions & 0 deletions hydrolib/core/dflowfm/gui/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
namespace for storing the branches as branches.gui file
"""

# TODO reconsider the definition and/or filename of the branches.gui (from Prisca)

import logging
Expand All @@ -14,6 +15,7 @@

logger = logging.getLogger(__name__)


# FIXME: GUI does not recongnize this section yet
class BranchGeneral(INIGeneral):
"""The branches.gui file's `[General]` section with file meta data."""
Expand Down
2 changes: 1 addition & 1 deletion hydrolib/core/dflowfm/ini/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def feed_line(self, line: str) -> None:
line (str): The line to parse
"""
if not self._is_empty_line(line):
for (is_line_type, handle_line_type) in self._feed_line[self._state]:
for is_line_type, handle_line_type in self._feed_line[self._state]:
if is_line_type(line):
handle_line_type(line)
break
Expand Down
1 change: 1 addition & 0 deletions hydrolib/core/dflowfm/ini/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""util.py provides additional utility methods related to handling ini files.
"""

from datetime import datetime
from enum import Enum
from operator import eq
Expand Down
6 changes: 3 additions & 3 deletions hydrolib/core/dflowfm/mdu/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1892,7 +1892,7 @@ class Comments(INIBasedModel.Comments):
)
kmx: Optional[str] = Field("Number of vertical layers.", alias="kmx")
layertype: Optional[str] = Field(
"Number of vertical layers.", alias="layerType"
"1= sigma-layers, 2 = z-layers, 3 = use VertplizFile.", alias="layerType"
)
numtopsig: Optional[str] = Field(
"Number of sigma-layers on top of z-layers.", alias="numTopSig"
Expand Down Expand Up @@ -2015,7 +2015,7 @@ class Comments(INIBasedModel.Comments):
thindamfile: Optional[List[PolyFile]] = Field(None, alias="thinDamFile")
fixedweirfile: Optional[List[PolyFile]] = Field(None, alias="fixedWeirFile")
pillarfile: Optional[List[PolyFile]] = Field(None, alias="pillarFile")
usecaching: bool = Field(False, alias="useCaching")
usecaching: bool = Field(True, alias="useCaching")
vertplizfile: Optional[PolyFile] = Field(None, alias="vertPlizFile")
frictfile: Optional[List[FrictionModel]] = Field(
None, alias="frictFile", delimiter=";"
Expand Down Expand Up @@ -2079,7 +2079,7 @@ class Comments(INIBasedModel.Comments):
)
dxmin1d: float = Field(0.001, alias="dxmin1D")
uniformtyp1dstreetinlets: int = Field(-2, alias="uniformTyp1DStreetInlets")
stretchtype: int = Field(1, alias="stretchType")
stretchtype: int = Field(-1, alias="stretchType")
zlaybot: float = Field(-999.0, alias="zlayBot")
zlaytop: float = Field(-999.0, alias="zlayTop")
uniformheight1d: float = Field(3.0, alias="uniformHeight1D")
Expand Down
6 changes: 3 additions & 3 deletions hydrolib/core/dflowfm/obs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class ObservationPoint(INIBasedModel):

class Comments(INIBasedModel.Comments):
name: Optional[str] = "Name of the observation point (max. 255 characters)."
locationtype: Optional[
str
] = "Only when x and y are also specified. 1d: snap to closest 1D grid point, 2d: snap to closest 2D grid cell centre, all: snap to closest 1D or 2D point."
locationtype: Optional[str] = (
"Only when x and y are also specified. 1d: snap to closest 1D grid point, 2d: snap to closest 2D grid cell centre, all: snap to closest 1D or 2D point."
)
branchid: Optional[str] = Field(
"Branch on which the observation point is located.", alias="branchId"
)
Expand Down
2 changes: 2 additions & 0 deletions hydrolib/core/dflowfm/structure/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
structure namespace for storing the contents of an [FMModel][hydrolib.core.dflowfm.mdu.models.FMModel]'s structure file.
"""

# TODO Implement the following structures
# - Gate

Expand Down Expand Up @@ -35,6 +36,7 @@

ForcingData = Union[float, TimModel, ForcingModel]


# TODO: handle comment blocks
# TODO: handle duplicate keys
class Structure(INIBasedModel):
Expand Down
16 changes: 8 additions & 8 deletions hydrolib/core/rr/meteo/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def serialize(event_data: Dict, config: SerializerConfig) -> str:
**event_data,
**BuiEventSerializer.get_timedelta_fields(ts_duration),
}
event_data[
"timeseries_length"
] = BuiEventSerializer.serialize_timeseries_length(
event_data["timeseries_length"]
event_data["timeseries_length"] = (
BuiEventSerializer.serialize_timeseries_length(
event_data["timeseries_length"]
)
)
event_data[
"precipitation_per_timestep"
] = BuiEventSerializer.serialize_precipitation_per_timestep(
event_data["precipitation_per_timestep"], config
event_data["precipitation_per_timestep"] = (
BuiEventSerializer.serialize_precipitation_per_timestep(
event_data["precipitation_per_timestep"], config
)
)
if "event_idx" not in event_data.keys():
event_data["event_idx"] = 1
Expand Down
Loading

0 comments on commit 2fb8c8b

Please sign in to comment.