Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup deprecated usage of gpu #2182

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KubeFastifyInstance, AcceleratorKind } from '../../../types';
import { KubeFastifyInstance, AcceleratorProfileKind } from '../../../types';
import { FastifyRequest } from 'fastify';
import createError from 'http-errors';
import { translateDisplayNameForK8s } from '../../../utils/resourceUtils';
Expand All @@ -9,9 +9,9 @@ export const postAcceleratorProfile = async (
): Promise<{ success: boolean; error: string }> => {
const customObjectsApi = fastify.kube.customObjectsApi;
const namespace = fastify.kube.namespace;
const body = request.body as AcceleratorKind['spec'];
const body = request.body as AcceleratorProfileKind['spec'];

const payload: AcceleratorKind = {
const payload: AcceleratorProfileKind = {
apiVersion: 'dashboard.opendatahub.io/v1',
kind: 'AcceleratorProfile',
metadata: {
Expand Down Expand Up @@ -83,7 +83,7 @@ export const updateAcceleratorProfile = async (
const customObjectsApi = fastify.kube.customObjectsApi;
const namespace = fastify.kube.namespace;
const params = request.params as { acceleratorProfileName: string };
const body = request.body as Partial<AcceleratorKind['spec']>;
const body = request.body as Partial<AcceleratorProfileKind['spec']>;

try {
const currentProfile = await customObjectsApi
Expand All @@ -94,7 +94,7 @@ export const updateAcceleratorProfile = async (
'acceleratorprofiles',
params.acceleratorProfileName,
)
.then((r) => r.body as AcceleratorKind)
.then((r) => r.body as AcceleratorProfileKind)
.catch((e) => {
throw createError(e.statusCode, e?.body?.message);
});
Expand Down
8 changes: 4 additions & 4 deletions backend/src/routes/api/accelerators/acceleratorUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AcceleratorInfo, KubeFastifyInstance } from '../../../types';
import { DetectedAccelerators, KubeFastifyInstance } from '../../../types';

const RESOURCE_TYPES = [
'cpu',
Expand All @@ -19,13 +19,13 @@ const getIdentifiersFromResources = (resources: { [key: string]: string } = {})
}, {});
};

export const getAcceleratorNumbers = async (
export const getDetectedAccelerators = async (
fastify: KubeFastifyInstance,
): Promise<AcceleratorInfo> =>
): Promise<DetectedAccelerators> =>
fastify.kube.coreV1Api
.listNode()
.then((res) =>
res.body.items.reduce<AcceleratorInfo>(
res.body.items.reduce<DetectedAccelerators>(
(info, node) => {
// reduce resources down to just the accelerators and their counts
const allocatable = getIdentifiersFromResources(node.status.allocatable);
Expand Down
4 changes: 2 additions & 2 deletions backend/src/routes/api/accelerators/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { KubeFastifyInstance, OauthFastifyRequest } from '../../../types';
import { getAcceleratorNumbers } from './acceleratorUtils';
import { getDetectedAccelerators } from './acceleratorUtils';
import { logRequestDetails } from '../../../utils/fileUtils';

export default async (fastify: KubeFastifyInstance): Promise<void> => {
fastify.get('/', async (request: OauthFastifyRequest) => {
logRequestDetails(fastify, request);

return getAcceleratorNumbers(fastify);
return getDetectedAccelerators(fastify);
});
};
184 changes: 0 additions & 184 deletions backend/src/routes/api/gpu/gpuUtils.ts

This file was deleted.

14 changes: 0 additions & 14 deletions backend/src/routes/api/gpu/index.ts

This file was deleted.

56 changes: 26 additions & 30 deletions backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,6 @@ export type NotebookPort = {
protocol: string;
};

export type NotebookToleration = {
effect: string;
key: string;
operator: string;
};

export type VolumeMount = { mountPath: string; name: string };

type EnvFrom = {
Expand Down Expand Up @@ -432,7 +426,7 @@ export type Notebook = K8sResourceCommon & {
enableServiceLinks?: boolean;
containers: NotebookContainer[];
volumes?: Volume[];
tolerations?: NotebookToleration[];
tolerations?: Toleration[];
};
};
};
Expand Down Expand Up @@ -706,11 +700,6 @@ export type RecursivePartial<T> = {
[P in keyof T]?: RecursivePartial<T[P]>;
};

export type GPUScaleType = {
type: 'nvidia.com/gpu' | 'amd.com/gpu';
min: number;
max: number;
};

export type MachineAutoscaler = {
spec: {
Expand Down Expand Up @@ -742,18 +731,8 @@ export type MachineSetList = {
items: MachineSet[];
} & K8sResourceCommon;

export type gpuScale = {
availableScale: number;
gpuNumber: number;
};

export type GPUInfo = {
configured: boolean;
available: number;
autoscalers: gpuScale[];
};

export type AcceleratorInfo = {
export type DetectedAccelerators = {
configured: boolean;
available: { [key: string]: number };
total: { [key: string]: number };
Expand Down Expand Up @@ -810,19 +789,17 @@ export type NotebookData = {
notebookSizeName: string;
imageName: string;
imageTagName: string;
accelerator: AcceleratorState;
acceleratorProfile: AcceleratorProfileState;
envVars: EnvVarReducedTypeKeyValues;
state: NotebookState;
username?: string;
};

export type AcceleratorState = {
accelerator?: AcceleratorKind;
export type AcceleratorProfileState = {
acceleratorProfile?: AcceleratorProfileKind;
count: number;
};

export const LIMIT_NOTEBOOK_IMAGE_GPU = 'nvidia.com/gpu';

type DisplayNameAnnotations = Partial<{
'openshift.io/description': string; // the description provided by the user
'openshift.io/display-name': string; // the name provided by the user
Expand Down Expand Up @@ -920,7 +897,26 @@ export type ServingRuntime = K8sResourceCommon & {
};
};

export type AcceleratorKind = K8sResourceCommon & {
export enum TolerationOperator {
EXISTS = 'Exists',
EQUAL = 'Equal',
}

export enum TolerationEffect {
NO_SCHEDULE = 'NoSchedule',
PREFER_NO_SCHEDULE = 'PreferNoSchedule',
NO_EXECUTE = 'NoExecute',
}

export type Toleration = {
key: string;
operator?: TolerationOperator;
value?: string;
effect?: TolerationEffect;
tolerationSeconds?: number;
};

export type AcceleratorProfileKind = K8sResourceCommon & {
metadata: {
name: string;
annotations?: Partial<{
Expand All @@ -932,7 +928,7 @@ export type AcceleratorKind = K8sResourceCommon & {
enabled: boolean;
identifier: string;
description?: string;
tolerations?: NotebookToleration[];
tolerations?: Toleration[];
};
};

Expand Down
Loading
Loading