Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when 'dbt ls' returns an empty list in output #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 prefect_dbt_flow/dbt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@ class DbtDagOptions:
select: Optional[str] = None
exclude: Optional[str] = None
run_test_after_model: bool = False
test_selection: str = ''
vars: Optional[dict[str, str]] = None
install_deps: bool = True
2 changes: 2 additions & 0 deletions prefect_dbt_flow/dbt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def dbt_test(
if dag_options:
if dag_options.vars:
dbt_test_cmd.extend(["--vars", f"'{json.dumps(dag_options.vars)}'"])
if dag_options.test_selection != '':
dbt_test_cmd.extend([f"--indirect-selection={dag_options.test_selection}"])

return cmd.run(" ".join(dbt_test_cmd))

Expand Down
4 changes: 4 additions & 0 deletions prefect_dbt_flow/dbt/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def parse_dbt_project(
try:
node_dict = json.loads(line.strip())

# Skip if the line is not a dict, e.g an empty list []
if not isinstance(node_dict, dict):
continue

if node_dict["resource_type"] == "model":
dbt_graph.append(
DbtNode(
Expand Down