Skip to content

Commit 07c7e0c

Browse files
committed
Fix [Batch run] rename method to handler
1 parent 2f6fc03 commit 07c7e0c

File tree

6 files changed

+70
-70
lines changed

6 files changed

+70
-70
lines changed

src/components/JobWizard/JobWizard.util.js

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const generateJobWizardData = (
108108
const functions = selectedFunctionData.functions
109109
const functionInfo = getFunctionInfo(selectedFunctionData)
110110
const defaultResources = frontendSpec?.default_function_pod_resources ?? {}
111-
const functionParameters = getFunctionParameters(functions, functionInfo.method)
111+
const functionParameters = getFunctionParameters(functions, functionInfo.handler)
112112
const [functionPriorityClassName] = getFunctionPriorityClass(functions)
113113
const [limits] = getLimits(functions)
114114
const [requests] = getRequests(functions)
@@ -123,7 +123,7 @@ export const generateJobWizardData = (
123123
? getDefaultSchedule(defaultData.schedule)
124124
: scheduleDataInitialState
125125
const jobAdditionalData = {
126-
methodOptions: functionInfo.methodOptions,
126+
handlerOptions: functionInfo.handlerOptions,
127127
versionOptions: functionInfo.versionOptions
128128
}
129129
const currentLimits = parseLimits(limits, defaultResources.limits, gpuType)
@@ -133,8 +133,8 @@ export const generateJobWizardData = (
133133
[RUN_DETAILS_STEP]: {
134134
name: functionInfo.name,
135135
version: functionInfo.version,
136-
method: functionInfo.method,
137-
methodData: functionInfo.methodData,
136+
handler: functionInfo.handler,
137+
handlerData: functionInfo.handlerData,
138138
labels: [],
139139
image: parseImageData(functionInfo.function, frontendSpec, currentProjectName)
140140
},
@@ -209,7 +209,7 @@ export const generateJobWizardDefaultData = (
209209
if (isEmpty(defaultData)) return [{}, {}]
210210

211211
const runInfo = getRunDefaultInfo(defaultData, selectedFunctionData)
212-
const functionParameters = getFunctionDefaultParameters(selectedFunctionData, runInfo.method)
212+
const functionParameters = getFunctionDefaultParameters(selectedFunctionData, runInfo.handler)
213213
const [predefinedParameters, customParameters] = parseDefaultParameters(
214214
functionParameters,
215215
defaultData.task.spec.parameters,
@@ -223,7 +223,7 @@ export const generateJobWizardDefaultData = (
223223
const requests = defaultData.function.spec?.resources?.requests
224224
const gpuType = getLimitsGpuType(limits)
225225
const jobAdditionalData = {
226-
methodOptions: runInfo.methodOptions,
226+
handlerOptions: runInfo.handlerOptions,
227227
versionOptions: runInfo.versionOptions
228228
}
229229
const currentLimits = parseLimits(limits, defaultResources.limits, gpuType)
@@ -236,8 +236,8 @@ export const generateJobWizardDefaultData = (
236236
[RUN_DETAILS_STEP]: {
237237
name: runInfo.name,
238238
version: runInfo.version,
239-
method: runInfo.method,
240-
methodData: runInfo.methodData,
239+
handler: runInfo.handler,
240+
handlerData: runInfo.handlerData,
241241
labels: runInfo.labels,
242242
image: parseImageData(selectedFunctionData, frontendSpec, currentProjectName)
243243
},
@@ -297,16 +297,16 @@ export const generateJobWizardDefaultData = (
297297
return [jobFormData, jobAdditionalData]
298298
}
299299

300-
export const getMethodData = (selectedFunctionData, method) => {
300+
export const getHandlerData = (selectedFunctionData, handler) => {
301301
const currentFunction = selectedFunctionData?.functions
302302
? chain(selectedFunctionData.functions).orderBy('metadata.updated', 'desc').get(0).value()
303303
: selectedFunctionData
304-
const methodData = get(currentFunction, ['spec', 'entry_points', method], {})
305-
const outputs = (methodData?.outputs ?? []).filter(output => !isEveryObjectValueEmpty(output))
304+
const handlerData = get(currentFunction, ['spec', 'entry_points', handler], {})
305+
const outputs = (handlerData?.outputs ?? []).filter(output => !isEveryObjectValueEmpty(output))
306306

307307
return {
308-
doc: methodData?.doc,
309-
has_kwargs: methodData?.has_kwargs || false,
308+
doc: handlerData?.doc,
309+
has_kwargs: handlerData?.has_kwargs || false,
310310
outputs
311311
}
312312
}
@@ -316,10 +316,10 @@ const getFunctionInfo = selectedFunctionData => {
316316

317317
if (!isEmpty(functions)) {
318318
const versionOptions = getVersionOptions(functions)
319-
const methodOptions = getMethodOptions(functions)
320-
const { defaultVersion, defaultMethod } = getDefaultMethodAndVersion(
319+
const handlerOptions = getHandlerOptions(functions)
320+
const { defaultVersion, defaultHandler } = getDefaultHandlerAndVersion(
321321
versionOptions,
322-
methodOptions,
322+
handlerOptions,
323323
functions
324324
)
325325
const currentFunctionVersion = selectedFunctionData.tag || defaultVersion
@@ -328,10 +328,10 @@ const getFunctionInfo = selectedFunctionData => {
328328

329329
return {
330330
name: selectedFunctionData.name,
331-
method: defaultMethod,
331+
handler: defaultHandler,
332332
version: currentFunctionVersion,
333-
methodData: getMethodData(currentFunction, defaultMethod),
334-
methodOptions,
333+
handlerData: getHandlerData(currentFunction, defaultHandler),
334+
handlerOptions,
335335
versionOptions,
336336
function: currentFunction || {}
337337
}
@@ -342,15 +342,15 @@ const getRunDefaultInfo = (defaultData, selectedFunctionData) => {
342342
return {
343343
labels: parseChipsData(defaultData.task?.metadata?.labels),
344344
name: defaultData.task?.metadata?.name || '',
345-
method: defaultData.task?.spec?.handler,
346-
methodData: getMethodData(selectedFunctionData, defaultData.task?.spec?.handler),
347-
methodOptions: [],
345+
handler: defaultData.task?.spec?.handler,
346+
handlerData: getHandlerData(selectedFunctionData, defaultData.task?.spec?.handler),
347+
handlerOptions: [],
348348
version: '',
349349
versionOptions: []
350350
}
351351
}
352352

353-
const getMethodOptions = selectedFunctions => {
353+
const getHandlerOptions = selectedFunctions => {
354354
return chain(selectedFunctions)
355355
.map(func => Object.values(func.spec?.entry_points ?? {}))
356356
.flatten()
@@ -377,47 +377,47 @@ const getVersionOptions = selectedFunctions => {
377377
return versionOptions.length ? versionOptions : [{ label: 'latest', id: TAG_LATEST }]
378378
}
379379

380-
const getDefaultMethod = (methodOptions, selectedFunctions) => {
381-
let method = ''
380+
const getDefaultHandler = (handlerOptions, selectedFunctions) => {
381+
let handler = ''
382382

383383
const latestFunction = selectedFunctions.find(item => item.metadata.tag === TAG_LATEST)
384384

385-
if (methodOptions.length) {
386-
method = methodOptions[0]?.id
385+
if (handlerOptions.length) {
386+
handler = handlerOptions[0]?.id
387387
} else if (latestFunction) {
388-
method = latestFunction.spec.default_handler || 'handler'
388+
handler = latestFunction.spec.default_handler || 'handler'
389389
} else {
390-
method = selectedFunctions[0]?.spec.default_handler || 'handler'
390+
handler = selectedFunctions[0]?.spec.default_handler || 'handler'
391391
}
392392

393-
return method
393+
return handler
394394
}
395395

396-
const getDefaultMethodAndVersion = (versionOptions, methodOptions, selectedFunctions) => {
396+
const getDefaultHandlerAndVersion = (versionOptions, handlerOptions, selectedFunctions) => {
397397
const defaultVersion =
398398
versionOptions.find(version => version.id === TAG_LATEST)?.id || versionOptions[0].id || ''
399399

400-
const defaultMethod = getDefaultMethod(methodOptions, selectedFunctions)
400+
const defaultHandler = getDefaultHandler(handlerOptions, selectedFunctions)
401401

402402
return {
403403
defaultVersion,
404-
defaultMethod
404+
defaultHandler
405405
}
406406
}
407407

408-
export const getFunctionParameters = (selectedFunction, method) => {
408+
export const getFunctionParameters = (selectedFunction, handler) => {
409409
return chain(selectedFunction)
410410
.orderBy('metadata.updated', 'desc')
411411
.map(func => {
412-
return func.spec.entry_points ? func.spec.entry_points[method]?.parameters ?? [] : []
412+
return func.spec.entry_points ? func.spec.entry_points[handler]?.parameters ?? [] : []
413413
})
414414
.flatten()
415415
.unionBy('name')
416416
.value()
417417
}
418418

419-
export const getFunctionDefaultParameters = (selectedFunction, method) => {
420-
const functionParameters = get(selectedFunction, `spec.entry_points[${method}].parameters`, [])
419+
export const getFunctionDefaultParameters = (selectedFunction, handler) => {
420+
const functionParameters = get(selectedFunction, `spec.entry_points[${handler}].parameters`, [])
421421

422422
return keyBy(functionParameters, 'name')
423423
}
@@ -1079,7 +1079,7 @@ export const generateJobRequestData = (
10791079
// secret_sources: formData[ADVANCED_STEP].secretSourcesTable.map(secretSource => {
10801080
// return { kind: secretSource.data.key, source: secretSource.data.value }
10811081
// }),
1082-
handler: formData[RUN_DETAILS_STEP].method ?? '',
1082+
handler: formData[RUN_DETAILS_STEP].handler ?? '',
10831083
input_path: formData[ADVANCED_STEP].inputPath ?? '',
10841084
output_path: formData[ADVANCED_STEP].outputPath,
10851085
function:

src/components/JobWizard/JobWizardSteps/JobWizardDataInputs/JobWizardDataInputs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const JobWizardDataInputs = ({ formState, stepIsActive }) => {
3535
exitEditModeTriggerItem={stepIsActive}
3636
fieldsPath={`${DATA_INPUTS_STEP}.dataInputsTable`}
3737
formState={formState}
38-
rowCanBeAdded={formState.values.runDetails.methodData?.has_kwargs}
38+
rowCanBeAdded={formState.values.runDetails.handlerData?.has_kwargs}
3939
/>
4040
</div>
4141
</div>

src/components/JobWizard/JobWizardSteps/JobWizardFunctionSelection/JobWizardFunctionSelection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { generateProjectsList } from '../../../../utils/projects'
4545
import { functionRunKinds } from '../../../Jobs/jobs.util'
4646
import { openConfirmPopUp } from 'igz-controls/utils/common.util'
4747
import {
48-
filterTrainFunctionMethods,
48+
filterTrainFunctionHandlers,
4949
FUNCTIONS_SELECTION_FUNCTIONS_TAB,
5050
FUNCTIONS_SELECTION_HUB_TAB,
5151
functionsSelectionTabs,
@@ -335,7 +335,7 @@ const JobWizardFunctionSelection = ({
335335
const functionTemplatePath = `${functionData.spec.item_uri}${functionData.spec.assets.function}`
336336

337337
dispatch(functionsActions.fetchFunctionTemplate(functionTemplatePath)).then(result => {
338-
const resultData = isTrain ? filterTrainFunctionMethods(result) : result
338+
const resultData = isTrain ? filterTrainFunctionHandlers(result) : result
339339

340340
setSelectedFunctionData(resultData)
341341
generateData(resultData)

src/components/JobWizard/JobWizardSteps/JobWizardFunctionSelection/jobWizardFunctionSelection.util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ export const generateFunctionTemplateCardData = templateData => {
6969
return functionTemplateCardData
7070
}
7171

72-
export const filterTrainFunctionMethods = result => {
73-
const allowedMethods = trainModelAllowedHubFunctions[result.name]
72+
export const filterTrainFunctionHandlers = result => {
73+
const allowedHandlers = trainModelAllowedHubFunctions[result.name]
7474
const { entry_points } = result.functions[0].spec
7575

7676
if (entry_points) {
7777
result.functions[0].spec.entry_points = Object.fromEntries(
78-
Object.entries(entry_points).filter(([key]) => allowedMethods.includes(key))
78+
Object.entries(entry_points).filter(([key]) => allowedHandlers.includes(key))
7979
)
8080
}
8181

src/components/JobWizard/JobWizardSteps/JobWizardParameters/JobWizardParameters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const JobWizardParameters = ({ formState, stepIsActive }) => {
7070
fieldsPath={`${PARAMETERS_STEP}.parametersTable`}
7171
formState={formState}
7272
parametersFromPath={parametersFromPath}
73-
rowCanBeAdded={formState.values.runDetails.methodData?.has_kwargs}
73+
rowCanBeAdded={formState.values.runDetails.handlerData?.has_kwargs}
7474
withHyperparameters={
7575
hyperParametersAreEnabled && selectedFromValue === PARAMETERS_FROM_UI_VALUE
7676
}

src/components/JobWizard/JobWizardSteps/JobWizardRunDetails/JobWizardRunDetails.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { getValidationRules } from 'igz-controls/utils/validation.util'
4747
import { openPopUp } from 'igz-controls/utils/common.util'
4848
import {
4949
getFunctionParameters,
50-
getMethodData,
50+
getHandlerData,
5151
parseDataInputs,
5252
parsePredefinedParameters
5353
} from '../../JobWizard.util'
@@ -63,10 +63,10 @@ const JobWizardRunDetails = ({
6363
selectedFunctionData,
6464
stepIsActive
6565
}) => {
66-
const methodPath = `${RUN_DETAILS_STEP}.method`
66+
const handlerPath = `${RUN_DETAILS_STEP}.handler`
6767
const imageSourcePath = `${RUN_DETAILS_STEP}.image.imageSource`
68-
const outputsPath = `${RUN_DETAILS_STEP}.methodData.outputs`
69-
const [spyOnMethodChange, setSpyOnMethodChange] = useState(true)
68+
const outputsPath = `${RUN_DETAILS_STEP}.handlerData.outputs`
69+
const [spyOnHandlerChange, setspyOnHandlerChange] = useState(true)
7070
const commonImageWarningMsg =
7171
'The image must include all the software packages that are required to run the function. ' +
7272
'For example, for an XGBoost model, ensure that the image includes the correct XGboost package and version'
@@ -79,32 +79,32 @@ const JobWizardRunDetails = ({
7979
[formState.values, imageSourcePath]
8080
)
8181

82-
const handleMethodChange = method => {
83-
setSpyOnMethodChange(true)
82+
const handleHandlerChange = handler => {
83+
setspyOnHandlerChange(true)
8484

85-
const functionParameters = getFunctionParameters(selectedFunctionData.functions, method)
85+
const functionParameters = getFunctionParameters(selectedFunctionData.functions, handler)
8686
const dataInputs = parseDataInputs(functionParameters, prePopulatedData.dataInputs)
8787
const predefinedParameters = parsePredefinedParameters(functionParameters)
88-
const methodData = getMethodData(selectedFunctionData, method)
88+
const handlerData = getHandlerData(selectedFunctionData, handler)
8989

9090
set(formState.initialValues, `${DATA_INPUTS_STEP}.dataInputsTable`, dataInputs)
9191
set(
9292
formState.initialValues,
9393
`${PARAMETERS_STEP}.parametersTable.predefined`,
9494
predefinedParameters
9595
)
96-
set(formState.initialValues, `${RUN_DETAILS_STEP}.methodData`, methodData)
96+
set(formState.initialValues, `${RUN_DETAILS_STEP}.handlerData`, handlerData)
9797
formState.form.change(`${DATA_INPUTS_STEP}.dataInputsTable`, dataInputs)
9898
formState.form.change(`${PARAMETERS_STEP}.parametersTable.predefined`, predefinedParameters)
99-
formState.form.change(`${RUN_DETAILS_STEP}.methodData`, methodData)
99+
formState.form.change(`${RUN_DETAILS_STEP}.handlerData`, handlerData)
100100
formState.form.change(
101101
`${PARAMETERS_STEP}.parametersTable.custom`,
102102
get(formState.initialValues, `${PARAMETERS_STEP}.parametersTable.custom`, [])
103103
)
104104
}
105105

106-
const onMethodChange = (value, prevValue) => {
107-
setSpyOnMethodChange(false)
106+
const onHandlerChange = (value, prevValue) => {
107+
setspyOnHandlerChange(false)
108108

109109
const dataInputsAreChanged = areFormValuesChanged(
110110
formState.initialValues[DATA_INPUTS_STEP].dataInputsTable,
@@ -125,22 +125,22 @@ const JobWizardRunDetails = ({
125125
label: 'Cancel',
126126
variant: TERTIARY_BUTTON,
127127
handler: () => {
128-
formState.form.change(methodPath, prevValue)
129-
setSpyOnMethodChange(true)
128+
formState.form.change(handlerPath, prevValue)
129+
setspyOnHandlerChange(true)
130130
}
131131
},
132132
confirmButton: {
133133
label: 'OK',
134134
variant: SECONDARY_BUTTON,
135135
handler: () => {
136-
handleMethodChange(value)
136+
handleHandlerChange(value)
137137
}
138138
},
139139
header: 'Are you sure?',
140140
message: 'Changes made to the Data Inputs and Parameters sections will be lost'
141141
})
142142
} else {
143-
handleMethodChange(value)
143+
handleHandlerChange(value)
144144
}
145145
}
146146

@@ -175,18 +175,18 @@ const JobWizardRunDetails = ({
175175
</div>
176176
)}
177177
{!isBatchInference ? (
178-
jobAdditionalData.methodOptions?.length !== 0 ? (
178+
jobAdditionalData.handlerOptions?.length !== 0 ? (
179179
<div className="form-col-1">
180180
<FormSelect
181-
label="Method"
182-
name={methodPath}
183-
options={jobAdditionalData.methodOptions || []}
181+
label="Handler"
182+
name={handlerPath}
183+
options={jobAdditionalData.handlerOptions || []}
184184
scrollToView={false}
185185
/>
186186
</div>
187187
) : (
188188
<div className="form-col-1">
189-
<FormInput label="Method" name={methodPath} disabled={isEditMode} />
189+
<FormInput label="Handler" name={handlerPath} disabled={isEditMode} />
190190
</div>
191191
)
192192
) : null}
@@ -263,10 +263,10 @@ const JobWizardRunDetails = ({
263263
</div>
264264
</>
265265
)}
266-
{get(formState.values, `${RUN_DETAILS_STEP}.methodData.doc`, '') && (
266+
{get(formState.values, `${RUN_DETAILS_STEP}.handlerData.doc`, '') && (
267267
<>
268268
<div className="form-row form-table-title">Description</div>
269-
<div className="form-row">{formState.values[RUN_DETAILS_STEP].methodData.doc}</div>
269+
<div className="form-row">{formState.values[RUN_DETAILS_STEP].handlerData.doc}</div>
270270
</>
271271
)}
272272
{get(formState.values, outputsPath, []).length > 0 && (
@@ -305,8 +305,8 @@ const JobWizardRunDetails = ({
305305
</>
306306
)}
307307

308-
{stepIsActive && spyOnMethodChange && (
309-
<OnChange name={methodPath}>{onMethodChange}</OnChange>
308+
{stepIsActive && spyOnHandlerChange && (
309+
<OnChange name={handlerPath}>{onHandlerChange}</OnChange>
310310
)}
311311
</div>
312312
)

0 commit comments

Comments
 (0)