Skip to content

Commit

Permalink
Merge pull request #358 from kube-HPC/HKUBE-1909-stop-of-all-jobs
Browse files Browse the repository at this point in the history
invoke stop of all jobs of a certain pipeline
  • Loading branch information
zivglik authored Mar 18, 2024
2 parents 52dc92f + 4946fa3 commit 993fe0b
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/Routes/Tables/Pipelines/PipelineActions.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import {
EditOutlined,
InfoCircleOutlined,
PlayCircleOutlined,
StopOutlined,
} from '@ant-design/icons';
import { Button, Empty, Popover, Tooltip } from 'antd';

import { USER_GUIDE } from 'const';
import { useActions } from 'hooks';
import isEqual from 'lodash/isEqual';
import { deleteConfirmAction } from 'utils';
import { deleteConfirmAction, stopConfirmAction } from 'utils';
import PipelineCreateBoard from './TensorflowBoards/PipelineCreateBoard.react';
import usePath from './usePath';

Expand All @@ -23,7 +24,7 @@ const title = 'Create Tensor Board for selected Node';

const PipelineActions = ({ pipeline, className }) => {
const { goTo } = usePath();
const { deleteStored: remove } = useActions();
const { deleteStored: remove, stopAllPipeline } = useActions();

const container = useRef();

Expand All @@ -38,6 +39,11 @@ const PipelineActions = ({ pipeline, className }) => {
remove,
]);

const onStop = useCallback(
() => stopConfirmAction(stopAllPipeline, pipeline),
[pipeline, stopAllPipeline]
);

const setPopupContainer = useCallback(() => container.current, [container]);

const onUpdate = useCallback(() => {
Expand Down Expand Up @@ -90,6 +96,9 @@ const PipelineActions = ({ pipeline, className }) => {
<Tooltip title="delete pipeline">
<Button icon={<DeleteOutlined />} onClick={onDelete} />
</Tooltip>
<Tooltip title="stop all jobs of pipeline">
<Button icon={<StopOutlined />} onClick={onStop} />
</Tooltip>
<Tooltip title="show overview">
<Button icon={<InfoCircleOutlined />} onClick={onEdit} />
</Tooltip>
Expand Down
2 changes: 2 additions & 0 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
pausePipeline,
resumePipeline,
stopPipeline,
stopAllPipeline,
updateStored,
} from './pipeline.action';
import { setSettings } from './settings.action';
Expand Down Expand Up @@ -78,6 +79,7 @@ const actions = {
socketInit,
startBoard,
stopPipeline,
stopAllPipeline,
toggleViewType,
setExperimentLoading,
triggerUserGuide,
Expand Down
13 changes: 13 additions & 0 deletions src/actions/pipeline.action.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ export const addPipeline = pipeline => ({
},
});

export const stopAllPipeline = (pipelineName, { onSuccess }) => ({
type: actions.REST_REQ_POST,
payload: {
url: `exec/stop`,
body: {
pipelineName,
reason: `Request from simulator, Algorithms-tab Delete action`,
},
actionType: actions.PIPELINE_STOP,
},
meta: { pipelineName, onSuccess },
});

export const stopPipeline = jobId => ({
type: actions.REST_REQ_POST,
payload: {
Expand Down
1 change: 1 addition & 0 deletions src/config/schema/success-messages.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Text from 'antd/lib/typography/Text';
import React from 'react';

const successMsg = payload => ({
ALL_PIPELINE_JOBS_STOP: `${payload.name}'s Jobs have been stopped`,
ALGORITHM_APPLY: 'Algorithm Applied, check Algorithms table',
ALGORITHM_RUN: (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/styles/themes/CommonColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const COMMON_COLOR = () => {
[PIPELINE.COMPLETED]: COLOR.greenLight,
[PIPELINE.CRASHED]: COLOR.redPale,
[PIPELINE.FAILED]: COLOR.red,
[PIPELINE.PENDING]: COLOR.white,
[PIPELINE.PENDING]: COLOR.grey,
[PIPELINE.RESUMED]: COLOR.blueLight,
[PIPELINE.RUNNING]: COLOR.blue,
[PIPELINE.STALLED]: COLOR.darkGrey,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export {
setLsItem,
} from './localStorage';
export { default as mapObjValues } from './mapObjValues';
export { deleteConfirmAction } from './modal';
export { deleteConfirmAction, stopConfirmAction } from './modal';
export { default as notification, copyToClipboard } from './notification';
export { default as selector } from './selector';
export {
Expand Down
25 changes: 24 additions & 1 deletion src/utils/modal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Modal } from 'antd';
import { Modal, message } from 'antd';
import successMsg from 'config/schema/success-messages.schema';
import Text from 'antd/lib/typography/Text';
import React from 'react';

Expand All @@ -19,3 +20,25 @@ export const deleteConfirmAction = (action, { name }) => {
},
});
};

export const stopConfirmAction = (action, { name }) => {
Modal.confirm({
title: 'WARNING stop all jobs',
content: (
<>
Are you sure you want to stop all jobs of pipeline{' '}
<Text strong>{name}</Text>?
</>
),
okText: 'Confirm',
okType: 'danger',
cancelText: 'Cancel',
onOk() {
action(name, {
onSuccess: () => {
message.success(successMsg({ name }).ALL_PIPELINE_JOBS_STOP);
},
});
},
});
};

0 comments on commit 993fe0b

Please sign in to comment.