Skip to content

Commit

Permalink
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Oct 23, 2023
1 parent f33bfc2 commit 384c7b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cosmos/operators/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _get_or_create_venv_py_interpreter(self) -> str:
1. No: Create one in this directory and return it
2. Yes: Return this virtual env
2. No: Create a temporary virtual env and return it
"""
if self._venv_dir is not None:
if self._venv_dir.is_dir():
Expand Down
11 changes: 6 additions & 5 deletions dev/dags/example_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@
),
)


@dag(
schedule_interval="@daily",
start_date=datetime(2023, 1, 1),
catchup=False,
)
def example_virtualenv() -> None:
start_task = EmptyOperator(task_id='start-venv-examples')
end_task = EmptyOperator(task_id='end-venv-examples')
start_task = EmptyOperator(task_id="start-venv-examples")
end_task = EmptyOperator(task_id="end-venv-examples")

tmp_venv_task_group = DbtTaskGroup(
group_id='tmp-venv-group',
group_id="tmp-venv-group",
# dbt/cosmos-specific parameters
project_config=ProjectConfig(
DBT_ROOT_PATH / "jaffle_shop",
Expand All @@ -55,7 +56,7 @@ def example_virtualenv() -> None:
)

cached_venv_task_group = DbtTaskGroup(
group_id='cached-venv-group',
group_id="cached-venv-group",
# dbt/cosmos-specific parameters
project_config=ProjectConfig(
DBT_ROOT_PATH / "jaffle_shop",
Expand All @@ -76,6 +77,6 @@ def example_virtualenv() -> None:

start_task >> [tmp_venv_task_group, cached_venv_task_group] >> end_task


example_virtualenv()
# [END virtualenv_example]

12 changes: 8 additions & 4 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def test_converter_creates_dag_with_seed(mock_load_dbt_graph, execution_mode, op
)
assert converter


@pytest.mark.parametrize(
"execution_mode,virtualenv_dir,operator_args",
[
Expand All @@ -91,14 +92,17 @@ def test_converter_raises_warning(mock_load_dbt_graph, execution_mode, virtualen
target_name="my_target_name",
profiles_yml_filepath=SAMPLE_PROFILE_YML,
)
converter = DbtToAirflowConverter(
DbtToAirflowConverter(
nodes=nodes,
project_config=project_config,
profile_config=profile_config,
execution_config=execution_config,
render_config=render_config,
operator_args=operator_args,
)

assert "`ExecutionConfig.virtualenv_dir` is only supported when \
ExecutionConfig.execution_mode is set to ExecutionMode.VIRTUALENV." in caplog.text

assert (
"`ExecutionConfig.virtualenv_dir` is only supported when \
ExecutionConfig.execution_mode is set to ExecutionMode.VIRTUALENV."
in caplog.text
)

0 comments on commit 384c7b5

Please sign in to comment.