Skip to content

Commit

Permalink
Fix incorrect temporary directory creation in VirtualenvOperator cons…
Browse files Browse the repository at this point in the history
…tructor
  • Loading branch information
tatiana committed Aug 30, 2023
1 parent 53dbb38 commit 6590b80
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cosmos/operators/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(
self.py_requirements = py_requirements or []
self.py_system_site_packages = py_system_site_packages
super().__init__(**kwargs)
self._venv_tmp_dir = TemporaryDirectory()
self._venv_tmp_dir: None | TemporaryDirectory[str] = None

@cached_property
def venv_dbt_path(
Expand Down
2 changes: 2 additions & 0 deletions tests/operators/test_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def test_run_command(
py_system_site_packages=False,
py_requirements=["dbt-postgres==1.6.0b1"],
)
assert venv_operator._venv_tmp_dir is None # Otherwise we are creating empty directories during DAG parsing time
# and not deleting them
venv_operator.run_command(cmd=["fake-dbt", "do-something"], env={}, context={})
run_command_args = mock_subprocess_hook.run_command.call_args_list
assert len(run_command_args) == 3
Expand Down

0 comments on commit 6590b80

Please sign in to comment.