diff --git a/src/components/JobWizard/JobWizard.util.js b/src/components/JobWizard/JobWizard.util.js index 7926f9fbe4..69f2f1f44c 100644 --- a/src/components/JobWizard/JobWizard.util.js +++ b/src/components/JobWizard/JobWizard.util.js @@ -110,7 +110,7 @@ export const generateJobWizardData = ( const functions = selectedFunctionData.functions const functionInfo = getFunctionInfo(selectedFunctionData) const defaultResources = frontendSpec?.default_function_pod_resources ?? {} - const functionParameters = getFunctionParameters(functions, functionInfo.method) + const functionParameters = getFunctionParameters(functions, functionInfo.handler) const [functionPriorityClassName] = getFunctionPriorityClass(functions) const [limits] = getLimits(functions) const [requests] = getRequests(functions) @@ -125,7 +125,7 @@ export const generateJobWizardData = ( ? getDefaultSchedule(defaultData.schedule) : scheduleDataInitialState const jobAdditionalData = { - methodOptions: functionInfo.methodOptions, + handlerOptions: functionInfo.handlerOptions, versionOptions: functionInfo.versionOptions } const currentLimits = parseLimits(limits, defaultResources.limits, gpuType) @@ -135,8 +135,8 @@ export const generateJobWizardData = ( [RUN_DETAILS_STEP]: { runName: functionInfo.name, version: functionInfo.version, - method: functionInfo.method, - methodData: functionInfo.methodData, + handler: functionInfo.handler, + handlerData: functionInfo.handlerData, labels: [], image: parseImageData(functionInfo.function, frontendSpec, currentProjectName) }, @@ -211,7 +211,7 @@ export const generateJobWizardDefaultData = ( if (isEmpty(defaultData)) return [{}, {}] const runInfo = getRunDefaultInfo(defaultData, selectedFunctionData) - const functionParameters = getFunctionDefaultParameters(selectedFunctionData, runInfo.method) + const functionParameters = getFunctionDefaultParameters(selectedFunctionData, runInfo.handler) const [predefinedParameters, customParameters] = parseDefaultParameters( functionParameters, defaultData.task.spec.parameters, @@ -225,7 +225,7 @@ export const generateJobWizardDefaultData = ( const requests = defaultData.function.spec?.resources?.requests const gpuType = getLimitsGpuType(limits) const jobAdditionalData = { - methodOptions: runInfo.methodOptions, + handlerOptions: runInfo.handlerOptions, versionOptions: runInfo.versionOptions } const currentLimits = parseLimits(limits, defaultResources.limits, gpuType) @@ -238,8 +238,8 @@ export const generateJobWizardDefaultData = ( [RUN_DETAILS_STEP]: { runName: runInfo.name, version: runInfo.version, - method: runInfo.method, - methodData: runInfo.methodData, + handler: runInfo.handler, + handlerData: runInfo.handlerData, labels: runInfo.labels, image: parseImageData(selectedFunctionData, frontendSpec, currentProjectName) }, @@ -299,16 +299,16 @@ export const generateJobWizardDefaultData = ( return [jobFormData, jobAdditionalData] } -export const getMethodData = (selectedFunctionData, method) => { +export const getHandlerData = (selectedFunctionData, handler) => { const currentFunction = selectedFunctionData?.functions ? chain(selectedFunctionData.functions).orderBy('metadata.updated', 'desc').get(0).value() : selectedFunctionData - const methodData = get(currentFunction, ['spec', 'entry_points', method], {}) - const outputs = (methodData?.outputs ?? []).filter(output => !isEveryObjectValueEmpty(output)) + const handlerData = get(currentFunction, ['spec', 'entry_points', handler], {}) + const outputs = (handlerData?.outputs ?? []).filter(output => !isEveryObjectValueEmpty(output)) return { - doc: methodData?.doc, - has_kwargs: methodData?.has_kwargs || false, + doc: handlerData?.doc, + has_kwargs: handlerData?.has_kwargs || false, outputs } } @@ -318,10 +318,10 @@ const getFunctionInfo = selectedFunctionData => { if (!isEmpty(functions)) { const versionOptions = getVersionOptions(functions) - const methodOptions = getMethodOptions(functions) - const { defaultVersion, defaultMethod } = getDefaultMethodAndVersion( + const handlerOptions = getHandlerOptions(functions) + const { defaultVersion, defaultHandler } = getDefaultHandlerAndVersion( versionOptions, - methodOptions, + handlerOptions, functions ) const currentFunctionVersion = selectedFunctionData.tag || defaultVersion @@ -330,10 +330,10 @@ const getFunctionInfo = selectedFunctionData => { return { name: selectedFunctionData.name, - method: defaultMethod, + handler: defaultHandler, version: currentFunctionVersion, - methodData: getMethodData(currentFunction, defaultMethod), - methodOptions, + handlerData: getHandlerData(currentFunction, defaultHandler), + handlerOptions, versionOptions, function: currentFunction || {} } @@ -344,15 +344,15 @@ const getRunDefaultInfo = (defaultData, selectedFunctionData) => { return { labels: parseChipsData(defaultData.task?.metadata?.labels), name: defaultData.task?.metadata?.name || '', - method: defaultData.task?.spec?.handler, - methodData: getMethodData(selectedFunctionData, defaultData.task?.spec?.handler), - methodOptions: [], + handler: defaultData.task?.spec?.handler, + handlerData: getHandlerData(selectedFunctionData, defaultData.task?.spec?.handler), + handlerOptions: [], version: '', versionOptions: [] } } -const getMethodOptions = selectedFunctions => { +const getHandlerOptions = selectedFunctions => { return chain(selectedFunctions) .map(func => Object.values(func.spec?.entry_points ?? {})) .flatten() @@ -379,47 +379,47 @@ const getVersionOptions = selectedFunctions => { return versionOptions.length ? versionOptions : [{ label: 'N/A', id: TAG_NA }] } -const getDefaultMethod = (methodOptions, selectedFunctions) => { - let method = '' +const getDefaultHandler = (handlerOptions, selectedFunctions) => { + let handler = '' const latestFunction = selectedFunctions.find(item => item.metadata.tag === TAG_LATEST) - if (methodOptions.length) { - method = methodOptions[0]?.id + if (handlerOptions.length) { + handler = handlerOptions[0]?.id } else if (latestFunction) { - method = latestFunction.spec.default_handler || FUNCTION_DEFAULT_HANDLER + handler = latestFunction.spec.default_handler || FUNCTION_DEFAULT_HANDLER } else { - method = selectedFunctions[0]?.spec.default_handler || FUNCTION_DEFAULT_HANDLER + handler = selectedFunctions[0]?.spec.default_handler || FUNCTION_DEFAULT_HANDLER } - return method + return handler } -const getDefaultMethodAndVersion = (versionOptions, methodOptions, selectedFunctions) => { +const getDefaultHandlerAndVersion = (versionOptions, handlerOptions, selectedFunctions) => { const defaultVersion = versionOptions.find(version => version.id === TAG_LATEST)?.id || versionOptions[0].id || '' - const defaultMethod = getDefaultMethod(methodOptions, selectedFunctions) + const defaultHandler = getDefaultHandler(handlerOptions, selectedFunctions) return { defaultVersion, - defaultMethod + defaultHandler } } -export const getFunctionParameters = (selectedFunction, method) => { +export const getFunctionParameters = (selectedFunction, handler) => { return chain(selectedFunction) .orderBy('metadata.updated', 'desc') .map(func => { - return func.spec.entry_points ? func.spec.entry_points[method]?.parameters ?? [] : [] + return func.spec.entry_points ? func.spec.entry_points[handler]?.parameters ?? [] : [] }) .flatten() .unionBy('name') .value() } -export const getFunctionDefaultParameters = (selectedFunction, method) => { - const functionParameters = get(selectedFunction, `spec.entry_points[${method}].parameters`, []) +export const getFunctionDefaultParameters = (selectedFunction, handler) => { + const functionParameters = get(selectedFunction, `spec.entry_points[${handler}].parameters`, []) return keyBy(functionParameters, 'name') } @@ -1081,7 +1081,7 @@ export const generateJobRequestData = ( // secret_sources: formData[ADVANCED_STEP].secretSourcesTable.map(secretSource => { // return { kind: secretSource.data.key, source: secretSource.data.value } // }), - handler: formData[RUN_DETAILS_STEP].method ?? '', + handler: formData[RUN_DETAILS_STEP].handler ?? '', input_path: formData[ADVANCED_STEP].inputPath ?? '', output_path: formData[ADVANCED_STEP].outputPath, function: diff --git a/src/components/JobWizard/JobWizardSteps/JobWizardDataInputs/JobWizardDataInputs.js b/src/components/JobWizard/JobWizardSteps/JobWizardDataInputs/JobWizardDataInputs.js index 88d4ff4350..d752f42aa8 100644 --- a/src/components/JobWizard/JobWizardSteps/JobWizardDataInputs/JobWizardDataInputs.js +++ b/src/components/JobWizard/JobWizardSteps/JobWizardDataInputs/JobWizardDataInputs.js @@ -35,7 +35,7 @@ const JobWizardDataInputs = ({ formState, stepIsActive }) => { exitEditModeTriggerItem={stepIsActive} fieldsPath={`${DATA_INPUTS_STEP}.dataInputsTable`} formState={formState} - rowCanBeAdded={formState.values.runDetails.methodData?.has_kwargs} + rowCanBeAdded={formState.values.runDetails.handlerData?.has_kwargs} /> diff --git a/src/components/JobWizard/JobWizardSteps/JobWizardFunctionSelection/JobWizardFunctionSelection.js b/src/components/JobWizard/JobWizardSteps/JobWizardFunctionSelection/JobWizardFunctionSelection.js index 589e2dcfde..5d0100b5a0 100644 --- a/src/components/JobWizard/JobWizardSteps/JobWizardFunctionSelection/JobWizardFunctionSelection.js +++ b/src/components/JobWizard/JobWizardSteps/JobWizardFunctionSelection/JobWizardFunctionSelection.js @@ -45,7 +45,7 @@ import { generateProjectsList } from '../../../../utils/projects' import { functionRunKinds } from '../../../Jobs/jobs.util' import { openConfirmPopUp } from 'igz-controls/utils/common.util' import { - filterTrainFunctionMethods, + filterTrainFunctionHandlers, FUNCTIONS_SELECTION_FUNCTIONS_TAB, FUNCTIONS_SELECTION_HUB_TAB, functionsSelectionTabs, @@ -335,7 +335,7 @@ const JobWizardFunctionSelection = ({ const functionTemplatePath = `${functionData.spec.item_uri}${functionData.spec.assets.function}` dispatch(functionsActions.fetchFunctionTemplate(functionTemplatePath)).then(result => { - const resultData = isTrain ? filterTrainFunctionMethods(result) : result + const resultData = isTrain ? filterTrainFunctionHandlers(result) : result setSelectedFunctionData(resultData) generateData(resultData) diff --git a/src/components/JobWizard/JobWizardSteps/JobWizardFunctionSelection/jobWizardFunctionSelection.util.js b/src/components/JobWizard/JobWizardSteps/JobWizardFunctionSelection/jobWizardFunctionSelection.util.js index d9e2a8586d..2333455cd6 100644 --- a/src/components/JobWizard/JobWizardSteps/JobWizardFunctionSelection/jobWizardFunctionSelection.util.js +++ b/src/components/JobWizard/JobWizardSteps/JobWizardFunctionSelection/jobWizardFunctionSelection.util.js @@ -69,13 +69,13 @@ export const generateFunctionTemplateCardData = templateData => { return functionTemplateCardData } -export const filterTrainFunctionMethods = result => { - const allowedMethods = trainModelAllowedHubFunctions[result.name] +export const filterTrainFunctionHandlers = result => { + const allowedHandlers = trainModelAllowedHubFunctions[result.name] const { entry_points } = result.functions[0].spec if (entry_points) { result.functions[0].spec.entry_points = Object.fromEntries( - Object.entries(entry_points).filter(([key]) => allowedMethods.includes(key)) + Object.entries(entry_points).filter(([key]) => allowedHandlers.includes(key)) ) } diff --git a/src/components/JobWizard/JobWizardSteps/JobWizardParameters/JobWizardParameters.js b/src/components/JobWizard/JobWizardSteps/JobWizardParameters/JobWizardParameters.js index 8a4b7bf350..a41cc69d9f 100644 --- a/src/components/JobWizard/JobWizardSteps/JobWizardParameters/JobWizardParameters.js +++ b/src/components/JobWizard/JobWizardSteps/JobWizardParameters/JobWizardParameters.js @@ -70,7 +70,7 @@ const JobWizardParameters = ({ formState, stepIsActive }) => { fieldsPath={`${PARAMETERS_STEP}.parametersTable`} formState={formState} parametersFromPath={parametersFromPath} - rowCanBeAdded={formState.values.runDetails.methodData?.has_kwargs} + rowCanBeAdded={formState.values.runDetails.handlerData?.has_kwargs} withHyperparameters={ hyperParametersAreEnabled && selectedFromValue === PARAMETERS_FROM_UI_VALUE } diff --git a/src/components/JobWizard/JobWizardSteps/JobWizardRunDetails/JobWizardRunDetails.js b/src/components/JobWizard/JobWizardSteps/JobWizardRunDetails/JobWizardRunDetails.js index 71bce426b8..25b28b90a4 100644 --- a/src/components/JobWizard/JobWizardSteps/JobWizardRunDetails/JobWizardRunDetails.js +++ b/src/components/JobWizard/JobWizardSteps/JobWizardRunDetails/JobWizardRunDetails.js @@ -48,7 +48,7 @@ import { getValidationRules } from 'igz-controls/utils/validation.util' import { openPopUp } from 'igz-controls/utils/common.util' import { getFunctionParameters, - getMethodData, + getHandlerData, parseDataInputs, parsePredefinedParameters } from '../../JobWizard.util' @@ -64,10 +64,10 @@ const JobWizardRunDetails = ({ selectedFunctionData, stepIsActive }) => { - const methodPath = `${RUN_DETAILS_STEP}.method` + const handlerPath = `${RUN_DETAILS_STEP}.handler` const imageSourcePath = `${RUN_DETAILS_STEP}.image.imageSource` - const outputsPath = `${RUN_DETAILS_STEP}.methodData.outputs` - const [spyOnMethodChange, setSpyOnMethodChange] = useState(true) + const outputsPath = `${RUN_DETAILS_STEP}.handlerData.outputs` + const [spyOnHandlerChange, setspyOnHandlerChange] = useState(true) const commonImageWarningMsg = 'The image must include all the software packages that are required to run the function. ' + 'For example, for an XGBoost model, ensure that the image includes the correct XGboost package and version' @@ -80,13 +80,13 @@ const JobWizardRunDetails = ({ [formState.values, imageSourcePath] ) - const handleMethodChange = method => { - setSpyOnMethodChange(true) + const handleHandlerChange = handler => { + setspyOnHandlerChange(true) - const functionParameters = getFunctionParameters(selectedFunctionData.functions, method) + const functionParameters = getFunctionParameters(selectedFunctionData.functions, handler) const dataInputs = parseDataInputs(functionParameters, prePopulatedData?.dataInputs) const predefinedParameters = parsePredefinedParameters(functionParameters) - const methodData = getMethodData(selectedFunctionData, method) + const handlerData = getHandlerData(selectedFunctionData, handler) set(formState.initialValues, `${DATA_INPUTS_STEP}.dataInputsTable`, dataInputs) set( @@ -94,18 +94,18 @@ const JobWizardRunDetails = ({ `${PARAMETERS_STEP}.parametersTable.predefined`, predefinedParameters ) - set(formState.initialValues, `${RUN_DETAILS_STEP}.methodData`, methodData) + set(formState.initialValues, `${RUN_DETAILS_STEP}.handlerData`, handlerData) formState.form.change(`${DATA_INPUTS_STEP}.dataInputsTable`, dataInputs) formState.form.change(`${PARAMETERS_STEP}.parametersTable.predefined`, predefinedParameters) - formState.form.change(`${RUN_DETAILS_STEP}.methodData`, methodData) + formState.form.change(`${RUN_DETAILS_STEP}.handlerData`, handlerData) formState.form.change( `${PARAMETERS_STEP}.parametersTable.custom`, get(formState.initialValues, `${PARAMETERS_STEP}.parametersTable.custom`, []) ) } - const onMethodChange = (value, prevValue) => { - setSpyOnMethodChange(false) + const onHandlerChange = (value, prevValue) => { + setspyOnHandlerChange(false) const dataInputsAreChanged = areFormValuesChanged( formState.initialValues[DATA_INPUTS_STEP].dataInputsTable, @@ -126,22 +126,22 @@ const JobWizardRunDetails = ({ label: 'Cancel', variant: TERTIARY_BUTTON, handler: () => { - formState.form.change(methodPath, prevValue) - setSpyOnMethodChange(true) + formState.form.change(handlerPath, prevValue) + setspyOnHandlerChange(true) } }, confirmButton: { label: 'OK', variant: SECONDARY_BUTTON, handler: () => { - handleMethodChange(value) + handleHandlerChange(value) } }, header: 'Are you sure?', message: 'Changes made to the Data Inputs and Parameters sections will be lost' }) } else { - handleMethodChange(value) + handleHandlerChange(value) } } @@ -180,18 +180,18 @@ const JobWizardRunDetails = ({ )} {!isBatchInference ? ( - jobAdditionalData.methodOptions?.length !== 0 ? ( + jobAdditionalData.handlerOptions?.length !== 0 ? (