Skip to content

feat: log sqlmesh errors to dagster #10

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

Merged
merged 1 commit into from
Feb 24, 2025
Merged
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
12 changes: 9 additions & 3 deletions dagster_sqlmesh/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def warning(self, message: str, obj: t.Optional[t.Dict[str, t.Any]] = None):
self.log("warning", message, obj)

def error(self, message: str, obj: t.Optional[t.Dict[str, t.Any]] = None):
self.log("warning", message, obj)
self.log("error", message, obj)

def log(self, level: str | int, message: str, obj: t.Optional[t.Dict[str, t.Any]]):
self._handler.log(level, message, self.ensure_standard_obj(obj))
Expand Down Expand Up @@ -180,15 +180,17 @@ def report_event(self, event: console.ConsoleEvent):
"duration_ms": duration_ms,
},
)

case console.LogSuccess(success):
self.update_stage("done")
if success:
log_context.info("sqlmesh ran successfully")
else:
log_context.error("sqlmesh failed")
raise Exception("sqlmesh failed during run")

case console.LogError(message):
log_context.error(
message,
)
case _:
log_context.debug("Received event")

Expand All @@ -201,6 +203,10 @@ def log(
message: str,
obj: t.Optional[t.Dict[str, t.Any]] = None,
):
if level == "error":
self._logger.error(message)
return

obj = obj or {}
final_obj = obj.copy()
final_obj["message"] = message
Expand Down