Skip to content

Commit

Permalink
fix backfill run termination (#24127)
Browse files Browse the repository at this point in the history
## Summary & Motivation
Could not cancel runs from a backfill - forced users to search on the
runs page and cancel from there.

## How I Tested These Changes
Added a BK test for the `cancelableRuns` field.
Sanity checked with a test run.

## Changelog [Bug]

* Fixed a bug where in-progress runs from a backfill could not be
terminated from the backfill UI.
  • Loading branch information
prha authored Sep 3, 2024
1 parent e6054cc commit 553d74a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ export const BackfillRowLoader = (props: {
const {data} = statusQueryResult;
const {hasCancelableRuns} = React.useMemo(() => {
if (data?.partitionBackfillOrError.__typename === 'PartitionBackfill') {
if ('partitionBackfill' in data.partitionBackfillOrError) {
return {hasCancelableRuns: data.partitionBackfillOrError.cancelableRuns.length > 0};
}
return {hasCancelableRuns: data.partitionBackfillOrError.cancelableRuns.length > 0};
}
return {hasCancelableRuns: false};
}, [data]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def resolve_cancelableRuns(self, graphene_info: ResolveInfo) -> Sequence["Graphe
from dagster_graphql.schema.pipelines.pipeline import GrapheneRun

records = self._get_records(graphene_info)
return [GrapheneRun(record) for record in records if not record.dagster_run.is_cancelable]
return [GrapheneRun(record) for record in records if record.dagster_run.is_cancelable]

def resolve_runs(self, graphene_info: ResolveInfo) -> "Sequence[GrapheneRun]":
from dagster_graphql.schema.pipelines.pipeline import GrapheneRun
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
user
title
description
cancelableRuns {
id
runId
}
}
... on PythonError {
message
Expand Down Expand Up @@ -1063,7 +1067,7 @@ def test_backfill_run_incomplete(self, graphql_context):
[
(DagsterRunStatus.SUCCESS, "2"),
(DagsterRunStatus.SUCCESS, "3"),
(DagsterRunStatus.SUCCESS, "4"),
(DagsterRunStatus.STARTED, "4"),
(DagsterRunStatus.CANCELED, "5"),
],
backfill_id,
Expand All @@ -1080,13 +1084,14 @@ def test_backfill_run_incomplete(self, graphql_context):
assert result.data["partitionBackfillOrError"]["__typename"] == "PartitionBackfill"
assert result.data["partitionBackfillOrError"]["status"] == "COMPLETED"
assert result.data["partitionBackfillOrError"]["numPartitions"] == 4
assert len(result.data["partitionBackfillOrError"]["cancelableRuns"]) == 1
run_stats = _get_run_stats(
result.data["partitionBackfillOrError"]["partitionStatuses"]["results"]
)
assert run_stats.get("total") == 4
assert run_stats.get("queued") == 0
assert run_stats.get("in_progress") == 0
assert run_stats.get("success") == 3
assert run_stats.get("in_progress") == 1
assert run_stats.get("success") == 2
assert run_stats.get("failure") == 0
assert run_stats.get("canceled") == 1

Expand Down

1 comment on commit 553d74a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-gbv85iodx-elementl.vercel.app

Built with commit 553d74a.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.