Skip to content

Commit

Permalink
[RHOAIENG-4999] Details page for archived runs
Browse files Browse the repository at this point in the history
add archived labels and additional dropdown items

format, update tests

update test

update instances of Duplicate to Clone

fix lint

PR feedback: reverts Clone, disables restore on archived run, fixes route from archived experiment

PR feedback: fix route, remove helper functions

fix tests
  • Loading branch information
jenny-s51 committed May 23, 2024
1 parent 26d1116 commit 66d3c85
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 8 deletions.
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,6 +1,6 @@
import React from 'react';
import { Label, Split, SplitItem } from '@patternfly/react-core';
import { PipelineRunKFv2 } from '~/concepts/pipelines/kfTypes';
import { PipelineRunKFv2, StorageStateKF } from '~/concepts/pipelines/kfTypes';
import { computeRunStatus } from '~/concepts/pipelines/content/utils';
import PipelineRunTypeLabel from '~/concepts/pipelines/content/PipelineRunTypeLabel';

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

const isArchived = run.storage_state === StorageStateKF.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
@@ -1,4 +1,5 @@
import * as React from 'react';
import { Tooltip } from '@patternfly/react-core';
import {
Dropdown,
DropdownItem,
Expand All @@ -11,6 +12,7 @@ import useNotification from '~/utilities/useNotification';
import { PipelineRunKFv2, RuntimeStateKF, StorageStateKF } from '~/concepts/pipelines/kfTypes';
import { cloneRunRoute, experimentsCompareRunsRoute } from '~/routes';
import { SupportedArea, useIsAreaAvailable } from '~/concepts/areas';
import useExperimentById from '~/concepts/pipelines/apiHooks/useExperimentById';

type PipelineRunDetailsActionsProps = {
run?: PipelineRunKFv2 | null;
Expand All @@ -25,6 +27,8 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
const [open, setOpen] = React.useState(false);
const isExperimentsAvailable = useIsAreaAvailable(SupportedArea.PIPELINE_EXPERIMENTS).status;
const isRunActive = run?.storage_state === StorageStateKF.AVAILABLE;
const [experiment] = useExperimentById(experimentId);
const isExperimentActive = experiment?.storage_state === StorageStateKF.AVAILABLE;

return (
<Dropdown
Expand All @@ -42,15 +46,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 @@ -66,6 +70,17 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
>
Duplicate
</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
key="compare-runs"
Expand All @@ -78,6 +93,32 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
) : (
<React.Fragment key="compare-runs" />
),
!isExperimentActive ? (
<Tooltip
position="left"
content={
<div>
Archived runs cannot be restored until its associated experiment is restored.
</div>
}
>
<DropdownItem
isDisabled={!isExperimentActive}
key="restore-run"
onClick={() =>
api
.unarchivePipelineRun({}, run.run_id)
.catch((e) =>
notification.error('Unable to restore pipeline run', e.message),
)
}
>
Restore
</DropdownItem>
</Tooltip>
) : (
<React.Fragment key="restore-run" />
),
<DropdownSeparator key="separator" />,
<DropdownItem key="delete-run" onClick={() => onDelete()}>
Delete
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Link, useLocation } from 'react-router-dom';

import { ActionsColumn, IAction, Td, Tr } from '@patternfly/react-table';

Expand All @@ -23,12 +23,20 @@ const ExperimentTableRow: React.FC<ExperimentTableRowProps> = ({
actionColumnItems,
}) => {
const { namespace } = usePipelinesAPI();
const location = useLocation();

const isArchived = location.pathname.includes('/archived');

return (
<Tr>
<CheckboxTd id={experiment.experiment_id} isChecked={isChecked} onToggle={onToggleCheck} />
<Td dataLabel="Experiment">
<Link to={experimentRunsRoute(namespace, experiment.experiment_id)} state={{ experiment }}>
<Link
to={`${experimentRunsRoute(namespace, experiment.experiment_id)}${
isArchived ? '/?runType=archived' : ''
}`}
state={{ experiment }}
>
{experiment.display_name}
</Link>
</Td>
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 66d3c85

Please sign in to comment.