From a8b1d88ee127cf1f943fd5dabaf436e758f0393c Mon Sep 17 00:00:00 2001 From: Robert Sun <107655677+rsun19@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:20:07 -0400 Subject: [PATCH] deleted dead code in second pass --- frontend/src/api/trustyai/k8s.ts | 10 +--- frontend/src/api/trustyai/rawTypes.ts | 4 -- .../codeEditor/useCodeEditorAsLogs.tsx | 52 ------------------- .../context/useModelRegistryNamespaceCR.ts | 4 +- .../pipelines/content/tables/utils.ts | 18 +------ frontend/src/concepts/topology/utils.ts | 3 -- .../src/pages/modelServing/screens/const.ts | 6 --- .../modelServing/screens/metrics/const.ts | 20 ------- frontend/src/pages/modelServing/utils.ts | 6 --- .../global/experiments/artifacts/utils.ts | 11 ---- frontend/src/types.ts | 27 ---------- 11 files changed, 5 insertions(+), 156 deletions(-) delete mode 100644 frontend/src/concepts/dashboard/codeEditor/useCodeEditorAsLogs.tsx diff --git a/frontend/src/api/trustyai/k8s.ts b/frontend/src/api/trustyai/k8s.ts index d5bf175eda..91bd5b9e4d 100644 --- a/frontend/src/api/trustyai/k8s.ts +++ b/frontend/src/api/trustyai/k8s.ts @@ -4,9 +4,8 @@ import { k8sGetResource, K8sStatus, } from '@openshift/dynamic-plugin-sdk-utils'; -import { K8sAPIOptions, RouteKind, TrustyAIKind } from '~/k8sTypes'; -import { getRoute } from '~/api'; -import { TRUSTYAI_DEFINITION_NAME, TRUSTYAI_ROUTE_NAME } from '~/concepts/trustyai/const'; +import { K8sAPIOptions, TrustyAIKind } from '~/k8sTypes'; +import { TRUSTYAI_DEFINITION_NAME } from '~/concepts/trustyai/const'; import { applyK8sAPIOptions } from '~/api/apiMergeUtils'; import { TrustyAIApplicationsModel } from '~/api/models/trustyai'; @@ -25,11 +24,6 @@ const trustyAIDefaultCRSpec: TrustyAIKind['spec'] = { }, }; -export const getTrustyAIAPIRoute = async ( - namespace: string, - opts?: K8sAPIOptions, -): Promise => getRoute(TRUSTYAI_ROUTE_NAME, namespace, opts); - export const getTrustyAICR = async ( namespace: string, opts?: K8sAPIOptions, diff --git a/frontend/src/api/trustyai/rawTypes.ts b/frontend/src/api/trustyai/rawTypes.ts index 7732250d33..00b6588f89 100644 --- a/frontend/src/api/trustyai/rawTypes.ts +++ b/frontend/src/api/trustyai/rawTypes.ts @@ -58,7 +58,3 @@ export type BaseMetricCreationResponse = { requestId: string; timestamp: string; }; - -export type BaseMetricDeletionRequest = { - requestId: string; -}; diff --git a/frontend/src/concepts/dashboard/codeEditor/useCodeEditorAsLogs.tsx b/frontend/src/concepts/dashboard/codeEditor/useCodeEditorAsLogs.tsx deleted file mode 100644 index c3f650d873..0000000000 --- a/frontend/src/concepts/dashboard/codeEditor/useCodeEditorAsLogs.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import * as React from 'react'; -import * as monacoEditor from 'monaco-editor'; -import { EditorDidMount } from 'react-monaco-editor'; -import { LOG_TAIL_LINES } from '~/concepts/pipelines/content/pipelinesDetails/pipelineRun/runLogs/const'; - -type UseCodeEditorAsLogs = { - editorOptions: monacoEditor.editor.IStandaloneEditorConstructionOptions; - onMount: EditorDidMount; - scrollToBottom: () => void; -}; - -type EditorData = { - editor: monacoEditor.editor.IStandaloneCodeEditor; - monaco: typeof monacoEditor; -}; - -const useCodeEditorAsLogs = (): UseCodeEditorAsLogs => { - const [editorData, setEditorData] = React.useState(null); - - const scrollToBottom = React.useCallback(() => { - if (!editorData) { - return; - } - - // Move the cursor back to the start / unselect everything - editorData.editor.setSelection(new editorData.monaco.Selection(0, 0, 0, 0)); - - // Scroll to the bottom - editorData.editor.revealLine(editorData.editor.getModel()?.getLineCount() ?? LOG_TAIL_LINES); - }, [editorData]); - - const onMount = React.useCallback((editor, monaco) => { - setEditorData({ editor, monaco }); - }, []); - - return { - editorOptions: { - // Always wrap - wordWrap: 'on', - // Cursor on item highlights repeats -- not needed - occurrencesHighlight: false, - // Disable the selection highlight - selectionHighlight: true, - // Stop it at the last line; logs editors don't usually go past that - scrollBeyondLastLine: false, - }, - scrollToBottom, - onMount, - }; -}; - -export default useCodeEditorAsLogs; diff --git a/frontend/src/concepts/modelRegistry/context/useModelRegistryNamespaceCR.ts b/frontend/src/concepts/modelRegistry/context/useModelRegistryNamespaceCR.ts index 86b9301c21..5db9845c5c 100644 --- a/frontend/src/concepts/modelRegistry/context/useModelRegistryNamespaceCR.ts +++ b/frontend/src/concepts/modelRegistry/context/useModelRegistryNamespaceCR.ts @@ -1,7 +1,7 @@ import React from 'react'; import { getModelRegistryCR } from '~/api'; -import { SupportedArea, useIsAreaAvailable } from '~/concepts/areas'; import { ModelRegistryKind } from '~/k8sTypes'; +import useModelRegistryEnabled from '~/pages/modelRegistry/useModelRegistryEnabled'; import { FAST_POLL_INTERVAL, SERVER_TIMEOUT } from '~/utilities/const'; import useFetchState, { FetchState, @@ -18,7 +18,7 @@ export const isModelRegistryAvailable = ([state, loaded]: FetchState): bo loaded && !!state && isModelRegistryCRStatusAvailable(state); export const useModelRegistryNamespaceCR = (namespace: string, name: string): FetchState => { - const modelRegistryAreaAvailable = useIsAreaAvailable(SupportedArea.MODEL_REGISTRY).status; + const modelRegistryAreaAvailable = useModelRegistryEnabled(); const callback = React.useCallback>( (opts) => { diff --git a/frontend/src/concepts/pipelines/content/tables/utils.ts b/frontend/src/concepts/pipelines/content/tables/utils.ts index 9ae3ac0625..f495d7e870 100644 --- a/frontend/src/concepts/pipelines/content/tables/utils.ts +++ b/frontend/src/concepts/pipelines/content/tables/utils.ts @@ -1,10 +1,4 @@ -import { - PipelineRunJobKFv2, - PipelineRunKFv2, - PipelineCoreResourceKF, - ResourceTypeKF, - ResourceReferenceKF, -} from '~/concepts/pipelines/kfTypes'; +import { PipelineRunJobKFv2, PipelineRunKFv2 } from '~/concepts/pipelines/kfTypes'; export const getRunDuration = (run: PipelineRunKFv2): number => { const finishedDate = new Date(run.finished_at); @@ -17,16 +11,6 @@ export const getRunDuration = (run: PipelineRunKFv2): number => { return finishedDate.getTime() - createdDate.getTime(); }; -/** - * @deprecated - * Uses v1 api where resource references existed - */ -export const getResourceRef = ( - resource: PipelineCoreResourceKF | null | undefined, - type: ResourceTypeKF, -): ResourceReferenceKF | undefined => - resource?.resource_references?.find((ref) => ref.key.type === type); - export const getPipelineRunJobStartTime = (job: PipelineRunJobKFv2): Date | null => { const startTime = job.trigger.cron_schedule?.start_time || job.trigger.periodic_schedule?.start_time; diff --git a/frontend/src/concepts/topology/utils.ts b/frontend/src/concepts/topology/utils.ts index 006408098e..a565425322 100644 --- a/frontend/src/concepts/topology/utils.ts +++ b/frontend/src/concepts/topology/utils.ts @@ -1,11 +1,8 @@ import { DEFAULT_TASK_NODE_TYPE, RunStatus } from '@patternfly/react-topology'; -import { genRandomChars } from '~/utilities/string'; import { PipelineTask } from '~/concepts/pipelines/topology'; import { EXECUTION_TASK_NODE_TYPE, NODE_HEIGHT, NODE_WIDTH } from './const'; import { PipelineNodeModelExpanded } from './types'; -export const createNodeId = (prefix = 'node'): string => `${prefix}-${genRandomChars()}`; - export const ICON_TASK_NODE_TYPE = 'ICON_TASK_NODE'; export const ARTIFACT_NODE_WIDTH = 44; diff --git a/frontend/src/pages/modelServing/screens/const.ts b/frontend/src/pages/modelServing/screens/const.ts index 52296f778c..c11d34d2c8 100644 --- a/frontend/src/pages/modelServing/screens/const.ts +++ b/frontend/src/pages/modelServing/screens/const.ts @@ -50,9 +50,3 @@ export enum StorageKeys { DEFAULT_REGION = 'region', PATH = 'path', } - -export const STORAGE_KEYS_REQUIRED: StorageKeys[] = [ - StorageKeys.ACCESS_KEY_ID, - StorageKeys.SECRET_ACCESS_KEY, - StorageKeys.S3_ENDPOINT, -]; diff --git a/frontend/src/pages/modelServing/screens/metrics/const.ts b/frontend/src/pages/modelServing/screens/metrics/const.ts index b1d9d9343a..c2ea95f21b 100644 --- a/frontend/src/pages/modelServing/screens/metrics/const.ts +++ b/frontend/src/pages/modelServing/screens/metrics/const.ts @@ -1,4 +1,3 @@ -import { ChartThemeColor, getCustomTheme } from '@patternfly/react-charts'; import { BiasMetricType } from '~/api'; import { BiasChartConfigMap, MetricsChartTypes } from '~/pages/modelServing/screens/metrics/types'; import { ModelMetricType } from '~/pages/modelServing/screens/metrics/ModelServingMetricsContext'; @@ -26,10 +25,6 @@ export const EMPTY_BIAS_CHART_SELECTION_DESC = export const BIAS_THRESHOLD_COLOR = 'var(--pf-chart-global--danger--Color--100, #c9190b)'; export const BIAS_DOMAIN_PADDING = 0.1; -export const DEFAULT_BIAS_THRESHOLD_DELTAS: { [key in BiasMetricType]: number } = { - [BiasMetricType.SPD]: 0.1, - [BiasMetricType.DIR]: 0.2, -}; export const BIAS_CHART_CONFIGS: BiasChartConfigMap = { [BiasMetricType.SPD]: { @@ -77,18 +72,3 @@ export const BIAS_CHART_CONFIGS: BiasChartConfigMap = { }, }, }; - -const colorScale = [ - 'var(--pf-chart-color-green-300, #4cb140)', - 'var(--pf-chart-global--danger--Color--100, #c9190b)', -]; - -const themeProps = { - bar: { colorScale }, - chart: { colorScale }, - group: { colorScale }, - legend: { colorScale }, - stack: { colorScale }, -}; - -export const SUCCESS_FAIL_CHART_THEME = getCustomTheme(ChartThemeColor.default, themeProps); diff --git a/frontend/src/pages/modelServing/utils.ts b/frontend/src/pages/modelServing/utils.ts index b20f70a5d8..6eae3474d8 100644 --- a/frontend/src/pages/modelServing/utils.ts +++ b/frontend/src/pages/modelServing/utils.ts @@ -24,7 +24,6 @@ import { K8sAPIOptions, RoleBindingKind, ServingRuntimeKind, - DataScienceClusterKindStatus, InferenceServiceKind, ServiceAccountKind, } from '~/k8sTypes'; @@ -298,10 +297,5 @@ export const isModelServerEditInfoChanged = ( )) : true; -export const checkModelMeshFailureStatus = (status: DataScienceClusterKindStatus): string => - status.conditions.find( - (condition) => condition.type === 'model-meshReady' && condition.status === 'False', - )?.message || ''; - export const isModelMesh = (inferenceService: InferenceServiceKind): boolean => inferenceService.metadata.annotations?.['serving.kserve.io/deploymentMode'] === 'ModelMesh'; diff --git a/frontend/src/pages/pipelines/global/experiments/artifacts/utils.ts b/frontend/src/pages/pipelines/global/experiments/artifacts/utils.ts index 20129979d8..d371bb525f 100644 --- a/frontend/src/pages/pipelines/global/experiments/artifacts/utils.ts +++ b/frontend/src/pages/pipelines/global/experiments/artifacts/utils.ts @@ -5,14 +5,3 @@ export const getArtifactName = (artifact: Artifact.AsObject | undefined): string artifact?.name || artifact?.customPropertiesMap.find(([name]) => name === 'display_name')?.[1].stringValue || '(No name)'; - -export function buildQuery(queriesMap?: { [key: string]: string | number | undefined }): string { - const queryContent = Object.entries(queriesMap || {}) - .filter((entry): entry is [string, string | number] => entry[1] != null) - .map(([key, value]) => `${key}=${encodeURIComponent(value)}`) - .join('&'); - if (!queryContent) { - return ''; - } - return `?${queryContent}`; -} diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 2dee3d3c3e..8040e9d084 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -551,20 +551,6 @@ export type ImageInfo = { export type ImageType = 'byon' | 'jupyter' | 'other'; -export type PersistentVolumeClaim = K8sResourceCommon & { - spec: { - accessModes: string[]; - resources: { - requests: { - storage: string; - }; - }; - storageClassName?: string; - volumeMode: 'Filesystem' | 'Block'; - }; - status?: Record; // eslint-disable-line -}; - export type Volume = { name: string; emptyDir?: Record; @@ -578,19 +564,6 @@ export type Volume = { export type VolumeMount = { mountPath: string; name: string }; -/** - * @deprecated -- use K8sStatus - * Copy from partial of V1Status that will returned by the delete CoreV1Api - */ -export type DeleteStatus = { - apiVersion?: string; - code?: number; - kind?: string; - message?: string; - reason?: string; - status?: string; -}; - export type RoleBindingSubject = { kind: string; apiGroup: string;