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

update ExperimentTableRow logic to render dropdown items correctly, use StorageStateKF instead of location'
  • Loading branch information
jenny-s51 committed May 29, 2024
1 parent 4fe93f0 commit 72f359d
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 12 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,23 @@ 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;

const RestoreDropdownItem = (
<DropdownItem
isDisabled={!isExperimentActive}
key="restore-run"
onClick={() =>
run &&
api
.unarchivePipelineRun({}, run.run_id)
.catch((e) => notification.error('Unable to restore pipeline run', e.message))
}
>
Restore
</DropdownItem>
);

return (
<Dropdown
Expand All @@ -42,15 +61,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 +85,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,10 +108,33 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
) : (
<React.Fragment key="compare-runs" />
),
<DropdownSeparator key="separator" />,
<DropdownItem key="delete-run" onClick={() => onDelete()}>
Delete
</DropdownItem>,
!isRunActive ? (
!isExperimentActive ? (
<Tooltip
position="left"
content={
<div>
Archived runs cannot be restored until its associated experiment is
restored.
</div>
}
>
{RestoreDropdownItem}
</Tooltip>
) : (
RestoreDropdownItem
)
) : (
<React.Fragment key="restore-run" />
),
!isRunActive ? (
<React.Fragment key="delete-run">
<DropdownSeparator key="separator" />
<DropdownItem onClick={() => onDelete()}>Delete</DropdownItem>
</React.Fragment>
) : (
<React.Fragment key="delete-run" />
),
]
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Link } from 'react-router-dom';

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

import { ExperimentKFv2 } from '~/concepts/pipelines/kfTypes';
import { ExperimentKFv2, StorageStateKF } from '~/concepts/pipelines/kfTypes';
import { CheckboxTd } from '~/components/table';
import { experimentRunsRoute } from '~/routes';
import { usePipelinesAPI } from '~/concepts/pipelines/context';
Expand All @@ -24,11 +24,18 @@ const ExperimentTableRow: React.FC<ExperimentTableRowProps> = ({
}) => {
const { namespace } = usePipelinesAPI();

const isArchived = experiment.storage_state === StorageStateKF.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 72f359d

Please sign in to comment.