From 8d937f966107563d7c363508c1b773045ad051d5 Mon Sep 17 00:00:00 2001 From: Ivan Metzlar Date: Mon, 23 Oct 2023 13:01:09 -0700 Subject: [PATCH] Honour `OPENLINEAGE_DISABLED` env var --- cosmos/operators/local.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cosmos/operators/local.py b/cosmos/operators/local.py index c033f33f3..c2294c644 100644 --- a/cosmos/operators/local.py +++ b/cosmos/operators/local.py @@ -74,6 +74,10 @@ class OperatorLineage: # type: ignore LINEAGE_NAMESPACE = os.getenv("OPENLINEAGE_NAMESPACE", DEFAULT_OPENLINEAGE_NAMESPACE) +# In the spirit of: https://github.com/apache/airflow/blob/8531396c7c8bf1e016db10c7d32e5e19298d67e5/airflow/providers/openlineage/plugins/openlineage.py#L30 +is_openlineage_enabled = is_openlineage_available and os.getenv("OPENLINEAGE_DISABLED", "false").lower() != "true" + + class DbtLocalBaseOperator(DbtBaseOperator): """ Executes a dbt core cli command locally. @@ -227,7 +231,7 @@ def run_command( output_encoding=self.output_encoding, cwd=tmp_project_dir, ) - if is_openlineage_available: + if is_openlineage_enabled: self.calculate_openlineage_events_completes(env, Path(tmp_project_dir)) context[ "task_instance"