Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ repos:
- id: rst-backticks
- id: python-check-mock-methods
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
rev: v1.5.6
hooks:
- id: remove-crlf
- id: remove-tabs
Expand All @@ -83,13 +83,13 @@ repos:
- --py310-plus
- --keep-runtime-typing
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.11
rev: v0.14.13
hooks:
- id: ruff
args:
- --fix
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.12.0
rev: 26.1.0
hooks:
- id: black
args: ["--config", "./pyproject.toml"]
Expand Down
1 change: 1 addition & 0 deletions cosmos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Contains dags, task groups, and operators.
"""

from __future__ import annotations

from cosmos import settings
Expand Down
6 changes: 2 additions & 4 deletions cosmos/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,8 @@ def __init__(
validate_changed_config_paths(execution_config, project_config, render_config)

if execution_config.execution_mode != ExecutionMode.VIRTUALENV and execution_config.virtualenv_dir is not None:
logger.warning(
"`ExecutionConfig.virtualenv_dir` is only supported when \
ExecutionConfig.execution_mode is set to ExecutionMode.VIRTUALENV."
)
logger.warning("`ExecutionConfig.virtualenv_dir` is only supported when \
ExecutionConfig.execution_mode is set to ExecutionMode.VIRTUALENV.")

cache_dir = None
cache_identifier = None
Expand Down
2 changes: 1 addition & 1 deletion cosmos/dbt/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def load_via_dbt_ls_without_cache(self) -> None:
) as profile_values,
environ(self.env_vars),
):
(profile_path, env_vars) = profile_values
profile_path, env_vars = profile_values
env = os.environ.copy()
env.update(env_vars)

Expand Down
14 changes: 5 additions & 9 deletions cosmos/operators/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def run_command( # noqa: C901
self._handle_partial_parse(tmp_dir_path)

with self.profile_config.ensure_profile() as profile_values:
(profile_path, env_vars) = profile_values
profile_path, env_vars = profile_values
env.update(env_vars)
logger.debug("Using environment variables keys: %s", env.keys())

Expand Down Expand Up @@ -752,26 +752,22 @@ def _create_asset_uri(openlineage_event: openlineage.client.generated.base.Outpu
if settings.use_dataset_airflow3_uri_standard:
dataset_uri = airflow_3_uri
else:
logger.warning(
f"""
logger.warning(f"""
Airflow 3.0.0 Asset (Dataset) URIs validation rules changed and OpenLineage URIs (standard used by Cosmos) will no longer be valid.
Therefore, if using Cosmos with Airflow 3, the Airflow Dataset URIs will be changed to <{airflow_3_uri}>.
Previously, with Airflow 2.x, the URI was <{airflow_2_uri}>.
If you want to use the Airflow 3 URI standard while still using Airflow 2, please, set:
export AIRFLOW__COSMOS__USE_DATASET_AIRFLOW3_URI_STANDARD=1
Remember to update any DAGs that are scheduled using this dataset.
"""
)
""")
dataset_uri = airflow_2_uri
else:
logger.warning(
f"""
logger.warning(f"""
Airflow 3.0.0 Asset (Dataset) URIs validation rules changed and OpenLineage URIs (standard used by Cosmos) are no longer accepted.
Therefore, if using Cosmos with Airflow 3, the Airflow Asset (Dataset) URI is now <{airflow_3_uri}>.
Before, with Airflow 2.x, the URI used to be <{airflow_2_uri}>.
Please, change any DAGs that were scheduled using the old standard to the new one.
"""
)
""")
dataset_uri = airflow_3_uri
return dataset_uri

Expand Down
7 changes: 2 additions & 5 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,11 +599,8 @@ def test_converter_raises_warning(mock_load_dbt_graph, execution_mode, virtualen
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


@pytest.mark.parametrize(
Expand Down
12 changes: 4 additions & 8 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,26 @@ def test_enable_cache_env_var():


def test_enable_memory_optimised_imports_true(monkeypatch):
script = textwrap.dedent(
"""
script = textwrap.dedent("""
import os
os.environ["AIRFLOW__COSMOS__ENABLE_MEMORY_OPTIMISED_IMPORTS"] = "True"
import cosmos
assert cosmos.settings.enable_memory_optimised_imports is True
assert not hasattr(cosmos, "DbtDag")
"""
)
""")

result = subprocess.run(["python", "-c", script], capture_output=True, text=True)
assert result.returncode == 0, result.stderr


def test_enable_memory_optimised_imports_false(monkeypatch):
script = textwrap.dedent(
"""
script = textwrap.dedent("""
import os
os.environ["AIRFLOW__COSMOS__ENABLE_MEMORY_OPTIMISED_IMPORTS"] = "False"
import cosmos
assert cosmos.settings.enable_memory_optimised_imports is False
assert hasattr(cosmos, "DbtDag")
"""
)
""")

result = subprocess.run(["python", "-c", script], capture_output=True, text=True)
assert result.returncode == 0, result.stderr