From 85099430631289aac4caf6aa55217e05378dec52 Mon Sep 17 00:00:00 2001 From: pankajastro Date: Mon, 28 Apr 2025 19:05:22 +0530 Subject: [PATCH 1/2] Fix test_integration_virtualenv_operator Remove template --- dev/dags/example_virtualenv_mini.py | 9 ++++++++- tests/operators/test_virtualenv.py | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dev/dags/example_virtualenv_mini.py b/dev/dags/example_virtualenv_mini.py index 849847a25b..6130acadf7 100644 --- a/dev/dags/example_virtualenv_mini.py +++ b/dev/dags/example_virtualenv_mini.py @@ -8,6 +8,11 @@ from cosmos.operators.virtualenv import DbtSeedVirtualenvOperator from cosmos.profiles import PostgresUserPasswordProfileMapping +try: + from airflow.providers.standard.operators.bash import BashOperator +except ImportError: + from airflow.operators.bash import BashOperator + DEFAULT_DBT_ROOT_PATH = Path(__file__).resolve().parent / "dbt" DBT_PROJ_DIR = Path(os.getenv("DBT_ROOT_PATH", DEFAULT_DBT_ROOT_PATH)) / "jaffle_shop" @@ -21,6 +26,8 @@ ) with DAG("example_virtualenv_mini", start_date=datetime(2022, 1, 1)) as dag: + pre = BashOperator(task_id="pre", bash_command="mkdir /tmp/persistent-venv2") + seed_operator = DbtSeedVirtualenvOperator( profile_config=profile_config, project_dir=DBT_PROJ_DIR, @@ -32,4 +39,4 @@ py_requirements=["dbt-postgres"], virtualenv_dir=Path("/tmp/persistent-venv2"), ) - seed_operator + pre >> seed_operator diff --git a/tests/operators/test_virtualenv.py b/tests/operators/test_virtualenv.py index 9a766808bf..0e2f0c7363 100644 --- a/tests/operators/test_virtualenv.py +++ b/tests/operators/test_virtualenv.py @@ -381,8 +381,6 @@ def test__release_venv_lock_current_process(tmpdir): assert not lockfile.exists() -# TODO: Make test compatible with Airflow 3.0. Issue: https://github.com/astronomer/astronomer-cosmos/issues/1707 -@pytest.mark.skipif(AIRFLOW_VERSION.major == 3, reason="Test need to be updated for Airflow 3.0") @pytest.mark.skipif( AIRFLOW_VERSION < Version("2.5"), reason="This error is only reproducible with dag.test, which was introduced in Airflow 2.5", From ab82177f2229355058b90c3a129d12c06ddb9e5e Mon Sep 17 00:00:00 2001 From: pankajastro Date: Mon, 28 Apr 2025 22:59:52 +0530 Subject: [PATCH 2/2] Fix command --- dev/dags/example_virtualenv_mini.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/dags/example_virtualenv_mini.py b/dev/dags/example_virtualenv_mini.py index 6130acadf7..9d5e42cced 100644 --- a/dev/dags/example_virtualenv_mini.py +++ b/dev/dags/example_virtualenv_mini.py @@ -26,7 +26,7 @@ ) with DAG("example_virtualenv_mini", start_date=datetime(2022, 1, 1)) as dag: - pre = BashOperator(task_id="pre", bash_command="mkdir /tmp/persistent-venv2") + pre = BashOperator(task_id="pre", bash_command="mkdir -p /tmp/persistent-venv2") seed_operator = DbtSeedVirtualenvOperator( profile_config=profile_config,