-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Assign backfills a run status based on their sub-run statuses #23702
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,25 +122,6 @@ class GrapheneBulkActionStatus(graphene.Enum): | |
class Meta: | ||
name = "BulkActionStatus" | ||
|
||
def to_dagster_run_status(self) -> GrapheneRunStatus: | ||
"""Maps bulk action status to a run status for use with the RunsFeedEntry interface.""" | ||
# the pyright ignores are required because GrapheneBulkActionStatus.STATUS and GrapheneRunStatus.STATUS | ||
# are interpreted as a Literal string during static analysis, but it is actually an Enum value | ||
if self.args[0] == GrapheneBulkActionStatus.REQUESTED.value: # pyright: ignore[reportAttributeAccessIssue] | ||
return GrapheneRunStatus.STARTED # pyright: ignore[reportReturnType] | ||
if self.args[0] == GrapheneBulkActionStatus.COMPLETED.value: # pyright: ignore[reportAttributeAccessIssue] | ||
return GrapheneRunStatus.SUCCESS # pyright: ignore[reportReturnType] | ||
if self.args[0] == GrapheneBulkActionStatus.FAILED.value: # pyright: ignore[reportAttributeAccessIssue] | ||
return GrapheneRunStatus.FAILURE # pyright: ignore[reportReturnType] | ||
if self.args[0] == GrapheneBulkActionStatus.CANCELED.value: # pyright: ignore[reportAttributeAccessIssue] | ||
return GrapheneRunStatus.CANCELED # pyright: ignore[reportReturnType] | ||
if self.args[0] == GrapheneBulkActionStatus.CANCELING.value: # pyright: ignore[reportAttributeAccessIssue] | ||
return GrapheneRunStatus.CANCELING # pyright: ignore[reportReturnType] | ||
|
||
raise DagsterInvariantViolationError( | ||
f"Unable to convert BulkActionStatus {self.args[0]} to a RunStatus. {self.args[0]} is an unknown status." | ||
) | ||
|
||
|
||
class GrapheneAssetBackfillTargetPartitions(graphene.ObjectType): | ||
class Meta: | ||
|
@@ -511,8 +492,44 @@ def resolve_tags(self, _graphene_info: ResolveInfo): | |
if get_tag_type(key) != TagType.HIDDEN | ||
] | ||
|
||
def resolve_runStatus(self, _graphene_info: ResolveInfo) -> GrapheneRunStatus: | ||
return GrapheneBulkActionStatus(self.status).to_dagster_run_status() | ||
def resolve_runStatus(self, _graphene_info: ResolveInfo) -> str: | ||
converted_status = BulkActionStatus[self.status] | ||
if converted_status is BulkActionStatus.FAILED: | ||
return GrapheneRunStatus.FAILURE | ||
if converted_status is BulkActionStatus.CANCELED: | ||
return GrapheneRunStatus.CANCELED | ||
if converted_status is BulkActionStatus.CANCELING: | ||
return GrapheneRunStatus.CANCELING | ||
if converted_status is BulkActionStatus.REQUESTED: | ||
# if no runs have been launched: | ||
if len(self._get_records(_graphene_info)) == 0: | ||
return GrapheneRunStatus.QUEUED | ||
return GrapheneRunStatus.STARTED | ||
# BulkActionStatus.COMPLETED | ||
# Backfills are only marked as COMPLETED once all runs that are part of the backfill have reached | ||
# a finished state (SUCCESS, FAILURE, or CANCELED). So we only need to check for those | ||
# statuses to determine the overall status of the backfill. | ||
sub_runs = self._get_records(_graphene_info) | ||
sub_run_statuses = [record.dagster_run.status.value for record in sub_runs] | ||
if all(status == "SUCCESS" for status in sub_run_statuses): | ||
return GrapheneRunStatus.SUCCESS | ||
if any(status == "FAILURE" or status == "CANCELED" for status in sub_run_statuses): | ||
return GrapheneRunStatus.FAILURE | ||
|
||
# can't import this because two deserializers get registered for PipelineRunStatsSnapshot | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather use the code below to check the statuses of the runs, but if I import @whitelist_for_serdes(storage_name="PipelineRunStatsSnapshot")
class DagsterRunStatsSnapshot(
... collides with Not sure what there is to de about this other than move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Surprised that that would help with the serdes error, but moving it to a separate module seems like a nice thing to me. |
||
# from python_modules.dagster.dagster._core.storage.dagster_run import DagsterRunStatus | ||
# | ||
# sub_run_statuses = [record.dagster_run.status for record in sub_runs] | ||
# if all(status == DagsterRunStatus.SUCCESS for status in sub_run_statuses): | ||
# return GrapheneRunStatus.SUCCESS | ||
# if any(status == DagsterRunStatus.FAILURE for status in sub_run_statuses): | ||
# return GrapheneRunStatus.FAILURE | ||
# if any(status == DagsterRunStatus.CANCELED for status in sub_run_statuses): | ||
# return GrapheneRunStatus.FAILURE | ||
|
||
raise DagsterInvariantViolationError( | ||
f"Unable to convert BulkActionStatus {self.args[0]} to a RunStatus. {self.args[0]} is an unknown status." | ||
) | ||
|
||
def resolve_endTimestamp(self, graphene_info: ResolveInfo) -> Optional[float]: | ||
if self._backfill_job.status == BulkActionStatus.REQUESTED: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be not_started? starting? or just map to Started for all in requested state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
STARTING
might make sense here, but if it'sSTARTED
, it's not a big deal.