diff --git a/package.json b/package.json index cb48596973..14322e2bbe 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "@monaco-editor/react": "^4.6.0", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3", "@reduxjs/toolkit": "^1.8.1", - "axios": "1.7.4", + "axios": "1.8.2", "bfj": "^7.0.2", "browserslist": "^4.18.1", "camelcase": "^6.2.1", @@ -24,7 +24,7 @@ "final-form-arrays": "^3.1.0", "fs-extra": "^10.0.0", "identity-obj-proxy": "^3.0.0", - "iguazio.dashboard-react-controls": "2.2.22", + "iguazio.dashboard-react-controls": "2.2.24", "is-wsl": "^1.1.0", "js-base64": "^2.5.2", "js-yaml": "^4.1.0", diff --git a/src/App.js b/src/App.js index 90387b86b5..1197c90524 100755 --- a/src/App.js +++ b/src/App.js @@ -118,6 +118,7 @@ const WorkflowsMonitoring = lazyRetry( () => import('./components/ProjectsJobsMonitoring/WorkflowsMonitoring/WorkflowsMonitoring') ) const Documents = lazyRetry(() => import('./components/Documents/Documents')) +const LLMPrompts = lazyRetry(() => import('./components/LLMPrompts/LLMPrompts')) const App = () => { const { isNuclioModeDisabled } = useNuclioMode() @@ -324,6 +325,16 @@ const App = () => { } /> ))} + {[ + 'projects/:projectName/llm-prompts', + 'projects/:projectName/llm-prompts/:promptName/:id/:tab', + `projects/:projectName/llm-prompts/:promptName/${ALL_VERSIONS_PATH}`, + `projects/:projectName/llm-prompts/:promptName/${ALL_VERSIONS_PATH}/:id/:tab` + ].map((path, index) => ( + + } /> + + ))} } /> } /> diff --git a/src/actions/details.js b/src/actions/details.js deleted file mode 100644 index c1910faece..0000000000 --- a/src/actions/details.js +++ /dev/null @@ -1,161 +0,0 @@ -/* -Copyright 2019 Iguazio Systems Ltd. - -Licensed under the Apache License, Version 2.0 (the "License") with -an addition restriction as set forth herein. You may not use this -file except in compliance with the License. You may obtain a copy of -the License at http://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -implied. See the License for the specific language governing -permissions and limitations under the License. - -In addition, you may not use the software for any purposes that are -illegal under applicable law, and the grant of the foregoing license -under the Apache 2.0 license is conditioned upon your compliance with -such restriction. -*/ -import detailsApi from '../api/details-api' -import { - FETCH_JOB_PODS_BEGIN, - FETCH_JOB_PODS_FAILURE, - FETCH_JOB_PODS_SUCCESS, - FETCH_MODEL_FEATURE_VECTOR_BEGIN, - FETCH_MODEL_FEATURE_VECTOR_FAILURE, - FETCH_MODEL_FEATURE_VECTOR_SUCCESS, - REMOVE_DETAILS_POPUP_INFO_CONTENT, - REMOVE_INFO_CONTENT, - REMOVE_JOB_PODS, - REMOVE_MODEL_FEATURE_VECTOR, - RESET_CHANGES, - SET_CHANGES, - SET_CHANGES_COUNTER, - SET_CHANGES_DATA, - SET_DETAILS_DATES, - SET_DETAILS_POPUP_INFO_CONTENT, - SET_EDIT_MODE, - SET_FILTERS_WAS_HANDLED, - SET_INFO_CONTENT, - SET_ITERATION, - SET_ITERATION_OPTIONS, - SHOW_WARNING -} from '../constants' -import { generatePods } from '../utils/generatePods' - -const detailsActions = { - fetchModelFeatureVector: (project, name, reference) => dispatch => { - dispatch(detailsActions.fetchModelFeatureVectorBegin()) - - return detailsApi - .getModelFeatureVector(project, name, reference) - .then(response => { - dispatch(detailsActions.fetchModelFeatureVectorSuccess(response.data.status)) - - return response.data.status - }) - .catch(err => { - dispatch(detailsActions.fetchModelFeatureVectorFailure(err)) - }) - }, - fetchModelFeatureVectorBegin: () => ({ - type: FETCH_MODEL_FEATURE_VECTOR_BEGIN - }), - fetchModelFeatureVectorFailure: error => ({ - type: FETCH_MODEL_FEATURE_VECTOR_FAILURE, - payload: error - }), - fetchModelFeatureVectorSuccess: featureSets => ({ - type: FETCH_MODEL_FEATURE_VECTOR_SUCCESS, - payload: featureSets - }), - fetchJobPods: (project, uid, kind) => dispatch => { - dispatch(detailsActions.fetchPodsBegin()) - - return detailsApi - .getJobPods(project, uid, kind) - .then(({ data }) => { - let podsData = generatePods(project, uid, data) - - dispatch(detailsActions.fetchPodsSuccess(podsData)) - - return podsData - }) - .catch(err => { - dispatch(detailsActions.fetchPodsFailure(err)) - }) - }, - fetchPodsBegin: () => ({ - type: FETCH_JOB_PODS_BEGIN - }), - fetchPodsFailure: error => ({ - type: FETCH_JOB_PODS_FAILURE, - payload: error - }), - fetchPodsSuccess: pods => ({ - type: FETCH_JOB_PODS_SUCCESS, - payload: pods - }), - removeDetailsPopUpInfoContent: () => ({ - type: REMOVE_DETAILS_POPUP_INFO_CONTENT - }), - removeInfoContent: () => ({ - type: REMOVE_INFO_CONTENT - }), - removeModelFeatureVector: () => ({ - type: REMOVE_MODEL_FEATURE_VECTOR - }), - removePods: () => ({ - type: REMOVE_JOB_PODS - }), - resetChanges: () => ({ - type: RESET_CHANGES - }), - setChanges: data => ({ - type: SET_CHANGES, - payload: data - }), - setChangesCounter: counter => ({ - type: SET_CHANGES_COUNTER, - payload: counter - }), - setChangesData: data => ({ - type: SET_CHANGES_DATA, - payload: data - }), - setDetailsDates: data => ({ - type: SET_DETAILS_DATES, - payload: data - }), - setDetailsPopUpInfoContent: content => ({ - type: SET_DETAILS_POPUP_INFO_CONTENT, - payload: content - }), - setEditMode: value => ({ - type: SET_EDIT_MODE, - payload: value - }), - setFiltersWasHandled: isHandled => ({ - type: SET_FILTERS_WAS_HANDLED, - payload: isHandled - }), - setInfoContent: content => ({ - type: SET_INFO_CONTENT, - payload: content - }), - setIteration: iteration => ({ - type: SET_ITERATION, - payload: iteration - }), - setIterationOption: option => ({ - type: SET_ITERATION_OPTIONS, - payload: option - }), - showWarning: show => ({ - type: SHOW_WARNING, - payload: show - }) -} - -export default detailsActions diff --git a/src/actions/functions.js b/src/actions/functions.js deleted file mode 100644 index d3cb826ed0..0000000000 --- a/src/actions/functions.js +++ /dev/null @@ -1,521 +0,0 @@ -/* -Copyright 2019 Iguazio Systems Ltd. - -Licensed under the Apache License, Version 2.0 (the "License") with -an addition restriction as set forth herein. You may not use this -file except in compliance with the License. You may obtain a copy of -the License at http://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -implied. See the License for the specific language governing -permissions and limitations under the License. - -In addition, you may not use the software for any purposes that are -illegal under applicable law, and the grant of the foregoing license -under the Apache 2.0 license is conditioned upon your compliance with -such restriction. -*/ -import yaml from 'js-yaml' -import { - CREATE_NEW_FUNCTION_BEGIN, - CREATE_NEW_FUNCTION_FAILURE, - CREATE_NEW_FUNCTION_SUCCESS, - DEPLOY_FUNCTION_BEGIN, - DEPLOY_FUNCTION_FAILURE, - DEPLOY_FUNCTION_SUCCESS, - FETCH_FUNCTIONS_BEGIN, - FETCH_FUNCTIONS_FAILURE, - FETCH_FUNCTIONS_SUCCESS, - FETCH_FUNCTIONS_TEMPLATES_FAILURE, - FETCH_FUNCTION_NUCLIO_LOGS_BEGIN, - FETCH_FUNCTION_NUCLIO_LOGS_FAILURE, - FETCH_FUNCTION_NUCLIO_LOGS_SUCCESS, - FETCH_FUNCTION_LOGS_BEGIN, - FETCH_FUNCTION_LOGS_FAILURE, - FETCH_FUNCTION_LOGS_SUCCESS, - FETCH_FUNCTION_TEMPLATE_BEGIN, - FETCH_FUNCTION_TEMPLATE_FAILURE, - FETCH_FUNCTION_TEMPLATE_SUCCESS, - FETCH_HUB_FUNCTIONS_BEGIN, - FETCH_HUB_FUNCTIONS_FAILURE, - FETCH_HUB_FUNCTION_TEMPLATE_BEGIN, - FETCH_HUB_FUNCTION_TEMPLATE_FAILURE, - FETCH_HUB_FUNCTION_TEMPLATE_SUCCESS, - GET_FUNCTION_BEGIN, - GET_FUNCTION_FAILURE, - GET_FUNCTION_SUCCESS, - REMOVE_FUNCTION, - REMOVE_FUNCTIONS_ERROR, - REMOVE_FUNCTION_TEMPLATE, - REMOVE_HUB_FUNCTIONS, - REMOVE_NEW_FUNCTION, - RESET_NEW_FUNCTION_CODE_CUSTOM_IMAGE, - SET_FUNCTIONS_TEMPLATES, - SET_HUB_FUNCTIONS, - SET_LOADING, - SET_NEW_FUNCTION, - SET_NEW_FUNCTION_BASE_IMAGE, - SET_NEW_FUNCTION_BUILD_IMAGE, - SET_NEW_FUNCTION_COMMANDS, - SET_NEW_FUNCTION_CREDENTIALS_ACCESS_KEY, - SET_NEW_FUNCTION_DEFAULT_CLASS, - SET_NEW_FUNCTION_DESCRIPTION, - SET_NEW_FUNCTION_DISABLE_AUTO_MOUNT, - SET_NEW_FUNCTION_ENV, - SET_NEW_FUNCTION_ERROR_STREAM, - SET_NEW_FUNCTION_FORCE_BUILD, - SET_NEW_FUNCTION_GRAPH, - SET_NEW_FUNCTION_HANDLER, - SET_NEW_FUNCTION_IMAGE, - SET_NEW_FUNCTION_KIND, - SET_NEW_FUNCTION_NAME, - SET_NEW_FUNCTION_PARAMETERS, - SET_NEW_FUNCTION_PREEMTION_MODE, - SET_NEW_FUNCTION_PRIORITY_CLASS_NAME, - SET_NEW_FUNCTION_PROJECT, - SET_NEW_FUNCTION_REQUIREMENTS, - SET_NEW_FUNCTION_RESOURCES, - SET_NEW_FUNCTION_SECRETS, - SET_NEW_FUNCTION_SOURCE_CODE, - SET_NEW_FUNCTION_TAG, - SET_NEW_FUNCTION_TRACK_MODELS, - SET_NEW_FUNCTION_VOLUMES, - SET_NEW_FUNCTION_VOLUME_MOUNTS -} from '../constants' -import { FORBIDDEN_ERROR_STATUS_CODE } from 'igz-controls/constants' -import { generateCategories, generateHubCategories } from '../utils/generateTemplatesCategories' -import { showErrorNotification } from '../utils/notifications.util' -import functionsApi from '../api/functions-api' -import mlrunNuclioApi from '../api/mlrun-nuclio-api' -import { largeResponseCatchHandler } from '../utils/largeResponseCatchHandler' - -const functionsActions = { - createNewFunction: (project, data) => dispatch => { - dispatch(functionsActions.createNewFunctionBegin()) - - return functionsApi - .createNewFunction(project, data) - .then(result => { - dispatch(functionsActions.createNewFunctionSuccess()) - - return result - }) - .catch(error => { - const message = - error.response.status === FORBIDDEN_ERROR_STATUS_CODE - ? 'You do not have permission to create a new function' - : error.message - - dispatch(functionsActions.createNewFunctionFailure(message)) - }) - }, - createNewFunctionBegin: () => ({ - type: CREATE_NEW_FUNCTION_BEGIN - }), - createNewFunctionFailure: error => ({ - type: CREATE_NEW_FUNCTION_FAILURE, - payload: error - }), - createNewFunctionSuccess: () => ({ - type: CREATE_NEW_FUNCTION_SUCCESS - }), - deleteFunction: (funcName, project) => () => { - return functionsApi.deleteSelectedFunction(funcName, project) - }, - deployFunction: data => dispatch => { - dispatch(functionsActions.deployFunctionBegin()) - - return functionsApi - .deployFunction(data) - .then(result => { - dispatch(functionsActions.deployFunctionSuccess()) - - return result - }) - .catch(error => { - dispatch(functionsActions.deployFunctionFailure()) - - throw error - }) - }, - deployFunctionBegin: () => ({ - type: DEPLOY_FUNCTION_BEGIN - }), - deployFunctionFailure: () => ({ - type: DEPLOY_FUNCTION_FAILURE - }), - deployFunctionSuccess: () => ({ - type: DEPLOY_FUNCTION_SUCCESS - }), - fetchFunctionLogs: (project, name, tag) => dispatch => { - dispatch(functionsActions.fetchFunctionLogsBegin()) - - return functionsApi - .getFunctionLogs(project, name, tag) - .then(result => { - dispatch(functionsActions.fetchFunctionLogsSuccess()) - - return result - }) - .catch(error => dispatch(functionsActions.fetchFunctionLogsFailure(error))) - }, - fetchFunctionLogsBegin: () => ({ - type: FETCH_FUNCTION_LOGS_BEGIN - }), - fetchFunctionLogsFailure: error => ({ - type: FETCH_FUNCTION_LOGS_FAILURE, - payload: error - }), - fetchFunctionLogsSuccess: () => ({ - type: FETCH_FUNCTION_LOGS_SUCCESS - }), - fetchFunctionNuclioLogs: (project, name, tag) => dispatch => { - dispatch(functionsActions.fetchFunctionNuclioLogsBegin()) - - const config = { - params: {} - } - - if (tag) { - config.params.tag = tag - } - - return mlrunNuclioApi - .getDeployLogs(project, name, config) - .then(result => { - dispatch(functionsActions.fetchFunctionNuclioLogsSuccess()) - - return result - }) - .catch(error => dispatch(functionsActions.fetchFunctionNuclioLogsFailure(error))) - }, - fetchFunctionNuclioLogsBegin: () => ({ - type: FETCH_FUNCTION_NUCLIO_LOGS_BEGIN - }), - fetchFunctionNuclioLogsFailure: error => ({ - type: FETCH_FUNCTION_NUCLIO_LOGS_FAILURE, - payload: error - }), - fetchFunctionNuclioLogsSuccess: () => ({ - type: FETCH_FUNCTION_NUCLIO_LOGS_SUCCESS - }), - fetchFunctionTemplate: path => dispatch => { - dispatch(functionsActions.fetchFunctionTemplateBegin()) - - return functionsApi - .getFunctionTemplate(path) - .then(response => { - let parsedData = yaml.load(response.data) - const templates = { - name: parsedData.metadata.name, - functions: parsedData.spec.entry_point ? [] : [parsedData] - } - - dispatch(functionsActions.fetchFunctionTemplateSuccess(templates)) - - return templates - }) - .catch(error => { - dispatch(functionsActions.fetchFunctionTemplateFailure(error)) - showErrorNotification(dispatch, error, "Function's template failed to load") - }) - }, - fetchFunctionTemplateSuccess: selectFunction => ({ - type: FETCH_FUNCTION_TEMPLATE_SUCCESS, - payload: selectFunction - }), - fetchFunctionTemplateBegin: () => ({ - type: FETCH_FUNCTION_TEMPLATE_BEGIN - }), - fetchFunctionTemplateFailure: err => ({ - type: FETCH_FUNCTION_TEMPLATE_FAILURE, - payload: err - }), - fetchFunctions: - (project, filters, config, setRequestErrorMessage = () => {}) => - dispatch => { - const setRequestErrorMessageLocal = - config?.ui?.setRequestErrorMessage || setRequestErrorMessage - - dispatch(functionsActions.fetchFunctionsBegin()) - setRequestErrorMessageLocal('') - - return functionsApi - .getFunctions(project, filters, config) - .then(({ data }) => { - dispatch(functionsActions.fetchFunctionsSuccess(data.funcs)) - - return data - }) - .catch(error => { - dispatch(functionsActions.fetchFunctionsFailure(error.message)) - largeResponseCatchHandler( - error, - 'Failed to fetch functions', - dispatch, - setRequestErrorMessageLocal - ) - }) - }, - fetchFunctionsBegin: () => ({ - type: FETCH_FUNCTIONS_BEGIN - }), - fetchFunctionsFailure: error => ({ - type: FETCH_FUNCTIONS_FAILURE, - payload: error - }), - fetchFunctionsSuccess: funcs => ({ - type: FETCH_FUNCTIONS_SUCCESS, - payload: funcs - }), - fetchFunctionsTemplates: () => dispatch => { - return functionsApi - .getFunctionTemplatesCatalog() - .then(({ data: functionTemplates }) => { - const templatesData = generateCategories(functionTemplates) - - dispatch(functionsActions.setFunctionsTemplates(templatesData)) - - return templatesData - }) - .catch(error => { - dispatch(functionsActions.fetchFunctionsTemplatesFailure(error)) - }) - }, - fetchFunctionsTemplatesFailure: err => ({ - type: FETCH_FUNCTIONS_TEMPLATES_FAILURE, - payload: err - }), - fetchHubFunction: hubFunctionName => dispatch => { - dispatch(functionsActions.fetchHubFunctionTemplateBegin()) - - return functionsApi - .getHubFunction(hubFunctionName) - .then(response => { - dispatch(functionsActions.fetchHubFunctionTemplateSuccess()) - return response.data - }) - .catch(error => { - dispatch(functionsActions.fetchHubFunctionTemplateFailure(error)) - showErrorNotification(dispatch, error, 'The function failed to load') - }) - }, - fetchHubFunctionTemplateSuccess: () => ({ - type: FETCH_HUB_FUNCTION_TEMPLATE_SUCCESS - }), - fetchHubFunctionTemplateBegin: () => ({ - type: FETCH_HUB_FUNCTION_TEMPLATE_BEGIN - }), - fetchHubFunctionTemplateFailure: err => ({ - type: FETCH_HUB_FUNCTION_TEMPLATE_FAILURE, - payload: err - }), - fetchHubFunctions: - (allowedHubFunctions, setRequestErrorMessage = () => {}) => - dispatch => { - dispatch(functionsActions.fetchHubFunctionsBegin()) - setRequestErrorMessage('') - - return functionsApi - .getHubFunctions() - .then(({ data: functionTemplates }) => { - const templatesData = generateHubCategories( - functionTemplates.catalog, - allowedHubFunctions - ) - - dispatch(functionsActions.setHubFunctions(templatesData)) - - return templatesData - }) - .catch(error => { - dispatch(functionsActions.fetchHubFunctionsFailure(error)) - largeResponseCatchHandler( - error, - 'Failed to fetch functions', - dispatch, - setRequestErrorMessage - ) - }) - }, - - fetchHubFunctionsBegin: () => ({ - type: FETCH_HUB_FUNCTIONS_BEGIN - }), - fetchHubFunctionsFailure: err => ({ - type: FETCH_HUB_FUNCTIONS_FAILURE, - payload: err - }), - fetchFunction: (project, name, hash, tag) => dispatch => { - dispatch(functionsActions.getFunctionBegin()) - - return functionsApi - .getFunction(project, name, hash, tag) - .then(result => { - dispatch(functionsActions.getFunctionSuccess(result.data.func)) - - return result.data.func - }) - .catch(error => { - dispatch(functionsActions.getFunctionFailure(error.message)) - throw error - }) - }, - getFunctionBegin: () => ({ - type: GET_FUNCTION_BEGIN - }), - getFunctionFailure: error => ({ - type: GET_FUNCTION_FAILURE, - payload: error - }), - getFunctionSuccess: func => ({ - type: GET_FUNCTION_SUCCESS, - payload: func - }), - removeFunction: () => ({ - type: REMOVE_FUNCTION - }), - removeHubFunctions: () => ({ - type: REMOVE_HUB_FUNCTIONS - }), - removeFunctionTemplate: () => ({ - type: REMOVE_FUNCTION_TEMPLATE - }), - removeFunctionsError: () => ({ - type: REMOVE_FUNCTIONS_ERROR - }), - removeNewFunction: () => ({ - type: REMOVE_NEW_FUNCTION - }), - resetNewFunctionCodeCustomImage: () => ({ - type: RESET_NEW_FUNCTION_CODE_CUSTOM_IMAGE - }), - setFunctionsTemplates: payload => ({ - type: SET_FUNCTIONS_TEMPLATES, - payload - }), - setHubFunctions: payload => ({ - type: SET_HUB_FUNCTIONS, - payload - }), - setLoading: loading => ({ - type: SET_LOADING, - payload: loading - }), - setNewFunction: func => ({ - type: SET_NEW_FUNCTION, - payload: func - }), - setNewFunctionBaseImage: base_image => ({ - type: SET_NEW_FUNCTION_BASE_IMAGE, - payload: base_image - }), - setNewFunctionBuildImage: build_image => ({ - type: SET_NEW_FUNCTION_BUILD_IMAGE, - payload: build_image - }), - setNewFunctionCommands: commands => ({ - type: SET_NEW_FUNCTION_COMMANDS, - payload: commands - }), - setNewFunctionRequirements: requirements => ({ - type: SET_NEW_FUNCTION_REQUIREMENTS, - payload: requirements - }), - setNewFunctionDefaultClass: default_class => ({ - type: SET_NEW_FUNCTION_DEFAULT_CLASS, - payload: default_class - }), - setNewFunctionDescription: description => ({ - type: SET_NEW_FUNCTION_DESCRIPTION, - payload: description - }), - setNewFunctionDisableAutoMount: value => ({ - type: SET_NEW_FUNCTION_DISABLE_AUTO_MOUNT, - payload: value - }), - setNewFunctionEnv: env => ({ - type: SET_NEW_FUNCTION_ENV, - payload: env - }), - setNewFunctionErrorStream: error_stream => ({ - type: SET_NEW_FUNCTION_ERROR_STREAM, - payload: error_stream - }), - setNewFunctionForceBuild: forceBuild => ({ - type: SET_NEW_FUNCTION_FORCE_BUILD, - payload: forceBuild - }), - setNewFunctionGraph: graph => ({ - type: SET_NEW_FUNCTION_GRAPH, - payload: graph - }), - setNewFunctionHandler: handler => ({ - type: SET_NEW_FUNCTION_HANDLER, - payload: handler - }), - setNewFunctionImage: image => ({ - type: SET_NEW_FUNCTION_IMAGE, - payload: image - }), - setNewFunctionKind: kind => ({ - type: SET_NEW_FUNCTION_KIND, - payload: kind - }), - setNewFunctionCredentialsAccessKey: accessKey => ({ - type: SET_NEW_FUNCTION_CREDENTIALS_ACCESS_KEY, - payload: accessKey - }), - setNewFunctionName: name => ({ - type: SET_NEW_FUNCTION_NAME, - payload: name - }), - setNewFunctionParameters: parameters => ({ - type: SET_NEW_FUNCTION_PARAMETERS, - payload: parameters - }), - setNewFunctionPriorityClassName: className => ({ - type: SET_NEW_FUNCTION_PRIORITY_CLASS_NAME, - payload: className - }), - setNewFunctionPreemtionMode: mode => ({ - type: SET_NEW_FUNCTION_PREEMTION_MODE, - payload: mode - }), - setNewFunctionProject: project => ({ - type: SET_NEW_FUNCTION_PROJECT, - payload: project - }), - setNewFunctionResources: resources => ({ - type: SET_NEW_FUNCTION_RESOURCES, - payload: resources - }), - setNewFunctionSecretSources: secrets => ({ - type: SET_NEW_FUNCTION_SECRETS, - payload: secrets - }), - setNewFunctionSourceCode: code => ({ - type: SET_NEW_FUNCTION_SOURCE_CODE, - payload: code - }), - setNewFunctionTag: tag => ({ - type: SET_NEW_FUNCTION_TAG, - payload: tag - }), - setNewFunctionTrackModels: trackModels => ({ - type: SET_NEW_FUNCTION_TRACK_MODELS, - payload: trackModels - }), - setNewFunctionVolumeMounts: volumeMounts => ({ - type: SET_NEW_FUNCTION_VOLUME_MOUNTS, - payload: volumeMounts - }), - setNewFunctionVolumes: volumes => ({ - type: SET_NEW_FUNCTION_VOLUMES, - payload: volumes - }) -} - -export default functionsActions diff --git a/src/actions/modelEndpoints.js b/src/actions/modelEndpoints.js deleted file mode 100644 index 9427f2e6b9..0000000000 --- a/src/actions/modelEndpoints.js +++ /dev/null @@ -1,122 +0,0 @@ -/* -Copyright 2019 Iguazio Systems Ltd. - -Licensed under the Apache License, Version 2.0 (the "License") with -an addition restriction as set forth herein. You may not use this -file except in compliance with the License. You may obtain a copy of -the License at http://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -implied. See the License for the specific language governing -permissions and limitations under the License. - -In addition, you may not use the software for any purposes that are -illegal under applicable law, and the grant of the foregoing license -under the Apache 2.0 license is conditioned upon your compliance with -such restriction. -*/ -import modelEndpointsApi from '../api/modelEndpoints-api' -import { - DEFAULT_ABORT_MSG, - FETCH_ENDPOINT_METRICS_BEGIN, - FETCH_ENDPOINT_METRICS_SUCCESS, - FETCH_ENDPOINT_METRICS_FAILURE, - FETCH_ENDPOINT_METRICS_VALUES_BEGIN, - FETCH_ENDPOINT_METRICS_VALUES_SUCCESS, - FETCH_ENDPOINT_METRICS_VALUES_FAILURE, - SET_SELECTED_METRICS_OPTIONS -} from '../constants' - -import { - generateMetricsItems, - parseMetrics -} from '../components/DetailsMetrics/detailsMetrics.util' -import { TIME_FRAME_LIMITS } from '../utils/datePicker.util' -import { largeResponseCatchHandler } from '../utils/largeResponseCatchHandler' - -const modelEndpointsActions = { - fetchModelEndpointMetrics: (project, uid) => dispatch => { - dispatch(modelEndpointsActions.fetchEndpointMetricsBegin()) - - return modelEndpointsApi - .getModelEndpointMetrics(project, uid) - .then(({ data = [] }) => { - const metrics = generateMetricsItems(data) - - dispatch(modelEndpointsActions.fetchEndpointMetricsSuccess({ endpointUid: uid, metrics })) - - return metrics - }) - .catch(error => { - dispatch(modelEndpointsActions.fetchEndpointMetricsFailure(error)) - }) - }, - fetchEndpointMetricsBegin: () => ({ - type: FETCH_ENDPOINT_METRICS_BEGIN - }), - fetchEndpointMetricsFailure: error => ({ - type: FETCH_ENDPOINT_METRICS_FAILURE, - payload: error - }), - fetchEndpointMetricsSuccess: payload => ({ - type: FETCH_ENDPOINT_METRICS_SUCCESS, - payload - }), - fetchModelEndpointMetricsValues: ( - project, - uid, - params, - abortController, - setRequestErrorMessage = () => {} - ) => dispatch => { - const config = { - params, - ui: { - controller: abortController, - setRequestErrorMessage, - customErrorMessage: 'The query result is too large to display. Reduce either the number of metrics or the time period.' - } - } - - setRequestErrorMessage('') - dispatch(modelEndpointsActions.fetchEndpointMetricsValuesBegin()) - - return modelEndpointsApi - .getModelEndpointMetricsValues(project, uid, config) - .then(({ data = [] }) => { - const differenceInDays = params.end - params.start - const timeUnit = differenceInDays > TIME_FRAME_LIMITS['24_HOURS'] ? 'days' : 'hours' - const metrics = parseMetrics(data, timeUnit) - - dispatch(modelEndpointsActions.fetchEndpointMetricsValuesSuccess()) - - return metrics - }) - .catch(error => { - dispatch( - modelEndpointsActions.fetchEndpointMetricsValuesFailure( - error?.message === DEFAULT_ABORT_MSG ? null : error - ) - ) - largeResponseCatchHandler(error, 'Failed to fetch metrics', dispatch, setRequestErrorMessage) - }) - }, - fetchEndpointMetricsValuesBegin: () => ({ - type: FETCH_ENDPOINT_METRICS_VALUES_BEGIN - }), - fetchEndpointMetricsValuesFailure: error => ({ - type: FETCH_ENDPOINT_METRICS_VALUES_FAILURE, - payload: error - }), - fetchEndpointMetricsValuesSuccess: () => ({ - type: FETCH_ENDPOINT_METRICS_VALUES_SUCCESS - }), - setSelectedMetricsOptions: payload => ({ - type: SET_SELECTED_METRICS_OPTIONS, - payload - }) -} - -export default modelEndpointsActions diff --git a/src/actions/nuclio.js b/src/actions/nuclio.js deleted file mode 100644 index 5299b014b4..0000000000 --- a/src/actions/nuclio.js +++ /dev/null @@ -1,175 +0,0 @@ -/* -Copyright 2019 Iguazio Systems Ltd. - -Licensed under the Apache License, Version 2.0 (the "License") with -an addition restriction as set forth herein. You may not use this -file except in compliance with the License. You may obtain a copy of -the License at http://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -implied. See the License for the specific language governing -permissions and limitations under the License. - -In addition, you may not use the software for any purposes that are -illegal under applicable law, and the grant of the foregoing license -under the Apache 2.0 license is conditioned upon your compliance with -such restriction. -*/ -import { groupBy, property } from 'lodash' - -import nuclioApi from '../api/nuclio' -import { - FETCH_ALL_NUCLIO_FUNCTIONS_SUCCESS, - FETCH_API_GATEWAYS_BEGIN, - FETCH_API_GATEWAYS_FAILURE, - FETCH_API_GATEWAYS_SUCCESS, - FETCH_NUCLIO_FUNCTIONS_BEGIN, - FETCH_NUCLIO_FUNCTIONS_FAILURE, - FETCH_NUCLIO_FUNCTIONS_SUCCESS, - FETCH_NUCLIO_V3IO_STREAMS_BEGIN, - FETCH_NUCLIO_V3IO_STREAMS_FAILURE, - FETCH_NUCLIO_V3IO_STREAMS_SUCCESS, - FETCH_NUCLIO_V3IO_STREAM_SHARD_LAGS_BEGIN, - FETCH_NUCLIO_V3IO_STREAM_SHARD_LAGS_FAILURE, - FETCH_NUCLIO_V3IO_STREAM_SHARD_LAGS_SUCCESS, - REMOVE_V3IO_STREAMS, - RESET_V3IO_STREAMS_ERROR, - RESET_V3IO_STREAM_SHARD_LAG_ERROR -} from '../constants' -import { parseV3ioStreams } from '../utils/parseV3ioStreams' -import { parseV3ioStreamShardLags } from '../utils/parseV3ioStreamShardLags' - -const nuclioActions = { - fetchApiGateways: (project, signal) => dispatch => { - dispatch(nuclioActions.fetchApiGatewaysBegin()) - - return nuclioApi - .getApiGateways(project, signal) - .then(({ data }) => { - dispatch(nuclioActions.fetchApiGatewaysSuccess(Object.keys(data).length)) - }) - .catch(error => { - dispatch(nuclioActions.fetchApiGatewaysFailure(error.message)) - }) - }, - fetchApiGatewaysBegin: () => ({ - type: FETCH_API_GATEWAYS_BEGIN - }), - fetchApiGatewaysFailure: error => ({ - type: FETCH_API_GATEWAYS_FAILURE, - payload: error - }), - fetchApiGatewaysSuccess: apiGateways => ({ - type: FETCH_API_GATEWAYS_SUCCESS, - payload: apiGateways - }), - fetchNuclioFunctions: (project, signal) => dispatch => { - dispatch(nuclioActions.fetchNuclioFunctionsBegin()) - - return nuclioApi - .getFunctions(project, signal) - .then(({ data }) => { - if (project) { - dispatch(nuclioActions.fetchNuclioFunctionsSuccess(Object.values(data))) - } else { - let functionsByProject = groupBy( - data, - property(['metadata', 'labels', 'nuclio.io/project-name']) - ) - - dispatch(nuclioActions.fetchAllNuclioFunctionsSuccess(functionsByProject)) - } - }) - .catch(error => { - dispatch(nuclioActions.fetchNuclioFunctionsFailure(error.message)) - }) - }, - fetchNuclioFunctionsBegin: () => ({ - type: FETCH_NUCLIO_FUNCTIONS_BEGIN - }), - fetchNuclioFunctionsFailure: error => ({ - type: FETCH_NUCLIO_FUNCTIONS_FAILURE, - payload: error - }), - fetchNuclioFunctionsSuccess: functions => ({ - type: FETCH_NUCLIO_FUNCTIONS_SUCCESS, - payload: functions - }), - fetchAllNuclioFunctionsSuccess: functions => ({ - type: FETCH_ALL_NUCLIO_FUNCTIONS_SUCCESS, - payload: functions - }), - fetchNuclioV3ioStreamShardLags: (project, body) => dispatch => { - dispatch(nuclioActions.fetchNuclioV3ioStreamShardLagsBegin()) - - return nuclioApi - .getV3ioStreamShardLags(project, body) - .then(({ data }) => { - const parsedV3ioStreamShardLags = parseV3ioStreamShardLags(data, body) - - return dispatch( - nuclioActions.fetchNuclioV3ioStreamShardLagsSuccess({ - data, - parsedData: parsedV3ioStreamShardLags - }) - ) - }) - .catch(error => { - dispatch(nuclioActions.fetchNuclioV3ioStreamShardLagsFailure(error)) - }) - }, - fetchNuclioV3ioStreamShardLagsBegin: () => ({ - type: FETCH_NUCLIO_V3IO_STREAM_SHARD_LAGS_BEGIN - }), - fetchNuclioV3ioStreamShardLagsFailure: error => ({ - type: FETCH_NUCLIO_V3IO_STREAM_SHARD_LAGS_FAILURE, - payload: error - }), - fetchNuclioV3ioStreamShardLagsSuccess: summary => ({ - type: FETCH_NUCLIO_V3IO_STREAM_SHARD_LAGS_SUCCESS, - payload: summary - }), - fetchNuclioV3ioStreams: (project, signal) => dispatch => { - dispatch(nuclioActions.fetchNuclioV3ioStreamsBegin()) - - return nuclioApi - .getV3ioStreams(project, signal) - .then(({ data }) => { - const parsedV3ioStreams = parseV3ioStreams(data) - - return dispatch( - nuclioActions.fetchNuclioV3ioStreamsSuccess({ - data: data, - parsedData: parsedV3ioStreams - }) - ) - }) - .catch(error => { - dispatch(nuclioActions.fetchNuclioV3ioStreamsFailure(error)) - }) - }, - fetchNuclioV3ioStreamsBegin: () => ({ - type: FETCH_NUCLIO_V3IO_STREAMS_BEGIN - }), - fetchNuclioV3ioStreamsFailure: error => ({ - type: FETCH_NUCLIO_V3IO_STREAMS_FAILURE, - payload: error - }), - fetchNuclioV3ioStreamsSuccess: summary => ({ - type: FETCH_NUCLIO_V3IO_STREAMS_SUCCESS, - payload: summary - }), - removeV3ioStreams: () => ({ - type: REMOVE_V3IO_STREAMS - }), - resetV3ioStreamsError: () => ({ - type: RESET_V3IO_STREAMS_ERROR - }), - resetV3ioStreamShardLagsError: () => ({ - type: RESET_V3IO_STREAM_SHARD_LAG_ERROR - }) -} - -export default nuclioActions diff --git a/src/actions/projects.js b/src/actions/projects.js deleted file mode 100644 index e2f5fbc895..0000000000 --- a/src/actions/projects.js +++ /dev/null @@ -1,664 +0,0 @@ -/* -Copyright 2019 Iguazio Systems Ltd. - -Licensed under the Apache License, Version 2.0 (the "License") with -an addition restriction as set forth herein. You may not use this -file except in compliance with the License. You may obtain a copy of -the License at http://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -implied. See the License for the specific language governing -permissions and limitations under the License. - -In addition, you may not use the software for any purposes that are -illegal under applicable law, and the grant of the foregoing license -under the Apache 2.0 license is conditioned upon your compliance with -such restriction. -*/ -import projectsApi from '../api/projects-api' -import workflowsApi from '../api/workflow-api' -import { - CHANGE_PROJECT_STATE_BEGIN, - CHANGE_PROJECT_STATE_FAILURE, - CHANGE_PROJECT_STATE_SUCCESS, - CREATE_PROJECT_BEGIN, - CREATE_PROJECT_FAILURE, - CREATE_PROJECT_SUCCESS, - DELETE_PROJECT_BEGIN, - DELETE_PROJECT_FAILURE, - DELETE_PROJECT_SUCCESS, - FETCH_PROJECT_BEGIN, - FETCH_PROJECT_SUMMARY_BEGIN, - FETCH_PROJECT_SUMMARY_FAILURE, - FETCH_PROJECT_SUMMARY_SUCCESS, - FETCH_PROJECT_DATASETS_BEGIN, - FETCH_PROJECT_DATASETS_FAILURE, - FETCH_PROJECT_DATASETS_SUCCESS, - FETCH_PROJECT_FAILED_JOBS_BEGIN, - FETCH_PROJECT_FAILED_JOBS_FAILURE, - FETCH_PROJECT_FAILED_JOBS_SUCCESS, - FETCH_PROJECT_FAILURE, - FETCH_PROJECT_FEATURE_SETS_BEGIN, - FETCH_PROJECT_FEATURE_SETS_FAILURE, - FETCH_PROJECT_FEATURE_SETS_SUCCESS, - FETCH_PROJECT_FILES_BEGIN, - FETCH_PROJECT_FILES_FAILURE, - FETCH_PROJECT_FILES_SUCCESS, - FETCH_PROJECT_FUNCTIONS_BEGIN, - FETCH_PROJECT_FUNCTIONS_FAILURE, - FETCH_PROJECT_FUNCTIONS_SUCCESS, - FETCH_PROJECT_JOBS_BEGIN, - FETCH_PROJECT_JOBS_FAILURE, - FETCH_PROJECT_JOBS_SUCCESS, - FETCH_PROJECT_MODELS_BEGIN, - FETCH_PROJECT_MODELS_FAILURE, - FETCH_PROJECT_MODELS_SUCCESS, - FETCH_PROJECT_RUNNING_JOBS_BEGIN, - FETCH_PROJECT_RUNNING_JOBS_FAILURE, - FETCH_PROJECT_RUNNING_JOBS_SUCCESS, - FETCH_PROJECT_SCHEDULED_JOBS_BEGIN, - FETCH_PROJECT_SCHEDULED_JOBS_FAILURE, - FETCH_PROJECT_SCHEDULED_JOBS_SUCCESS, - FETCH_PROJECT_SUCCESS, - FETCH_PROJECTS_SUMMARY_BEGIN, - FETCH_PROJECTS_SUMMARY_FAILURE, - FETCH_PROJECTS_SUMMARY_SUCCESS, - FETCH_PROJECT_WORKFLOWS_BEGIN, - FETCH_PROJECT_WORKFLOWS_FAILURE, - FETCH_PROJECT_WORKFLOWS_SUCCESS, - FETCH_PROJECTS_BEGIN, - FETCH_PROJECTS_FAILURE, - FETCH_PROJECTS_SUCCESS, - REMOVE_NEW_PROJECT_ERROR, - REMOVE_PROJECT_SUMMARY, - REMOVE_PROJECT_DATA, - REMOVE_PROJECTS, - FETCH_PROJECTS_NAMES_BEGIN, - FETCH_PROJECTS_NAMES_FAILURE, - FETCH_PROJECTS_NAMES_SUCCESS, - FETCH_PROJECT_SECRETS_BEGIN, - FETCH_PROJECT_SECRETS_FAILURE, - FETCH_PROJECT_SECRETS_SUCCESS, - PROJECT_ONLINE_STATUS, - SET_JOBS_MONITORING_DATA, - SET_MLRUN_IS_UNHEALTHY, - SET_MLRUN_UNHEALTHY_RETRYING, - REQUEST_CANCELED, - DEFAULT_ABORT_MSG, - SET_DELETING_PROJECTS -} from '../constants' -import { - CONFLICT_ERROR_STATUS_CODE, - INTERNAL_SERVER_ERROR_STATUS_CODE, - FORBIDDEN_ERROR_STATUS_CODE -} from 'igz-controls/constants' - -import { parseSummaryData } from '../utils/parseSummaryData' -import { showErrorNotification } from '../utils/notifications.util' -import { mlrunUnhealthyErrors } from '../components/ProjectsPage/projects.util' -import { parseProjects } from '../utils/parseProjects' - -let firstServerErrorTimestamp = null - -const projectsAction = { - changeProjectState: (project, status) => dispatch => { - dispatch(projectsAction.changeProjectStateBegin()) - - return projectsApi - .changeProjectState(project, status) - .then(() => dispatch(projectsAction.changeProjectStateSuccess())) - .catch(error => { - dispatch(projectsAction.changeProjectStateFailure()) - throw error - }) - }, - changeProjectStateBegin: () => ({ type: CHANGE_PROJECT_STATE_BEGIN }), - changeProjectStateFailure: () => ({ type: CHANGE_PROJECT_STATE_FAILURE }), - changeProjectStateSuccess: () => ({ type: CHANGE_PROJECT_STATE_SUCCESS }), - createNewProject: postData => dispatch => { - dispatch(projectsAction.createProjectBegin()) - - return projectsApi - .createProject(postData) - .then(result => { - dispatch(projectsAction.createProjectSuccess()) - - return result.data - }) - .catch(error => { - const message = - error.response?.status === CONFLICT_ERROR_STATUS_CODE - ? `A project named "${postData.metadata.name}" already exists.` - : error.response?.status === FORBIDDEN_ERROR_STATUS_CODE - ? 'You don’t have permission to create a project.' - : error.response?.status === INTERNAL_SERVER_ERROR_STATUS_CODE - ? error.response.data?.detail || - 'The system already has the maximum number of projects. An existing project must be deleted before you can create another.' - : error.message - - dispatch(projectsAction.createProjectFailure(message)) - }) - }, - createProjectBegin: () => ({ type: CREATE_PROJECT_BEGIN }), - createProjectFailure: error => ({ - type: CREATE_PROJECT_FAILURE, - payload: error - }), - createProjectSuccess: () => ({ type: CREATE_PROJECT_SUCCESS }), - deleteProject: (projectName, deleteNonEmpty) => dispatch => { - dispatch(projectsAction.deleteProjectBegin(projectName)) - - return projectsApi - .deleteProject(projectName, deleteNonEmpty) - .then(response => { - dispatch(projectsAction.deleteProjectSuccess(projectName)) - - return response - }) - .catch(error => { - dispatch(projectsAction.deleteProjectFailure(projectName)) - - throw error - }) - }, - deleteProjectBegin: (projectName) => ({ - type: DELETE_PROJECT_BEGIN, - payload: projectName - }), - deleteProjectFailure: (projectName) => ({ - type: DELETE_PROJECT_FAILURE, - payload: projectName - }), - deleteProjectSuccess: (projectName) => ({ - type: DELETE_PROJECT_SUCCESS, - payload: projectName - }), - fetchProject: (project, params, signal) => dispatch => { - dispatch(projectsAction.fetchProjectBegin()) - - return projectsApi - .getProject(project, params, signal) - .then(response => { - dispatch(projectsAction.fetchProjectSuccess(response?.data)) - return response - }) - .catch(error => { - if (![REQUEST_CANCELED, DEFAULT_ABORT_MSG].includes(error.message)) { - dispatch(projectsAction.fetchProjectFailure(error)) - - throw error - } - }) - }, - fetchProjectBegin: () => ({ type: FETCH_PROJECT_BEGIN }), - fetchProjectFailure: error => ({ - type: FETCH_PROJECT_FAILURE, - payload: error - }), - fetchProjectSuccess: project => ({ - type: FETCH_PROJECT_SUCCESS, - payload: project - }), - fetchProjectDataSets: project => dispatch => { - dispatch(projectsAction.fetchProjectDataSetsBegin()) - - return projectsApi - .getProjectDataSets(project) - .then(response => { - dispatch(projectsAction.fetchProjectDataSetsSuccess(response?.data.artifacts)) - - return response?.data.artifacts - }) - .catch(error => { - dispatch(projectsAction.fetchProjectDataSetsFailure(error.message)) - - throw error.message - }) - }, - fetchProjectDataSetsBegin: () => ({ type: FETCH_PROJECT_DATASETS_BEGIN }), - fetchProjectDataSetsFailure: error => ({ - type: FETCH_PROJECT_DATASETS_FAILURE, - payload: error - }), - fetchProjectDataSetsSuccess: datasets => ({ - type: FETCH_PROJECT_DATASETS_SUCCESS, - payload: datasets - }), - fetchProjectFailedJobs: (project, signal) => dispatch => { - dispatch(projectsAction.fetchProjectFailedJobsBegin()) - - return projectsApi - .getProjectFailedJobs(project, signal) - .then(response => { - dispatch(projectsAction.fetchProjectFailedJobsSuccess(response?.data.runs)) - - return response?.data.runs - }) - .catch(error => { - dispatch(projectsAction.fetchProjectFailedJobsFailure(error.message)) - - throw error.message - }) - }, - fetchProjectFailedJobsBegin: () => ({ - type: FETCH_PROJECT_FAILED_JOBS_BEGIN - }), - fetchProjectFailedJobsFailure: error => ({ - type: FETCH_PROJECT_FAILED_JOBS_FAILURE, - payload: error - }), - fetchProjectFailedJobsSuccess: jobs => ({ - type: FETCH_PROJECT_FAILED_JOBS_SUCCESS, - payload: jobs - }), - fetchProjectFiles: project => dispatch => { - dispatch(projectsAction.fetchProjectFilesBegin()) - - projectsApi - .getProjectFiles(project) - .then(response => { - dispatch(projectsAction.fetchProjectFilesSuccess(response?.data.artifacts)) - }) - .catch(error => { - dispatch(projectsAction.fetchProjectFilesFailure(error.message)) - }) - }, - fetchProjectFeatureSets: (project, signal) => dispatch => { - dispatch(projectsAction.fetchProjectFeatureSetsBegin()) - - return projectsApi - .getProjectFeatureSets(project, signal) - .then(response => { - dispatch(projectsAction.fetchProjectFeatureSetsSuccess(response.data?.feature_sets)) - - return response.data?.feature_sets - }) - .catch(error => { - dispatch(projectsAction.fetchProjectFeatureSetsFailure(error.message)) - - throw error.message - }) - }, - fetchProjectFeatureSetsBegin: () => ({ - type: FETCH_PROJECT_FEATURE_SETS_BEGIN - }), - fetchProjectFeatureSetsFailure: error => ({ - type: FETCH_PROJECT_FEATURE_SETS_FAILURE, - payload: error - }), - fetchProjectFeatureSetsSuccess: featureSets => ({ - type: FETCH_PROJECT_FEATURE_SETS_SUCCESS, - payload: featureSets - }), - fetchProjectFilesBegin: () => ({ type: FETCH_PROJECT_FILES_BEGIN }), - fetchProjectFilesFailure: error => ({ - type: FETCH_PROJECT_FILES_FAILURE, - payload: error - }), - fetchProjectFilesSuccess: files => ({ - type: FETCH_PROJECT_FILES_SUCCESS, - payload: files - }), - fetchProjectFunctions: (project, signal) => dispatch => { - dispatch(projectsAction.fetchProjectFunctionsBegin()) - - return projectsApi - .getProjectFunctions(project, signal) - .then(response => { - dispatch(projectsAction.fetchProjectFunctionsSuccess(response?.data.funcs)) - - return response?.data.funcs - }) - .catch(error => { - dispatch(projectsAction.fetchProjectFunctionsFailure(error.message)) - - throw error.message - }) - }, - fetchProjectFunctionsBegin: () => ({ type: FETCH_PROJECT_FUNCTIONS_BEGIN }), - fetchProjectFunctionsFailure: error => ({ - type: FETCH_PROJECT_FUNCTIONS_FAILURE, - payload: error - }), - fetchProjectFunctionsSuccess: functions => ({ - type: FETCH_PROJECT_FUNCTIONS_SUCCESS, - payload: functions - }), - fetchProjectJobs: (project, startTimeFrom, signal) => dispatch => { - dispatch(projectsAction.fetchProjectJobsBegin()) - - const params = { - 'partition-by': 'name', - 'partition-sort-by': 'updated', - 'rows-per-partition': '5', - 'max-partitions': '5', - iter: 'false', - start_time_from: startTimeFrom - } - - return projectsApi - .getJobsAndWorkflows(project, params, signal) - .then(response => { - dispatch( - projectsAction.fetchProjectJobsSuccess( - response?.data.runs.filter(job => job.metadata.iteration === 0) - ) - ) - - return response?.data.runs - }) - .catch(error => { - dispatch(projectsAction.fetchProjectJobsFailure(error.message)) - }) - }, - fetchProjectJobsBegin: () => ({ type: FETCH_PROJECT_JOBS_BEGIN }), - fetchProjectJobsFailure: error => ({ - type: FETCH_PROJECT_JOBS_FAILURE, - payload: error - }), - fetchProjectJobsSuccess: jobs => ({ - type: FETCH_PROJECT_JOBS_SUCCESS, - payload: jobs - }), - fetchProjectModels: (project, signal) => dispatch => { - dispatch(projectsAction.fetchProjectModelsBegin()) - - return projectsApi - .getProjectModels(project, signal) - .then(response => { - dispatch(projectsAction.fetchProjectModelsSuccess(response?.data.artifacts)) - - return response?.data.artifacts - }) - .catch(error => { - dispatch(projectsAction.fetchProjectModelsFailure(error.message)) - - throw error.message - }) - }, - fetchProjectModelsBegin: () => ({ type: FETCH_PROJECT_MODELS_BEGIN }), - fetchProjectModelsFailure: error => ({ - type: FETCH_PROJECT_MODELS_FAILURE, - payload: error - }), - fetchProjectModelsSuccess: models => ({ - type: FETCH_PROJECT_MODELS_SUCCESS, - payload: models - }), - fetchProjectRunningJobs: (project, signal) => dispatch => { - dispatch(projectsAction.fetchProjectRunningJobsBegin()) - - return projectsApi - .getProjectRunningJobs(project, signal) - .then(response => { - dispatch(projectsAction.fetchProjectRunningJobsSuccess(response?.data.runs)) - - return response?.data.runs - }) - .catch(error => { - dispatch(projectsAction.fetchProjectRunningJobsFailure(error.message)) - - throw error.message - }) - }, - fetchProjectRunningJobsBegin: () => ({ - type: FETCH_PROJECT_RUNNING_JOBS_BEGIN - }), - fetchProjectRunningJobsFailure: error => ({ - type: FETCH_PROJECT_RUNNING_JOBS_FAILURE, - payload: error - }), - fetchProjectRunningJobsSuccess: jobs => ({ - type: FETCH_PROJECT_RUNNING_JOBS_SUCCESS, - payload: jobs - }), - fetchProjectScheduledJobs: project => dispatch => { - dispatch(projectsAction.fetchProjectScheduledJobsBegin()) - - return projectsApi - .getProjectScheduledJobs(project) - .then(response => { - dispatch(projectsAction.fetchProjectScheduledJobsSuccess(response.data.schedules)) - - return response.data.schedules - }) - .catch(error => { - dispatch(projectsAction.fetchProjectScheduledJobsFailure(error.message)) - - throw error.message - }) - }, - fetchProjectScheduledJobsBegin: () => ({ - type: FETCH_PROJECT_SCHEDULED_JOBS_BEGIN - }), - fetchProjectScheduledJobsFailure: error => ({ - type: FETCH_PROJECT_SCHEDULED_JOBS_FAILURE, - payload: error - }), - fetchProjectScheduledJobsSuccess: jobs => ({ - type: FETCH_PROJECT_SCHEDULED_JOBS_SUCCESS, - payload: jobs - }), - fetchProjectSecrets: project => dispatch => { - dispatch(projectsAction.fetchProjectSecretsBegin()) - - return projectsApi - .getProjectSecrets(project) - .then(response => { - dispatch(projectsAction.fetchProjectSecretsSuccess(response.data)) - }) - .catch(error => { - dispatch(projectsAction.fetchProjectSecretsFailure(error.message)) - - throw error - }) - }, - fetchProjectSecretsBegin: () => ({ - type: FETCH_PROJECT_SECRETS_BEGIN - }), - fetchProjectSecretsFailure: error => ({ - type: FETCH_PROJECT_SECRETS_FAILURE, - payload: error - }), - fetchProjectSecretsSuccess: secrets => ({ - type: FETCH_PROJECT_SECRETS_SUCCESS, - payload: secrets - }), - fetchProjectSummary: (project, signal) => dispatch => { - dispatch(projectsAction.fetchProjectSummaryBegin()) - - return projectsApi - .getProjectSummary(project, signal) - .then(({ data }) => { - return dispatch(projectsAction.fetchProjectSummarySuccess(parseSummaryData(data))) - }) - .catch(error => { - if (![REQUEST_CANCELED, DEFAULT_ABORT_MSG].includes(error.message)) { - dispatch(projectsAction.fetchProjectSummaryFailure(error.message)) - - throw error - } - }) - }, - fetchProjectSummaryBegin: () => ({ - type: FETCH_PROJECT_SUMMARY_BEGIN - }), - fetchProjectSummaryFailure: error => ({ - type: FETCH_PROJECT_SUMMARY_FAILURE, - payload: error - }), - fetchProjectSummarySuccess: summary => ({ - type: FETCH_PROJECT_SUMMARY_SUCCESS, - payload: summary - }), - fetchProjects: - (params, setRequestErrorMessage = () => {}) => - dispatch => { - dispatch(projectsAction.fetchProjectsBegin()) - setRequestErrorMessage('') - - return projectsApi - .getProjects(params) - .then(response => { - const parsedProjects = parseProjects(response.data.projects) - - dispatch(projectsAction.fetchProjectsSuccess(parsedProjects)) - dispatch( - projectsAction.fetchProjectsNamesSuccess( - parsedProjects - .filter(project => project.status.state === PROJECT_ONLINE_STATUS) - .map(project => project.metadata.name) - ) - ) - - return parsedProjects - }) - .catch(error => { - dispatch(projectsAction.fetchProjectsFailure(error), dispatch) - showErrorNotification( - dispatch, - error, - 'Failed to fetch projects', - null, - null, - setRequestErrorMessage - ) - }) - }, - fetchProjectsBegin: () => ({ type: FETCH_PROJECTS_BEGIN }), - fetchProjectsFailure: error => ({ - type: FETCH_PROJECTS_FAILURE, - payload: error - }), - fetchProjectsNames: () => dispatch => { - dispatch(projectsAction.fetchProjectsNamesBegin()) - - return projectsApi - .getProjects({ format: 'name_only', state: PROJECT_ONLINE_STATUS }) - .then(({ data: { projects } }) => { - dispatch(projectsAction.fetchProjectsNamesSuccess(projects)) - - return projects - }) - .catch(error => { - dispatch(projectsAction.fetchProjectsNamesFailure(error)) - showErrorNotification(dispatch, error, '', 'Failed to fetch projects') - }) - }, - fetchProjectsNamesBegin: () => ({ type: FETCH_PROJECTS_NAMES_BEGIN }), - fetchProjectsNamesFailure: error => ({ - type: FETCH_PROJECTS_NAMES_FAILURE, - payload: error - }), - fetchProjectsNamesSuccess: summary => ({ - type: FETCH_PROJECTS_NAMES_SUCCESS, - payload: summary - }), - fetchProjectsSuccess: projectsList => ({ - type: FETCH_PROJECTS_SUCCESS, - payload: projectsList - }), - fetchProjectsSummary: (signal, refresh) => dispatch => { - dispatch(projectsAction.fetchProjectsSummaryBegin()) - - return projectsApi - .getProjectSummaries(signal) - .then(({ data: { project_summaries } }) => { - if (firstServerErrorTimestamp && refresh) { - firstServerErrorTimestamp = null - - refresh() - } - - const summaryData = parseSummaryData(project_summaries) - - dispatch(projectsAction.fetchProjectsSummarySuccess(summaryData)) - dispatch(projectsAction.setMlrunIsUnhealthy(false)) - dispatch(projectsAction.setMlrunUnhealthyRetrying(false)) - - return summaryData - }) - .catch(err => { - if (mlrunUnhealthyErrors.includes(err.response?.status)) { - if (!firstServerErrorTimestamp) { - firstServerErrorTimestamp = new Date() - - dispatch(projectsAction.setMlrunUnhealthyRetrying(true)) - } - - const threeMinutesPassed = (new Date() - firstServerErrorTimestamp) / 1000 > 180 - - if (!threeMinutesPassed) { - setTimeout(() => { - dispatch(projectsAction.fetchProjectsSummary(signal, refresh)) - }, 3000) - } - - if (threeMinutesPassed) { - dispatch(projectsAction.setMlrunIsUnhealthy(true)) - dispatch(projectsAction.setMlrunUnhealthyRetrying(true)) - } - } - - dispatch(projectsAction.fetchProjectsSummaryFailure(err)) - }) - }, - fetchProjectsSummaryBegin: () => ({ type: FETCH_PROJECTS_SUMMARY_BEGIN }), - fetchProjectsSummaryFailure: error => ({ - type: FETCH_PROJECTS_SUMMARY_FAILURE, - payload: error - }), - fetchProjectsSummarySuccess: summary => ({ - type: FETCH_PROJECTS_SUMMARY_SUCCESS, - payload: summary - }), - fetchProjectWorkflows: project => dispatch => { - dispatch(projectsAction.fetchProjectWorkflowsBegin()) - - return workflowsApi - .getWorkflows(project) - .then(response => { - dispatch(projectsAction.fetchProjectWorkflowsSuccess(response.data.runs)) - - return response.data.runs - }) - .catch(error => { - dispatch(projectsAction.fetchProjectWorkflowsFailure(error.message)) - }) - }, - fetchProjectWorkflowsBegin: () => ({ - type: FETCH_PROJECT_WORKFLOWS_BEGIN - }), - fetchProjectWorkflowsFailure: error => ({ - type: FETCH_PROJECT_WORKFLOWS_FAILURE, - payload: error - }), - fetchProjectWorkflowsSuccess: workflows => ({ - type: FETCH_PROJECT_WORKFLOWS_SUCCESS, - payload: workflows - }), - removeNewProjectError: () => ({ type: REMOVE_NEW_PROJECT_ERROR }), - removeProjectData: () => ({ type: REMOVE_PROJECT_DATA }), - removeProjectSummary: () => ({ type: REMOVE_PROJECT_SUMMARY }), - removeProjects: () => ({ type: REMOVE_PROJECTS }), - setDeletingProjects: data => ({ - type: SET_DELETING_PROJECTS, - payload: data - }), - setMlrunIsUnhealthy: isUnhealthy => ({ - type: SET_MLRUN_IS_UNHEALTHY, - payload: isUnhealthy - }), - setMlrunUnhealthyRetrying: isRetrying => ({ - type: SET_MLRUN_UNHEALTHY_RETRYING, - payload: isRetrying - }), - setJobsMonitoringData: data => ({ - type: SET_JOBS_MONITORING_DATA, - payload: data - }) -} - -export default projectsAction diff --git a/src/common/Breadcrumbs/Breadcrumbs.js b/src/common/Breadcrumbs/Breadcrumbs.js index 86933c50d5..a9087d2431 100755 --- a/src/common/Breadcrumbs/Breadcrumbs.js +++ b/src/common/Breadcrumbs/Breadcrumbs.js @@ -17,17 +17,16 @@ illegal under applicable law, and the grant of the foregoing license under the Apache 2.0 license is conditioned upon your compliance with such restriction. */ -import React, { useEffect, useMemo, useRef, useState } from 'react' +import React, { useMemo, useRef, useState } from 'react' import PropTypes from 'prop-types' import { useLocation, useParams } from 'react-router-dom' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import BreadcrumbsStep from './BreadcrumbsStep/BreadcrumbsStep' import { useMode } from '../../hooks/mode.hook' import { generateMlrunScreens, generateTabsList } from './breadcrumbs.util' import { PROJECTS_PAGE_PATH } from '../../constants' -import projectsAction from '../../actions/projects' import { generateProjectsList } from '../../utils/projects' import './breadcrumbs.scss' @@ -38,7 +37,6 @@ const Breadcrumbs = ({ onClick = () => {} }) => { const [showProjectsList, setShowProjectsList] = useState(false) const { isDemoMode } = useMode() const breadcrumbsRef = useRef() - const dispatch = useDispatch() const params = useParams() const location = useLocation() @@ -82,16 +80,6 @@ const Breadcrumbs = ({ onClick = () => {} }) => { } }, [location.pathname, params.projectName, mlrunScreens, projectTabs]) - useEffect(() => { - if ( - projectsList.length === 0 && - location.pathname !== '/projects' && - !location.pathname.startsWith('/projects/*') - ) { - dispatch(projectsAction.fetchProjects({ format: 'minimal' })) - } - }, [dispatch, location.pathname, projectsList.length]) - return (