Skip to content

Commit aec9ae3

Browse files
committed
Fix executor hook to only fail when actual issues are found
1 parent 8b6829b commit aec9ae3

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/datapilot/core/platforms/dbt/hooks/executor_hook.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,25 +187,34 @@ def main(argv: Optional[Sequence[str]] = None):
187187
if reports:
188188
print("Insights generated successfully. Analyzing results...", file=sys.stderr)
189189
model_report = generate_model_insights_table(reports[MODEL])
190-
if len(model_report) > 0:
190+
project_report = generate_project_insights_table(reports[PROJECT])
191+
192+
# Check if there are actual issues found
193+
has_model_issues = len(model_report) > 0
194+
has_project_issues = len(project_report) > 0
195+
196+
if has_model_issues:
191197
print("--" * 50, file=sys.stderr)
192198
print("Model Insights", file=sys.stderr)
193199
print("--" * 50, file=sys.stderr)
194-
for model_id, report in model_report.items():
195-
print(f"Model: {model_id}", file=sys.stderr)
196-
print(f"File path: {report['path']}", file=sys.stderr)
197-
print(tabulate_data(report["table"], headers="keys"), file=sys.stderr)
198-
print("\n", file=sys.stderr)
200+
for model_id, report in model_report.items():
201+
print(f"Model: {model_id}", file=sys.stderr)
202+
print(f"File path: {report['path']}", file=sys.stderr)
203+
print(tabulate_data(report["table"], headers="keys"), file=sys.stderr)
204+
print("\n", file=sys.stderr)
199205

200-
project_report = generate_project_insights_table(reports[PROJECT])
201-
if len(project_report) > 0:
206+
if has_project_issues:
202207
print("--" * 50, file=sys.stderr)
203208
print("Project Insights", file=sys.stderr)
204209
print("--" * 50, file=sys.stderr)
205210
print(tabulate_data(project_report, headers="keys"), file=sys.stderr)
206211

207-
print("\nPre-commit hook failed: DataPilot found issues that need to be addressed.", file=sys.stderr)
208-
sys.exit(1)
212+
# Only fail if there are actual issues
213+
if has_model_issues or has_project_issues:
214+
print("\nPre-commit hook failed: DataPilot found issues that need to be addressed.", file=sys.stderr)
215+
sys.exit(1)
216+
else:
217+
print("All checks passed! No issues found.", file=sys.stderr)
209218
else:
210219
print("No insights generated. All checks passed!", file=sys.stderr)
211220

0 commit comments

Comments
 (0)