Skip to content

Commit 8767aa7

Browse files
committed
fix: update render() to return None, fix f-string syntax and variable references
1 parent 1ba3a84 commit 8767aa7

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

src/rompy/core/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class BaseConfig(RompyBaseModel):
4545
def __call__(self, *args, **kwargs):
4646
return self
4747

48-
def render(self, context: dict, output_dir: Path | str) -> str:
48+
def render(self, context: dict, output_dir: Path | str):
4949
"""Render the configuration template to the output directory.
5050
5151
This method orchestrates the template rendering process. The default implementation
@@ -63,4 +63,4 @@ def render(self, context: dict, output_dir: Path | str) -> str:
6363
# Import locally to avoid potential circular imports at module import time
6464
from rompy.core.render import render as cookiecutter_render
6565

66-
return cookiecutter_render(context, self.template, output_dir, self.checkout)
66+
cookiecutter_render(context, self.template, output_dir, self.checkout)

src/rompy/model.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,8 @@ def generate(self) -> str:
254254
cc_full["config"] = self.config
255255

256256
# Render templates
257-
logger.info(
258-
f"Rendering model configurations to {self.output_dir}/{self.run_id}..."
259-
)
260-
staging_dir = self.config.render(cc_full, self.output_dir)
257+
logger.info(f"Rendering model configurations to {self.staging_dir}...")
258+
self.config.render(cc_full, self.output_dir)
261259

262260
logger.info("")
263261
# Use the log_box utility function
@@ -268,8 +266,8 @@ def generate(self) -> str:
268266
logger=logger,
269267
add_empty_line=False,
270268
)
271-
logger.info(f"Model files generated at: {staging_dir}")
272-
return staging_dir
269+
logger.info(f"Model files generated at: {self.staging_dir}")
270+
return self.staging_dir
273271

274272
def zip(self) -> str:
275273
"""Zip the input files for the model run

tests/test_config_render_delegation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_modelrun_delegates_to_config_render(tmp_path):
1111
class TestConfig(BaseConfig):
1212
def render(self, context: dict, output_dir):
1313
# real implementation replaced by mock in the test
14-
return str(tmp_path / "staging")
14+
pass
1515

1616
config = TestConfig(template="../rompy/templates/base", checkout=None)
1717
model_run = ModelRun(run_id="test", output_dir=str(tmp_path), config=config)
@@ -21,7 +21,7 @@ def render(self, context: dict, output_dir):
2121
# the mock was bound to the instance or the class.
2222
# Patch by import path to avoid binding issues with Pydantic-generated classes
2323
with unittest.mock.patch.object(
24-
TestConfig, "render", return_value=str(tmp_path / "staging")
24+
TestConfig, "render", return_value=None
2525
) as mock_render:
2626
# Execute
2727
result = model_run.generate()
@@ -43,4 +43,4 @@ def render(self, context: dict, output_dir):
4343
assert "runtime" in context_arg
4444
assert "config" in context_arg
4545
assert output_dir_arg == model_run.output_dir
46-
assert result == str(tmp_path / "staging")
46+
assert str(result) == str(tmp_path / "test")

0 commit comments

Comments
 (0)