Skip to content

Commit

Permalink
Fix Cosmos enable_cache setting (#1025)
Browse files Browse the repository at this point in the history
As of Cosmos 1.4.1, users are not able to disable the cache in Cosmos
using `AIRFLOW__COSMOS__ENABLE_CACHE=0`.

During a recent refactoring #975, the `enable_cache` was changed to a
non-boolean config. This PR fixes this issue.
  • Loading branch information
tatiana committed Jun 6, 2024
1 parent b9b8aab commit 36ce7ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cosmos/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# In MacOS users may want to set the envvar `TMPDIR` if they do not want the value of the temp directory to change
DEFAULT_CACHE_DIR = Path(tempfile.gettempdir(), DEFAULT_COSMOS_CACHE_DIR_NAME)
cache_dir = Path(conf.get("cosmos", "cache_dir", fallback=DEFAULT_CACHE_DIR) or DEFAULT_CACHE_DIR)
enable_cache = conf.get("cosmos", "enable_cache", fallback=True)
enable_cache = conf.getboolean("cosmos", "enable_cache", fallback=True)
propagate_logs = conf.getboolean("cosmos", "propagate_logs", fallback=True)
dbt_docs_dir = conf.get("cosmos", "dbt_docs_dir", fallback=None)
dbt_docs_conn_id = conf.get("cosmos", "dbt_docs_conn_id", fallback=None)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
from importlib import reload
from unittest.mock import patch

from cosmos import settings


@patch.dict(os.environ, {"AIRFLOW__COSMOS__ENABLE_CACHE": "False"}, clear=True)
def test_enable_cache_env_var():
reload(settings)
assert settings.enable_cache is False

0 comments on commit 36ce7ad

Please sign in to comment.