Skip to content

Commit

Permalink
add retryPipelineRunLogic, wip
Browse files Browse the repository at this point in the history
add archived labels and additional dropdown items

format, update tests
  • Loading branch information
jenny-s51 committed May 21, 2024
1 parent cd93b29 commit 47bb48a
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,13 @@ describe('Pipeline topology', () => {

it('Test pipeline run duplicate navigation', () => {
pipelineRunDetails.visit(projectId, mockRun.run_id);
pipelineRunDetails.selectActionDropdownItem('Duplicate');
pipelineRunDetails.selectActionDropdownItem('Clone');
verifyRelativeURL(`/pipelineRuns/${projectId}/pipelineRun/clone/${mockRun.run_id}`);
});

it('Test pipeline job duplicate navigation', () => {
pipelineRunJobDetails.visit(projectId, mockJob.recurring_run_id);
pipelineRunJobDetails.selectActionDropdownItem('Duplicate');
pipelineRunJobDetails.selectActionDropdownItem('Clone');
verifyRelativeURL(
`/pipelineRuns/${projectId}/pipelineRun/cloneJob/${mockJob.recurring_run_id}?runType=scheduled`,
);
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/api/pipelines/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ export const stopPipelineRun: UpdatePipelineRunAPI = (hostPath) => (opts, runId)
proxyENDPOINT(hostPath, `/apis/v2beta1/runs/${runId}:terminate`, {}, opts),
);

export const retryPipelineRun: UpdatePipelineRunAPI = (hostPath) => (opts, runId) =>
handlePipelineFailures(proxyENDPOINT(hostPath, `/apis/v2beta1/runs/${runId}:retry`, {}, opts));

export const updatePipelineRunJob: UpdatePipelineRunJobAPI = (hostPath) => (opts, jobId, enabled) =>
handlePipelineFailures(
proxyENDPOINT(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Label, Split, SplitItem } from '@patternfly/react-core';
import { PipelineRunKFv2 } from '~/concepts/pipelines/kfTypes';
import { computeRunStatus } from '~/concepts/pipelines/content/utils';
import { computeRunStatus, getStorageState } from '~/concepts/pipelines/content/utils';
import PipelineRunTypeLabel from '~/concepts/pipelines/content/PipelineRunTypeLabel';

type RunJobTitleProps = {
Expand All @@ -17,6 +17,8 @@ const PipelineDetailsTitle: React.FC<RunJobTitleProps> = ({
}) => {
const { icon, label } = computeRunStatus(run);

const isArchived = getStorageState(run) === 'ARCHIVED';

return (
<>
<Split hasGutter>
Expand All @@ -31,6 +33,11 @@ const PipelineDetailsTitle: React.FC<RunJobTitleProps> = ({
<Label icon={icon}>{label}</Label>
</SplitItem>
)}
{isArchived && (
<SplitItem>
<Label>Archived</Label>
</SplitItem>
)}
</Split>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
? []
: [
<DropdownItem
key="stop-run"
isDisabled={run.state !== RuntimeStateKF.RUNNING}
key="retry-run"
isDisabled={run.state !== RuntimeStateKF.FAILED || !!run.error}
onClick={() =>
api
.stopPipelineRun({}, run.run_id)
.catch((e) => notification.error('Unable to stop pipeline run', e.message))
.retryPipelineRun({}, run.run_id)
.catch((e) => notification.error('Unable to retry pipeline run', e.message))
}
>
Stop
Retry
</DropdownItem>,
<DropdownItem
key="clone-run"
Expand All @@ -64,7 +64,18 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
)
}
>
Duplicate
Clone
</DropdownItem>,
<DropdownItem
key="stop-run"
isDisabled={run.state !== RuntimeStateKF.RUNNING}
onClick={() =>
api
.stopPipelineRun({}, run.run_id)
.catch((e) => notification.error('Unable to stop pipeline run', e.message))
}
>
Stop
</DropdownItem>,
isExperimentsAvailable && experimentId && isRunActive ? (
<DropdownItem
Expand All @@ -78,6 +89,20 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
) : (
<React.Fragment key="compare-runs" />
),
!isRunActive ? (
<DropdownItem
key="restore-run"
onClick={() =>
api
.unarchivePipelineRun({}, run.run_id)
.catch((e) => notification.error('Unable to restore pipeline run', e.message))
}
>
Restore
</DropdownItem>
) : (
<React.Fragment key="restore-run" />
),
<DropdownSeparator key="separator" />,
<DropdownItem key="delete-run" onClick={() => onDelete()}>
Delete
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/concepts/pipelines/content/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
PipelineRunKFv2,
PipelineVersionKFv2,
RuntimeStateKF,
StorageStateKF,
runtimeStateLabels,
} from '~/concepts/pipelines/kfTypes';
import { relativeTime } from '~/utilities/time';
Expand All @@ -30,6 +31,9 @@ export type RunStatusDetails = {
const UNKNOWN_ICON = <QuestionCircleIcon />;
const UNKNOWN_STATUS = 'warning';

export const getStorageState = (run?: PipelineRunKFv2 | null): StorageStateKF | undefined =>
run?.storage_state;

export const computeRunStatus = (run?: PipelineRunKFv2 | null): RunStatusDetails => {
if (!run) {
return { icon: UNKNOWN_ICON, status: UNKNOWN_STATUS, label: '-' };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
archiveExperiment,
unarchiveExperiment,
deleteExperiment,
retryPipelineRun,
} from '~/api';
import { PipelineAPIs } from '~/concepts/pipelines/types';
import { APIState } from '~/concepts/proxy/types';
Expand Down Expand Up @@ -66,6 +67,7 @@ const usePipelineAPIState = (
listPipelineVersions: listPipelineVersions(path),
archivePipelineRun: archivePipelineRun(path),
unarchivePipelineRun: unarchivePipelineRun(path),
retryPipelineRun: retryPipelineRun(path),
archiveExperiment: archiveExperiment(path),
unarchiveExperiment: unarchiveExperiment(path),
stopPipelineRun: stopPipelineRun(path),
Expand Down
1 change: 1 addition & 0 deletions frontend/src/concepts/pipelines/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export type PipelineAPIs = {
listPipelineRunJobs: ListPipelineRunJobs;
listPipelineVersions: ListPipelineVersions;
archivePipelineRun: UpdatePipelineRun;
retryPipelineRun: UpdatePipelineRun;
unarchivePipelineRun: UpdatePipelineRun;
archiveExperiment: UpdateExperiment;
unarchiveExperiment: UpdateExperiment;
Expand Down

0 comments on commit 47bb48a

Please sign in to comment.