Skip to content

fix: flow-run-graph-attempt-filter#22388

Open
hemantmm wants to merge 5 commits into
PrefectHQ:mainfrom
hemantmm:flow-run-graph-attempt-filter
Open

fix: flow-run-graph-attempt-filter#22388
hemantmm wants to merge 5 commits into
PrefectHQ:mainfrom
hemantmm:flow-run-graph-attempt-filter

Conversation

@hemantmm

Copy link
Copy Markdown
Contributor

closes: #22220

Added a flow run attempt dropdown to the flow run graph so that it can be retried, runs can be viewed one attempt at a time, using the task run flow_run_run_count to filter nodes and rescale the graph timeline.

@hemantmm
hemantmm marked this pull request as draft June 26, 2026 13:35
@github-actions github-actions Bot added the enhancement An improvement of an existing feature label Jun 26, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70d74b7430

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

...data,
root_node_ids: rootNodeIds,
start_time: startTime,
end_time: endTime,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve null end_time for active retried runs

When a flow run is still active but the selected attempt currently has only terminal or pending nodes (for example during an awaiting-retry delay after attempt 1 failed and before attempt 2 starts), getRunTimeRange returns a finite endTime and this overwrites the API's null graph end_time. The polling loop in ui-v2/src/graphs/factories/data.ts only refetches when returned data.end_time is null, so the graph stops polling and never shows later retry attempts. Keep the original null end time for active flow runs, or otherwise keep signaling that polling should continue, while still using the filtered range for rendering.

Useful? React with 👍 / 👎.

Signed-off-by: Hemant M Mehta <hemant29mehta@gmail.com>
@codspeed-hq

codspeed-hq Bot commented Jun 26, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 8 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing hemantmm:flow-run-graph-attempt-filter (ddc0846) with main (b75c060)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@hemantmm
hemantmm marked this pull request as ready for review July 7, 2026 13:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d75503823

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

const nodes = new Map<string, RunGraphNode>();

for (const [nodeId, node] of data.nodes) {
if (node.flow_run_run_count === runCount) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep pending downstream nodes in attempt filters

When a task never reaches RUNNING because an upstream failed, its flow_run_run_count stays at the DB/default value 0 (the task engine and UpdateFlowRunTrackerOnTasks only populate it when entering RUNNING). This strict equality check means those NotReady/PENDING downstream placeholders are classified as a bogus Run 0 and are omitted when the user filters to the actual parent flow attempt, so retried graphs lose pending downstream nodes. Normalize the attempt count for non-running task runs before filtering or avoid treating 0 as a separate selectable attempt.

Useful? React with 👍 / 👎.

theme: resolvedTheme === "dark" ? "dark" : "light",
}),
[flowRunId, resolvedTheme],
[fetchGraph, flowRunId, resolvedTheme],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid restarting the graph on attempt changes

Including fetchGraph here makes config change whenever selectedAttemptRunCount changes, so selecting a different attempt tears the graph down via the [config] start effect. stop() calls emitter.clear(), but the React effect that registers itemSelected/viewportDateRangeUpdated listeners does not rerun for an attempt-only change, leaving the wrapper unsubscribed; after switching attempts, node clicks no longer open the selection panel and viewport callbacks stop firing. Keep the graph instance mounted for filter changes or make the emitter subscriptions re-register after this restart.

Useful? React with 👍 / 👎.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I noticed a potential issue with filterRunGraphDataByFlowRunAttempt / getRunTimeRange in ui-v2/src/components/flow-runs/flow-run-graph/utilities.ts.

getRunTimeRange only returns endTime: null when the filtered set contains a node that is currently RUNNING (or a flow-run with no end_time). If a user selects an older attempt while the overall flow run is still active (e.g., during a retry delay or while a newer attempt is running), the filtered attempt can contain only terminal/pending nodes and getRunTimeRange will return a finite endTime. dataFactory in ui-v2/src/graphs/factories/data.ts only continues polling when !data.end_time, so the graph may stop polling and miss newer retries.

Consider preserving the original data.end_time when it is null (i.e., the flow run is still active) while still using the filtered range for rendering.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Two small cleanup items:

  • ui-v2/src/components/flow-runs/flow-run-graph/api.ts has /* eslint-disable @typescript-eslint/no-unsafe-assignment */ at the top, but ESLint reports it as an unused directive. It can be removed.
  • npm run service-sync regenerates ui-v2/src/api/prefect.ts and adds a @default 0 doc comment for flow_run_run_count, so the generated API client is slightly out of sync with the current backend schema.

@desertaxle desertaxle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@hemantmm the review comments posted by Devin and Codex will need to be addressed before this PR can be merged.

hemantmm and others added 3 commits July 10, 2026 10:22
Signed-off-by: Hemant M Mehta <hemant29mehta@gmail.com>
Signed-off-by: Hemant M Mehta <hemant29mehta@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add flow run attempt filter to the flow run graph to isolate tasks by run count

2 participants