diff --git a/prefect_dbt_flow/dbt/__init__.py b/prefect_dbt_flow/dbt/__init__.py index 80ebe2d..87c8cc4 100644 --- a/prefect_dbt_flow/dbt/__init__.py +++ b/prefect_dbt_flow/dbt/__init__.py @@ -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 diff --git a/prefect_dbt_flow/dbt/cli.py b/prefect_dbt_flow/dbt/cli.py index 845235e..b3954a7 100644 --- a/prefect_dbt_flow/dbt/cli.py +++ b/prefect_dbt_flow/dbt/cli.py @@ -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)) diff --git a/prefect_dbt_flow/dbt/graph.py b/prefect_dbt_flow/dbt/graph.py index 13f1844..cea0dca 100644 --- a/prefect_dbt_flow/dbt/graph.py +++ b/prefect_dbt_flow/dbt/graph.py @@ -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(