-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from eWaterCycle/allow-apptainer-version
Allow apptainer version
- Loading branch information
Showing
10 changed files
with
183 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
library(R6) | ||
|
||
FakeFailingRModel <- R6Class( | ||
public = list( | ||
# R6 constructor is also called initialize so rename bmi initialize | ||
bmi_initialize = function(config_file) stop('Always fails'), | ||
update = function() stop('Always fails'), | ||
updateUntil = function(until) stop('Always fails'), | ||
updateFrac = function(frac) stop('Always fails'), | ||
# R6 destructor is also called finalize so rename bmi finalize | ||
bmi_finalize = function() stop('Always fails'), | ||
runModel = function() stop('Always fails'), | ||
|
||
getComponentName = function() stop('Always fails'), | ||
getInputVarNames = function() stop('Always fails'), | ||
getOutputVarNames = function() stop('Always fails'), | ||
|
||
getTimeUnits = function() stop('Always fails'), | ||
getTimeStep = function() stop('Always fails'), | ||
getCurrentTime = function() stop('Always fails'), | ||
getStartTime = function() stop('Always fails'), | ||
getEndTime = function() stop('Always fails'), | ||
|
||
getVarGrid = function(name) stop('Always fails'), | ||
getVarType = function(name) stop('Always fails'), | ||
getVarItemSize = function(name) stop('Always fails'), | ||
getVarUnits = function(name) stop('Always fails'), | ||
getVarNBytes = function(name) stop('Always fails'), | ||
|
||
getValue = function(name) stop('Always fails'), | ||
getValueAtIndices = function(name, indices) stop('Always fails'), | ||
|
||
setValue = function(name, values) stop('Always fails'), | ||
setValueAtIndices = function(name, indices, values) stop('Always fails'), | ||
|
||
getGridSize = function(grid_id) stop('Always fails'), | ||
getGridType = function(grid_id) stop('Always fails'), | ||
getGridRank = function(grid_id) stop('Always fails'), | ||
getGridShape = function(grid_id) stop('Always fails'), | ||
getGridSpacing = function(grid_id) stop('Always fails'), | ||
getGridOrigin = function(grid_id) stop('Always fails'), | ||
getGridX = function(grid_id) stop('Always fails'), | ||
getGridY = function(grid_id) stop('Always fails'), | ||
getGridZ = function(grid_id) stop('Always fails'), | ||
getGridConnectivity = function(grid_id) stop('Always fails'), | ||
getGridOffset = function(grid_id) stop('Always fails') | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from pathlib import Path | ||
import numpy as np | ||
import pytest | ||
from rpy2.rinterface_lib.embedded import RRuntimeError | ||
|
||
from grpc4bmi.run_server import BmiR, build_r | ||
|
||
@pytest.fixture | ||
def model(): | ||
return build_r('FakeFailingRModel', 'test/fake.r') | ||
|
||
@pytest.mark.skipif(not BmiR, reason='R and its dependencies are not installed') | ||
class TestFakeFailingRModel: | ||
@pytest.mark.parametrize( | ||
'fn_name,fn_args', | ||
[ | ||
('get_component_name', tuple()), | ||
('get_input_var_names', tuple()), | ||
('get_output_var_names', tuple()), | ||
('get_start_time', tuple()), | ||
('get_end_time', tuple()), | ||
('get_time_step', tuple()), | ||
('get_time_units', tuple()), | ||
('get_var_type', ['plate_surface__temperature']), | ||
('get_var_units', ['plate_surface__temperature']), | ||
('get_var_itemsize', ['plate_surface__temperature']), | ||
('get_var_nbytes', ['plate_surface__temperature']), | ||
('get_var_grid', ['plate_surface__temperature']), | ||
('get_grid_shape', [0]), | ||
('get_grid_x', [0]), | ||
('get_grid_y', [0]), | ||
('get_grid_z', [0]), | ||
('get_grid_spacing', [0]), | ||
('get_grid_origin', [0]), | ||
('get_grid_connectivity', [0]), | ||
('get_grid_offset', [0]), | ||
('get_grid_rank', [0]), | ||
('get_grid_size', [0]), | ||
('get_grid_type', [0]), | ||
('update', tuple()), | ||
('update_until', [2]), | ||
('finalize', tuple()), | ||
('get_current_time', tuple()), | ||
('get_value_at_indices', ['plate_surface__temperature', [1, 2, 3]]), | ||
('set_value', ['plate_surface__temperature', np.ones((10, 20))]), | ||
('set_value_at_indices', ['plate_surface__temperature', [1, 2, 3], [4, 5, 6]]), | ||
# TODO figure out functions below do not raise error | ||
# ('update_frac', [0.5]), | ||
# ('get_value', ['plate_surface__temperature']), | ||
# ('get_value_ref', ['plate_surface__temperature']), | ||
] | ||
) | ||
def test_r_function_is_called(self, model: BmiR, fn_name, fn_args): | ||
# Every method in 'test/fake.r' executes the stop error action | ||
# So if no stop then no r function is called | ||
with pytest.raises(RRuntimeError, match="Always fails"): | ||
fn = getattr(model, fn_name) | ||
fn(*fn_args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters