Skip to content

Commit

Permalink
[#429] use is_reproduce flg depending on button type
Browse files Browse the repository at this point in the history
  • Loading branch information
ReiHashimoto committed Apr 17, 2023
1 parent 841c0a2 commit 23bd16f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
13 changes: 9 additions & 4 deletions frontend/src/api/run/Run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@ export type OutputPathsDTO = {
export async function runResult(data: {
uid: string
pendingNodeIdList: string[]
isReproduce?: boolean
}): Promise<RunResultDTO> {
const { uid, pendingNodeIdList } = data
const response = await axios.post(`${BASE_URL}/run/result/${uid}`, {
pendingNodeIdList,
})
const { uid, pendingNodeIdList, isReproduce } = data
const response = await axios.post(
`${BASE_URL}/run/result/${uid}`,
{
pendingNodeIdList,
},
{ params: { is_reproduce: isReproduce ?? false } },
)
return response.data
}
30 changes: 19 additions & 11 deletions frontend/src/store/slice/Pipeline/PipelineActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,24 @@ export const pollRunResult = createAsyncThunk<
RunResultDTO,
{
uid: string
isReproduce?: boolean
},
ThunkApiConfig
>(`${PIPELINE_SLICE_NAME}/pollRunResult`, async ({ uid }, thunkAPI) => {
const pendingNodeIdList = selectRunResultPendingNodeIdList(
thunkAPI.getState(),
)
try {
const responseData = await runResult({ uid, pendingNodeIdList })
return responseData
} catch (e) {
return thunkAPI.rejectWithValue(e)
}
})
>(
`${PIPELINE_SLICE_NAME}/pollRunResult`,
async ({ uid, isReproduce }, thunkAPI) => {
const pendingNodeIdList = selectRunResultPendingNodeIdList(
thunkAPI.getState(),
)
try {
const responseData = await runResult({
uid,
pendingNodeIdList,
isReproduce,
})
return responseData
} catch (e) {
return thunkAPI.rejectWithValue(e)
}
},
)
13 changes: 10 additions & 3 deletions frontend/src/store/slice/Pipeline/PipelineHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import {
selectPipelineIsCanceled,
selectPipelineIsStartedSuccess,
selectPipelineLatestUid,
selectPipelineRunBtn,
selectPipelineStatus,
} from './PipelineSelectors'
import { run, pollRunResult, runByCurrentUid } from './PipelineActions'
import { cancelPipeline } from './PipelineSlice'
import { selectFilePathIsUndefined } from '../InputNode/InputNodeSelectors'
import { selectAlgorithmNodeNotExist } from '../AlgorithmNode/AlgorithmNodeSelectors'
import { useSnackbar } from 'notistack'
import { RUN_STATUS } from './PipelineType'
import { RUN_BTN_OPTIONS, RUN_STATUS } from './PipelineType'

const POLLING_INTERVAL = 5000

Expand All @@ -27,6 +28,7 @@ export function useRunPipeline() {
const filePathIsUndefined = useSelector(selectFilePathIsUndefined)
const algorithmNodeNotExist = useSelector(selectAlgorithmNodeNotExist)
const runPostData = useSelector(selectRunPostData)
const runButton = useSelector(selectPipelineRunBtn)
const handleRunPipeline = React.useCallback(
(name: string) => {
dispatch(run({ runPostData: { name, ...runPostData, forceRunList: [] } }))
Expand All @@ -44,13 +46,18 @@ export function useRunPipeline() {
React.useEffect(() => {
const intervalId = setInterval(() => {
if (isStartedSuccess && !isCanceled && uid != null) {
dispatch(pollRunResult({ uid: uid }))
dispatch(
pollRunResult({
uid: uid,
isReproduce: runButton === RUN_BTN_OPTIONS.RUN_ALREADY,
}),
)
}
}, POLLING_INTERVAL)
return () => {
clearInterval(intervalId)
}
}, [dispatch, uid, isCanceled, isStartedSuccess])
}, [dispatch, uid, isCanceled, isStartedSuccess, runButton])
const status = useSelector(selectPipelineStatus)
const { enqueueSnackbar } = useSnackbar()
// タブ移動による再レンダリングするたびにスナックバーが実行されてしまう挙動を回避するために前回の値を保持
Expand Down

0 comments on commit 23bd16f

Please sign in to comment.