Skip to content
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

[dy] Expire certain pipeline runs #4727

Merged
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion mage_ai/api/resources/PipelineRunResource.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ScheduleStatus,
ScheduleType,
)
from mage_ai.orchestration.db import safe_db_query
from mage_ai.orchestration.db import db_connection, safe_db_query
from mage_ai.orchestration.db.models.schedules import (
BlockRun,
PipelineRun,
Expand Down Expand Up @@ -241,6 +241,15 @@ async def process_collection(self, query_arg, meta, user, **kwargs):
has_next = results_size > limit
final_end_idx = results_size - 1 if has_next else results_size

# Expire pipeline runs that are in progress so that the latest status is returned
# the next time they are fetched.
for run in results:
if run.status in (
PipelineRun.PipelineRunStatus.RUNNING,
PipelineRun.PipelineRunStatus.INITIAL,
):
db_connection.session.expire(run)

result_set = self.build_result_set(
results[0:final_end_idx],
user,
Expand Down
10 changes: 6 additions & 4 deletions mage_ai/frontend/components/Triggers/Detail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ function TriggerDetail({
mutate: fetchPipelineRuns,
} = api.pipeline_runs.pipeline_schedules.list(
pipelineScheduleID,
pipelineRunsRequestQuery, {
refreshInterval: 3000,
revalidateOnFocus: true,
});
pipelineRunsRequestQuery,
{
refreshInterval: 3000,
revalidateOnFocus: true,
},
);
const pipelineRuns = useMemo(() => dataPipelineRuns?.pipeline_runs || [], [dataPipelineRuns]);
const totalRuns = useMemo(() => dataPipelineRuns?.metadata?.count || [], [dataPipelineRuns]);

Expand Down
Loading