@@ -5,14 +5,15 @@ import { startModelInference, stopModelInference } from '../utils/api'
55import Configurator from '../components/Configurator'
66import { AppContext } from '../contexts/GlobalContext'
77
8- function ModelInference ( ) {
8+ function ModelInference ( { isInferring , setIsInferring } ) {
99 const context = useContext ( AppContext )
10- const [ isInference , setIsInference ] = useState ( false )
10+ // const [isInference, setIsInference] = useState(false)
1111 const handleStartButton = async ( ) => {
1212 try {
1313 const inferenceConfig = localStorage . getItem ( 'inferenceConfig' )
1414
15- const res = startModelInference (
15+ // const res = startModelInference(
16+ const res = await startModelInference (
1617 context . uploadedYamlFile . name ,
1718 inferenceConfig ,
1819 context . outputPath ,
@@ -22,17 +23,19 @@ function ModelInference () {
2223 } catch ( e ) {
2324 console . log ( e )
2425 } finally {
25- setIsInference ( true )
26+ // setIsInference(true)
27+ setIsInferring ( true )
2628 }
2729 }
2830
2931 const handleStopButton = async ( ) => {
3032 try {
31- stopModelInference ( )
33+ await stopModelInference ( )
3234 } catch ( e ) {
3335 console . log ( e )
3436 } finally {
35- setIsInference ( false )
37+ // setIsInference(false)
38+ setIsInferring ( false )
3639 }
3740 }
3841
@@ -49,13 +52,13 @@ function ModelInference () {
4952 < Space wrap style = { { marginTop : 12 } } size = { componentSize } >
5053 < Button
5154 onClick = { handleStartButton }
52- disabled = { isInference } // Disables the button when inference is running
55+ disabled = { isInferring } // Disables the button when inference is running
5356 >
5457 Start Inference
5558 </ Button >
5659 < Button
5760 onClick = { handleStopButton }
58- disabled = { ! isInference } // Disables the button when inference is not running
61+ disabled = { ! isInferring } // Disables the button when inference is not running
5962 >
6063 Stop Inference
6164 </ Button >
0 commit comments