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
1 change: 1 addition & 0 deletions cosmos/operators/aws_ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def build_and_run_cmd(
cmd_flags: list[str] | None = None,
run_as_async: bool = False,
async_context: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
self.build_command(context, cmd_flags)
self.log.info(f"Running command: {self.command}")
Expand Down
1 change: 1 addition & 0 deletions cosmos/operators/azure_container_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def build_and_run_cmd(
cmd_flags: list[str] | None = None,
run_as_async: bool = False,
async_context: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
self.build_command(context, cmd_flags)
self.log.info(f"Running command: {self.command}")
Expand Down
3 changes: 2 additions & 1 deletion cosmos/operators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,15 @@ def build_and_run_cmd(
cmd_flags: list[str],
run_as_async: bool = False,
async_context: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
"""Override this method for the operator to execute the dbt command"""

def execute(self, context: Context, **kwargs) -> Any | None: # type: ignore
if self.extra_context:
context_merge(context, self.extra_context)

self.build_and_run_cmd(context=context, cmd_flags=self.add_cmd_flags())
self.build_and_run_cmd(context=context, cmd_flags=self.add_cmd_flags(), **kwargs)


class DbtBuildMixin:
Expand Down
1 change: 1 addition & 0 deletions cosmos/operators/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def build_and_run_cmd(
cmd_flags: list[str] | None = None,
run_as_async: bool = False,
async_context: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
self.build_command(context, cmd_flags)
self.log.info(f"Running command: {self.command}")
Expand Down
1 change: 1 addition & 0 deletions cosmos/operators/gcp_cloud_run_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def build_and_run_cmd(
cmd_flags: list[str] | None = None,
run_as_async: bool = False,
async_context: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
self.build_command(context, cmd_flags)
self.log.info(f"Running command: {self.command}")
Expand Down
2 changes: 2 additions & 0 deletions cosmos/operators/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def build_and_run_cmd(
cmd_flags: list[str] | None = None,
run_as_async: bool = False,
async_context: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
self.build_kube_args(context, cmd_flags)
self.log.info(f"Running command: {self.arguments}")
Expand Down Expand Up @@ -360,6 +361,7 @@ def build_and_run_cmd(
cmd_flags: list[str] | None = None,
run_as_async: bool = False,
async_context: dict[str, Any] | None = None,
**kwargs: Any,
) -> Any:
if self.warning_handler:
self.warning_handler.context = context
Expand Down
7 changes: 6 additions & 1 deletion cosmos/operators/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,12 @@ def build_and_run_cmd(
dbt_cmd, env = self.build_cmd(context=context, cmd_flags=cmd_flags)
dbt_cmd = dbt_cmd or []
result = self.run_command(
cmd=dbt_cmd, env=env, context=context, run_as_async=run_as_async, async_context=async_context, **kwargs
cmd=dbt_cmd,
env=env,
context=context,
run_as_async=run_as_async,
async_context=async_context,
push_run_results_to_xcom=kwargs.get("push_run_results_to_xcom", False),
)
return result

Expand Down
25 changes: 23 additions & 2 deletions tests/operators/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ def test_store_compiled_sql_airflow3() -> None:
"cmd_flags": ["seed", "--full-refresh"],
"run_as_async": False,
"async_context": None,
"push_run_results_to_xcom": False,
},
),
(
Expand All @@ -1000,6 +1001,7 @@ def test_store_compiled_sql_airflow3() -> None:
"cmd_flags": ["build", "--full-refresh"],
"run_as_async": False,
"async_context": None,
"push_run_results_to_xcom": False,
},
),
(
Expand All @@ -1011,6 +1013,7 @@ def test_store_compiled_sql_airflow3() -> None:
"cmd_flags": ["run", "--full-refresh"],
"run_as_async": False,
"async_context": None,
"push_run_results_to_xcom": False,
},
),
(
Expand All @@ -1022,17 +1025,32 @@ def test_store_compiled_sql_airflow3() -> None:
"cmd_flags": ["clone", "--full-refresh"],
"run_as_async": False,
"async_context": None,
"push_run_results_to_xcom": False,
},
),
(
DbtTestLocalOperator,
{},
{"context": {}, "env": {}, "cmd_flags": ["test"], "run_as_async": False, "async_context": None},
{
"context": {},
"env": {},
"cmd_flags": ["test"],
"run_as_async": False,
"async_context": None,
"push_run_results_to_xcom": False,
},
),
(
DbtTestLocalOperator,
{"select": []},
{"context": {}, "env": {}, "cmd_flags": ["test"], "run_as_async": False, "async_context": None},
{
"context": {},
"env": {},
"cmd_flags": ["test"],
"run_as_async": False,
"async_context": None,
"push_run_results_to_xcom": False,
},
),
(
DbtTestLocalOperator,
Expand All @@ -1043,6 +1061,7 @@ def test_store_compiled_sql_airflow3() -> None:
"cmd_flags": ["test", "--select", "tag:daily", "--exclude", "tag:disabled"],
"run_as_async": False,
"async_context": None,
"push_run_results_to_xcom": False,
},
),
(
Expand All @@ -1054,6 +1073,7 @@ def test_store_compiled_sql_airflow3() -> None:
"cmd_flags": ["test", "--selector", "nightly_snowplow"],
"run_as_async": False,
"async_context": None,
"push_run_results_to_xcom": False,
},
),
(
Expand All @@ -1065,6 +1085,7 @@ def test_store_compiled_sql_airflow3() -> None:
"cmd_flags": ["run-operation", "bla", "--args", "days: 7\ndry_run: true\n"],
"run_as_async": False,
"async_context": None,
"push_run_results_to_xcom": False,
},
),
],
Expand Down
Loading