Skip to content

Commit

Permalink
Fix test and add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajastro committed May 17, 2024
1 parent e1e5527 commit 3b6c772
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
56 changes: 56 additions & 0 deletions docs/configuration/cosmos-conf.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Cosmos Config
=============

This page contains the list of all available Airflow configurations and environment variables specific to ``astronomer-cosmos`` that can be set in the airflow.cfg file or using environment variables.

.. note::
For more information, see `Setting Configuration Options <https://airflow.apache.org/docs/apache-airflow/stable/howto/set-config.html>`_.

**Sections:**

- [cosmos]
- [openlineage]

[cosmos]
~~~~~~~~

1. ``cache_dir``:
The directory used for caching Cosmos data.

- Default: ``{TMPDIR}/cosmos_cache`` (where ``{TMPDIR}`` is the system temporary directory)

2. ``enable_cache``:
Enable or disable caching of Cosmos data.

- Default: ``True``

3. ``propagate_logs``:
Whether to propagate logs in the Cosmos module.

- Default: ``True``

4. ``dbt_docs_dir``:
The directory path for dbt documentation.

- Default: ``None``

5. ``dbt_docs_conn_id``:
The connection ID for dbt documentation.

- Default: ``None``

[openlineage]
~~~~~~~~~~~~~

1. ``namespace``:
The OpenLineage namespace for tracking lineage.

- Default: If not configured in Airflow configuration, it falls back to the environment variable ``OPENLINEAGE_NAMESPACE``, otherwise it uses ``DEFAULT_OPENLINEAGE_NAMESPACE``.

Environment Variables
~~~~~~~~~~~~~~~~~~~~~

1. ``LINEAGE_NAMESPACE``:
The OpenLineage namespace for tracking lineage.

- Default: If not configured in Airflow configuration, it falls back to the environment variable ``OPENLINEAGE_NAMESPACE``, otherwise it uses ``DEFAULT_OPENLINEAGE_NAMESPACE``.
1 change: 1 addition & 0 deletions docs/configuration/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Cosmos offers a number of configuration options to customize its behavior. For m
Render Config <render-config>

Parsing Methods <parsing-methods>
Configuring <cosmos-conf>
Configuring Lineage <lineage>
Generating Docs <generating-docs>
Hosting Docs <hosting-docs>
Expand Down
3 changes: 3 additions & 0 deletions tests/plugin/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def conf_get(section, key, *args, **kwargs):
return original_conf_get(section, key, *args, **kwargs)

monkeypatch.setattr(conf, "get", conf_get)
monkeypatch.setattr("cosmos.plugin.dbt_docs_dir", "path/to/docs/dir")

response = app.get("/cosmos/dbt_docs")

Expand All @@ -97,6 +98,7 @@ def conf_get(section, key, *args, **kwargs):
return original_conf_get(section, key, *args, **kwargs)

monkeypatch.setattr(conf, "get", conf_get)
monkeypatch.setattr("cosmos.plugin.dbt_docs_dir", "path/to/docs/dir")

if artifact == "dbt_docs_index.html":
mock_open_file.return_value = "<head></head><body></body>"
Expand Down Expand Up @@ -135,6 +137,7 @@ def conf_get(section, key, *args, **kwargs):
return original_conf_get(section, key, *args, **kwargs)

monkeypatch.setattr(conf, "get", conf_get)
monkeypatch.setattr("cosmos.plugin.dbt_docs_conn_id", "mock_conn_id")

with patch.object(cosmos.plugin, open_file_callback) as mock_callback:
mock_callback.return_value = "mock file contents"
Expand Down
8 changes: 2 additions & 6 deletions tests/test_log.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import logging

from airflow.configuration import conf

from cosmos import get_provider_info
from cosmos.log import get_logger

Expand All @@ -17,10 +15,8 @@ def test_get_logger():
assert custom_string in custom_logger.handlers[0].formatter._fmt


def test_propagate_logs_conf():
if not conf.has_section("cosmos"):
conf.add_section("cosmos")
conf.set("cosmos", "propagate_logs", "False")
def test_propagate_logs_conf(monkeypatch):
monkeypatch.setattr("cosmos.log.propagate_logs", False)
custom_logger = get_logger("cosmos-log")
assert custom_logger.propagate is False

Expand Down

0 comments on commit 3b6c772

Please sign in to comment.