Skip to content

Commit 641507e

Browse files
authored
Make output folder part of stage templates (#144)
* Do not add "output" directory when executing stage * Update CHANGELOG * Create output directory as part of template * Add output directories to template
1 parent 1b5361f commit 641507e

9 files changed

Lines changed: 18 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ and this project adheres to [Semantic Versioning][].
1212

1313
### Fixes
1414

15+
- Fix how the `output` directory in stages is treated. Previously, the `output` directory was not
16+
part of of the stage template. Instead it got added dynamically during `dso exec quarto` and removed
17+
again in case it was empty. This could lead to failures of `dvc repro`, because `dvc` removed the `output`
18+
directory on repro, expecting it to be recreated by the script. Now, the `output` directory is part of the
19+
stage template, and a `mkdir -p output` is included in the stage command, ensuring that the directory will
20+
always be created ([#144](https://github.com/Boehringer-Ingelheim/dso/pull/144)).
1521
- Exit gracefully when aborting template selections ([#134](https://github.com/Boehringer-Ingelheim/dso/pull/134)).
1622
- Make sure watermarking doesn't modify external images inplace ([#140](https://github.com/Boehringer-Ingelheim/dso/pull/140)).
1723
- Do not exclude `meta.yaml` from templates. We leave it up to the templates to .gitignore them ([#142](https://github.com/Boehringer-Ingelheim/dso/pull/142)).
@@ -50,7 +56,7 @@ and this project adheres to [Semantic Versioning][].
5056

5157
### Template updates
5258

53-
- Add `_quarto.yml` to "init" template ([#115](https://github.com/Boehringer-Ingelheim/dso/pull/115))
59+
- Add `_quarto.yml` to "init" template `.gitignore` ([#115](https://github.com/Boehringer-Ingelheim/dso/pull/115))
5460

5561
### Chore
5662

src/dso/_util.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import sys
66
import tomllib
77
from collections.abc import Sequence
8-
from contextlib import contextmanager
98
from functools import cache
109
from os import environ
1110
from pathlib import Path
@@ -160,20 +159,6 @@ def _update_dot_dso_json(dir: Path, update_dict: dict):
160159
json.dump(config, f)
161160

162161

163-
@contextmanager
164-
def add_directory(dir: Path):
165-
"""Context manager that temporarily creates a directory and removes it again if it's empty"""
166-
dir.mkdir(exist_ok=True)
167-
try:
168-
yield
169-
finally:
170-
try:
171-
dir.rmdir()
172-
except OSError:
173-
# directory not empty
174-
pass
175-
176-
177162
def check_ask_pre_commit(dir: Path):
178163
"""
179164
Check if pre-commit hooks are installed and asks to install them

src/dso/cli/_exec.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from ruamel.yaml import YAML
66

77
from dso._logging import log
8-
from dso._util import add_directory
98

109

1110
@click.command("quarto")
@@ -74,15 +73,14 @@ def dso_exec_quarto(stage: str, skip_compile: bool = True):
7473
except KeyError:
7574
pass
7675

77-
with add_directory(stage_dir / "output"):
78-
with quarto_config_yml(quarto_config, stage_dir / "src"):
79-
render_quarto(
80-
stage_dir / "src",
81-
report_dir=stage_dir / "report",
82-
before_script=before_script,
83-
cwd=stage_dir,
84-
with_pandocfilter="watermark" in quarto_config or "disclaimer" in quarto_config,
85-
)
76+
with quarto_config_yml(quarto_config, stage_dir / "src"):
77+
render_quarto(
78+
stage_dir / "src",
79+
report_dir=stage_dir / "report",
80+
before_script=before_script,
81+
cwd=stage_dir,
82+
with_pandocfilter="watermark" in quarto_config or "disclaimer" in quarto_config,
83+
)
8684

8785

8886
@click.group(name="exec")

src/dso/templates/stage/quarto_ipynb/dvc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ stages:
88
- output
99
- report/{{ name }}.html
1010
cmd:
11+
- mkdir -p output
1112
- uv run dso exec quarto .

src/dso/templates/stage/quarto_ipynb/output/.gitkeeptemplate

Whitespace-only changes.

src/dso/templates/stage/quarto_py/dvc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ stages:
88
- output
99
- report/{{ name }}.html
1010
cmd:
11+
- mkdir -p output
1112
- uv run dso exec quarto .

src/dso/templates/stage/quarto_py/output/.gitkeeptemplate

Whitespace-only changes.

src/dso/templates/stage/quarto_r/dvc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ stages:
88
- output
99
- report/{{ name }}.html
1010
cmd:
11+
- mkdir -p output
1112
- dso exec quarto .

src/dso/templates/stage/quarto_r/output/.gitkeeptemplate

Whitespace-only changes.

0 commit comments

Comments
 (0)