Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasraabe committed May 19, 2024
1 parent 79789f0 commit cf00d68
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/pytask_stata/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run_stata_script(
_cwd: Path,
) -> None:
"""Run an R script."""
cmd = [_executable, "-e", "do", _script.as_posix(), *_options, _log_name]
cmd = [_executable, "-e", "do", _script.as_posix(), *_options, f"-{_log_name}"]
print("Executing " + " ".join(cmd) + ".") # noqa: T201
subprocess.run(cmd, cwd=_cwd, check=True) # noqa: S603

Expand Down Expand Up @@ -165,17 +165,16 @@ def pytask_collect_task(
# Add log_name node that depends on the task id.
if session.config["platform"] == "win32":
log_name = convert_task_id_to_name_of_log_file(task)
log_name_arg = f"-{log_name}"
else:
log_name_arg = ""
log_name = ""

log_name_node = session.hook.pytask_collect_node(
session=session,
path=path_nodes,
node_info=NodeInfo(
arg_name="_log_name",
path=(),
value=PythonNode(value=log_name_arg),
value=PythonNode(value=log_name),
task_path=path,
task_name=name,
),
Expand Down
2 changes: 1 addition & 1 deletion src/pytask_stata/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def pytask_execute_task_teardown(session: Session, task: PTask) -> None:
"""
if has_mark(task, "stata"):
if session.config["platform"] == "win32":
log_name = task.depends_on["_log_name"]
log_name = task.depends_on["_log_name"].load()
if isinstance(task, PTaskWithPath):
path_to_log = task.path.with_name(log_name).with_suffix(".log")
else:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,6 @@ def test_with_task_without_path(runner, tmp_path):
assert tmp_path.joinpath("auto.dta").exists()

if sys.platform == "win32":
assert tmp_path.joinpath("lambda.log").exists()
assert tmp_path.joinpath("task_example_py_lambda.log").exists()
else:
assert tmp_path.joinpath("lambda.log").exists()
assert not tmp_path.joinpath("task_example_py_lambda.log").exists()

0 comments on commit cf00d68

Please sign in to comment.