diff --git a/client/src/views/ModelInference.js b/client/src/views/ModelInference.js index 0c0e497..13386af 100644 --- a/client/src/views/ModelInference.js +++ b/client/src/views/ModelInference.js @@ -5,14 +5,15 @@ import { startModelInference, stopModelInference } from '../utils/api' import Configurator from '../components/Configurator' import { AppContext } from '../contexts/GlobalContext' -function ModelInference () { +function ModelInference ({ isInferring, setIsInferring }) { const context = useContext(AppContext) - const [isInference, setIsInference] = useState(false) + // const [isInference, setIsInference] = useState(false) const handleStartButton = async () => { try { const inferenceConfig = localStorage.getItem('inferenceConfig') - const res = startModelInference( + // const res = startModelInference( + const res = await startModelInference( context.uploadedYamlFile.name, inferenceConfig, context.outputPath, @@ -22,17 +23,19 @@ function ModelInference () { } catch (e) { console.log(e) } finally { - setIsInference(true) + // setIsInference(true) + setIsInferring(true) } } const handleStopButton = async () => { try { - stopModelInference() + await stopModelInference() } catch (e) { console.log(e) } finally { - setIsInference(false) + // setIsInference(false) + setIsInferring(false) } } @@ -49,13 +52,13 @@ function ModelInference () { diff --git a/client/src/views/Views.js b/client/src/views/Views.js index 2ccb95d..e9f7279 100644 --- a/client/src/views/Views.js +++ b/client/src/views/Views.js @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useState, useEffect } from 'react' import DataLoader from './DataLoader' import Visualization from '../views/Visualization' import ModelTraining from '../views/ModelTraining' @@ -13,6 +13,7 @@ function Views () { const [current, setCurrent] = useState('visualization') const [viewers, setViewers] = useState([]) const [isLoading, setIsLoading] = useState(false) + const [isInferring, setIsInferring] = useState(false) console.log(viewers) const onClick = (e) => { @@ -34,7 +35,7 @@ function Views () { } else if (current === 'monitoring') { return } else if (current === 'inference') { - return + return } } @@ -80,6 +81,12 @@ function Views () { } } + useEffect(() => { // This function makes sure that the inferring will continue when current tab changes + if (current === 'inference' && isInferring) { + console.log('Inference process is continuing...') + } + }, [current, isInferring]) + return (