Skip to content

Commit

Permalink
Merge branch 'astronomer:main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
SiddiqueAhmad authored Mar 21, 2024
2 parents 260696e + 4e3a3c8 commit f7d3ea4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cosmos/operators/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,19 +570,21 @@ class DbtDocsLocalOperator(DbtLocalBaseOperator):
"""

ui_color = "#8194E0"
required_files = ["index.html", "manifest.json", "graph.gpickle", "catalog.json"]
required_files = ["index.html", "manifest.json", "catalog.json"]
base_cmd = ["docs", "generate"]

def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs)
self.check_static_flag()

def check_static_flag(self) -> None:
flag = "--static"
if self.dbt_cmd_flags:
if flag in self.dbt_cmd_flags:
if "--static" in self.dbt_cmd_flags:
# For the --static flag we only upload the generated static_index.html file
self.required_files = ["static_index.html"]
if self.dbt_cmd_global_flags:
if "--no-write-json" in self.dbt_cmd_global_flags and "graph.gpickle" in self.required_files:
self.required_files.remove("graph.gpickle")


class DbtDocsCloudLocalOperator(DbtDocsLocalOperator, ABC):
Expand Down
15 changes: 15 additions & 0 deletions tests/operators/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,21 @@ def test_dbt_docs_local_operator_with_static_flag():
assert operator.required_files == ["static_index.html"]


def test_dbt_docs_local_operator_ignores_graph_gpickle():
# Check when --no-write-json is passed, graph.gpickle is removed.
# This is only currently relevant for subclasses, but will become more generally relevant in the future.
class CustomDbtDocsLocalOperator(DbtDocsLocalOperator):
required_files = ["index.html", "manifest.json", "graph.gpickle", "catalog.json"]

operator = CustomDbtDocsLocalOperator(
task_id="fake-task",
project_dir="fake-dir",
profile_config=profile_config,
dbt_cmd_global_flags=["--no-write-json"],
)
assert operator.required_files == ["index.html", "manifest.json", "catalog.json"]


@patch("cosmos.hooks.subprocess.FullOutputSubprocessHook.send_sigint")
def test_dbt_local_operator_on_kill_sigint(mock_send_sigint) -> None:

Expand Down

0 comments on commit f7d3ea4

Please sign in to comment.