Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,36 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
pip install -r dev-requirements.txt
pip install -e .[R,julia]
pip install -e .[dev,julia]
- name: Setup Apptainer
uses: eWaterCycle/setup-apptainer@v2
with:
apptainer-version: 1.1.9
- name: Pull Docker image
run: docker pull ewatercycle/walrus-grpc4bmi:v0.3.1
- name: Cache Apptainer image
id: cache-apptainer-image
uses: actions/cache@v3
with:
path: ~/.apptainer
key: apptainer-image
- name: Pull Apptainer image
if: steps.cache-apptainer-image.outputs.cache-hit != 'true'
run: apptainer pull docker://ewatercycle/walrus-grpc4bmi:v0.3.1
- uses: r-lib/actions/setup-r@v2
with:
install-r: false
install-r: true
- name: Install R dependencies
run: |
Rscript -e "install.packages('remotes')"
Rscript -e "install.packages('R6')"
- name: Install rpy2 (first requires R to be available).
run: |
pip install -e .[R]
- name: Install Julia
uses: julia-actions/setup-julia@v1
with:
version: '^1.9'
- name: Cache Apptainer image
id: cache-apptainer-image
uses: actions/cache@v3
with:
path: ~/.apptainer
key: apptainer-image
- name: Pull Apptainer image
if: steps.cache-apptainer-image.outputs.cache-hit != 'true'
run: apptainer pull docker://ewatercycle/walrus-grpc4bmi:v0.3.1
- name: Test with pytest
run: |
pytest -vv --cov=grpc4bmi --cov-report xml
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ python3 -m venv .venv
. venv/bin/activate
# Make sure latest pip and wheel are install
pip install -U pip wheel
pip install -r dev-requirements.txt
pip install -e .[dev]
# For R integration also install the R extras with
pip install -e .[R]
# For building docs (cd docs && make html) also install the docs extras with
Expand Down
5 changes: 0 additions & 5 deletions dev-requirements.txt

This file was deleted.

4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode',
'sphinx.ext.napoleon', 'sphinx.ext.intersphinx',
'sphinx.ext.autosectionlabel',
'sphinxarg.ext', 'sphinxcontrib.apidoc',
'sphinxarg.ext', 'sphinx.ext.apidoc',
'sphinx_copybutton', 'sphinxcontrib.jquery',
]

Expand Down Expand Up @@ -175,7 +175,7 @@
]

intersphinx_mapping = {
'https://docs.python.org/': None,
'python': ('https://docs.python.org/', None),
'numpy': ('http://docs.scipy.org/doc/numpy', None),
"bmipy": ("https://bmi.readthedocs.io/en/latest/", None),
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dev = [
"nbconvert",
"ipykernel",
"nbformat",
"bmi-heat@git+https://github.com/csdms/bmi-example-python",
]
docs = [
"sphinx",
Expand Down
2 changes: 1 addition & 1 deletion test/test_apptainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_too_old(self, test_input: str, error_class: Type[ApptainerVersionExcept
with pytest.raises(error_class, match=expected):
check_apptainer_version_string(test_input)

IMAGE_NAME = "docker://ewatercycle/walrus-grpc4bmi:v0.2.0"
IMAGE_NAME = "docker://ewatercycle/walrus-grpc4bmi:v0.3.1"

@pytest.fixture
def walrus_model(tmp_path, walrus_input):
Expand Down
15 changes: 9 additions & 6 deletions test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ def test_initialize_with_nonstring():
assert client is not None
with pytest.raises(TypeError, match='bad argument type for built-in operation'):
client.initialize(42)
client.finalize()
try: # Can't finalize model which is not initialized.
client.finalize()
except MyRpcError as err:
assert "has no attribute '_model'" in str(err)
del client


Expand All @@ -132,7 +135,7 @@ def test_update_until():


def test_get_time_unit():
client, local = make_bmi_classes()
client, local = make_bmi_classes(True)
assert client.get_time_units() == local.get_time_units()
client.finalize()
del client
Expand Down Expand Up @@ -819,18 +822,18 @@ class TestCreateGrpcChannel:
def test_defaults(self):
with BmiClient.create_grpc_channel() as channel:
target = channel._channel.target()
assert target == b'localhost:50051'
assert target == b'dns:///localhost:50051'

def test_custom(self):
with BmiClient.create_grpc_channel(51234, 'somehost') as channel:
target = channel._channel.target()
assert target == b'somehost:51234'
assert target == b'dns:///somehost:51234'

def test_same_port_twice(self):
port = 51235
with BmiClient.create_grpc_channel(port) as channel1, BmiClient.create_grpc_channel(port) as channel2:
assert channel1._channel.target() == b'localhost:51235'
assert channel2._channel.target() == b'localhost:51235'
assert channel1._channel.target() == b'dns:///localhost:51235'
assert channel2._channel.target() == b'dns:///localhost:51235'

class TestModelWithItemSizeZeroAndVarTypeFloat32:
name = 'plate_surface__temperature'
Expand Down
2 changes: 1 addition & 1 deletion test/test_julia.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def model(self, cfg_file):
("get_input_var_names", tuple(), ["plate_surface__temperature"]),
("get_output_var_names", tuple(), ["plate_surface__temperature"]),
("get_start_time", tuple(), 0.0),
("get_end_time", tuple(), np.Inf),
("get_end_time", tuple(), np.inf),
("get_time_step", tuple(), 0.25),
("get_time_units", tuple(), "s"),
("get_var_type", ["plate_surface__temperature"], "float64"),
Expand Down
2 changes: 1 addition & 1 deletion test/test_legacy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_update():


def test_get_time_unit():
server, local = make_bmi_classes()
server, local = make_bmi_classes(True)
assert server.getTimeUnits(None, None).units == make_string(local.get_time_units())
server.finalize(None, None)
del server
Expand Down
8 changes: 5 additions & 3 deletions test/test_memoized.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ def test_nonmemoized_methods(mut_name, mut_args):
mot = getattr(client, mut_name)

mot(*mut_args)
mot(*mut_args)

assert mock_method.call_count == 2
if mut_name != "finalize":
mot(*mut_args)
assert mock_method.call_count == 2
else:
assert mock_method.call_count == 1


def test_initialize_clears_cache():
Expand Down
2 changes: 1 addition & 1 deletion test/test_optionaldest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_methods_with_optional_dest(orig_model, method_name, method_args, expect
[
(BmiHeat(), 'update', tuple()),
(BmiHeat(), 'update_until', [2]),
(BmiHeat(), 'finalize', tuple()),
# (BmiHeat(), 'finalize', tuple()), # Can't test finalize: double finalize not allowed.
(BmiHeat(), 'get_current_time', tuple()),
(BmiHeat(), 'get_component_name', tuple()),
(BmiHeat(), 'get_input_item_count', tuple()),
Expand Down
2 changes: 1 addition & 1 deletion test/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_update():


def test_get_time_unit():
server, local = make_bmi_classes()
server, local = make_bmi_classes(True)
assert server.getTimeUnits(None, None).units == make_string(local.get_time_units())
server.finalize(None, None)
del server
Expand Down
2 changes: 1 addition & 1 deletion test/test_subproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_update():


def test_get_time_unit():
client, local = make_bmi_classes()
client, local = make_bmi_classes(True)
assert client.get_time_units() == local.get_time_units()
client.finalize()
del client
Expand Down
Loading