Skip to content

Commit 1549463

Browse files
committed
fix: corrected relative paths to create reproducibility configuration file.
tests: modified tests to handle newly implemented docker volumes set up.
1 parent 3a3535c commit 1549463

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

floatcsep/experiment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ def as_dict(self, extra: Sequence = (), extended=False) -> dict:
613613
"name": self.name,
614614
"config_file": self.config_file,
615615
"path": self.registry.workdir.as_posix(),
616-
"run_dir": self.registry.rel(self.registry.run_dir).as_posix(),
616+
"run_dir": Path(self.registry.workdir, self.registry.run_dir.name),
617617
"time_config": {
618618
i: j
619619
for i, j in self.time_config.items()

tests/unit/test_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_reproduce(self, mock_reproducibility_report, mock_exp_comparison, mock_
109109
mock_reproduced_exp.run.assert_called_once()
110110

111111
mock_experiment.from_yml.assert_any_call(
112-
mock_reproduced_exp.original_config, rundir=mock_reproduced_exp.original_run_dir
112+
mock_reproduced_exp.original_config, run_dir=mock_reproduced_exp.original_run_dir
113113
)
114114
mock_original_exp.stage_models.assert_called_once()
115115
mock_original_exp.set_tasks.assert_called_once()

tests/unit/test_environments.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import venv
33
import unittest
44
import subprocess
5+
from pathlib import Path
56
from unittest.mock import patch, MagicMock, call, mock_open
67
import shutil
78
import hashlib
@@ -474,8 +475,8 @@ def test_run_command_success(self):
474475

475476
uid, gid = os.getuid(), os.getgid()
476477
expected_volumes = {
477-
os.path.join(self.model_dir, "input"): {"bind": "/app/input", "mode": "rw"},
478-
os.path.join(self.model_dir, "forecasts"): {"bind": "/app/forecasts", "mode": "rw"},
478+
Path(self.model_dir, "input"): {"bind": "/app/input", "mode": "rw"},
479+
Path(self.model_dir, "forecasts"): {"bind": "/app/forecasts", "mode": "rw"},
479480
}
480481
self.mock_client.containers.run.assert_called_once_with(
481482
self.manager.image_tag,

tests/unit/test_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def assertEqualModel(model_a, model_b):
3131
if isinstance(getattr(model_a, i), ModelRegistry):
3232
continue
3333
if not (getattr(model_a, i) == getattr(model_b, i)):
34-
print(getattr(model_a, i), getattr(model_b, i))
3534
raise AssertionError("Models are not equal")
3635

3736

@@ -98,7 +97,6 @@ def test_from_dict(self):
9897
self.assertEqual(".csv", model_a.registry.fmt)
9998
self.assertEqual(Path(self._dir), model_a.registry.dir)
10099

101-
# print(model_a.__dict__, model_b.__dict__)
102100
self.assertEqualModel(model_a, model_b)
103101

104102
with self.assertRaises(IndexError):
@@ -177,6 +175,8 @@ def setUp(self):
177175
# Set attributes on the mock objects
178176
self.mock_registry_instance.workdir = Path("/path/to/workdir")
179177
self.mock_registry_instance.path = Path("/path/to/model")
178+
self.mock_registry_instance.get_input_dir = MagicMock()
179+
self.mock_registry_instance.get_input_dir.return_value = "input"
180180

181181
self.mock_registry_instance.get_args_key.return_value = (
182182
"/path/to/args_file.txt" # Mocking the return of the registry call
@@ -300,7 +300,7 @@ def test_create_forecast(self, prep_args_mock):
300300
self.model.create_forecast(tstring, force=True)
301301

302302
self.mock_environment_instance.run_command.assert_called_once_with(
303-
f"{self.func} {self.model.registry.get_args_key()}"
303+
command=f"{self.func}", input_dir="input"
304304
)
305305

306306
@patch("pathlib.Path.exists", return_value=True)

0 commit comments

Comments
 (0)