Skip to content

Commit

Permalink
Merge pull request #2448 from opendatahub-io/f/pipelines-v2
Browse files Browse the repository at this point in the history
[RHOAIENG-331] Pipelines v2 API Parity
  • Loading branch information
openshift-merge-bot[bot] authored Mar 11, 2024
2 parents c37a3b1 + f332e5d commit 0231f8d
Show file tree
Hide file tree
Showing 245 changed files with 8,433 additions and 3,505 deletions.
7 changes: 1 addition & 6 deletions backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type DashboardConfig = K8sResourceCommon & {
disableKServe: boolean;
disableModelMesh: boolean;
disableAcceleratorProfiles: boolean;
disablePipelineExperiments: boolean;
};
groupsConfig?: {
adminGroups: string;
Expand All @@ -53,12 +54,6 @@ export type DashboardConfig = K8sResourceCommon & {
templateOrder?: string[];
templateDisablement?: string[];
};
/** Faux status object -- will be replaced in the long run by a Dashboard Controller */
status: {
dependencyOperators: {
redhatOpenshiftPipelines: OperatorStatus;
};
};
};

export type ModelServerSize = {
Expand Down
9 changes: 1 addition & 8 deletions backend/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const blankDashboardCR: DashboardConfig = {
disableKServe: false,
disableModelMesh: false,
disableAcceleratorProfiles: false,
disablePipelineExperiments: true,
},
notebookController: {
enabled: true,
Expand All @@ -69,14 +70,6 @@ export const blankDashboardCR: DashboardConfig = {
templateOrder: [],
// templateDisablement: [], Don't create this field, will be used in migration
},
status: {
dependencyOperators: {
redhatOpenshiftPipelines: {
available: false,
queriedForStatus: false,
},
},
},
};

export const MOUNT_PATH = '/opt/app-root/src';
Expand Down
53 changes: 1 addition & 52 deletions backend/src/utils/resourceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,36 +56,10 @@ let buildsWatcher: ResourceWatcher<BuildStatus>;
let consoleLinksWatcher: ResourceWatcher<ConsoleLinkKind>;
let quickStartWatcher: ResourceWatcher<QuickStart>;

const fetchOperatorExistence = async (
fastify: KubeFastifyInstance,
operatorNamePrefix: string,
): Promise<boolean> => {
const operators: K8sResourceCommon[] = await fastify.kube.customObjectsApi
.listNamespacedCustomObject(
'operators.coreos.com',
'v1alpha1',
'openshift-operators',
'clusterserviceversions',
)
.then((resp) => {
const listObj = resp.body as K8sResourceCommon & { items?: K8sResourceCommon[] };

return listObj.items ?? [];
})
.catch((e) => {
fastify.log.warn(`Received error (${e.body.message}) fetching operators.`);
return [];
});

return !!operators.find((o) => o.metadata.name.startsWith(operatorNamePrefix));
};

const fetchDashboardCR = async (fastify: KubeFastifyInstance): Promise<DashboardConfig[]> => {
const dashboardName = process.env['DASHBOARD_CONFIG'] || dashboardConfigMapName;
return fetchOrCreateDashboardCR(fastify, dashboardName).then((dashboardCR) => {
return manageOperatorStatus(fastify, dashboardCR).then((dashboardCR) => {
return migrateTemplateDisablement(fastify, dashboardCR).then((dashboardCR) => [dashboardCR]);
});
return migrateTemplateDisablement(fastify, dashboardCR).then((dashboardCR) => [dashboardCR]);
});
};

Expand Down Expand Up @@ -128,31 +102,6 @@ const fetchOrCreateDashboardCR = async (
});
};

const manageOperatorStatus = async (
fastify: KubeFastifyInstance,
dashboardConfig: DashboardConfig,
): Promise<DashboardConfig> => {
if (dashboardConfig.spec.dashboardConfig.disablePipelines === false) {
fastify.log.info('Pipelines feature enabled, computing operator state...');
return fetchOperatorExistence(fastify, 'openshift-pipelines-operator-rh').then((exists) => {
fastify.log.info(`Pipeline Operator status: ${exists}`);
return _.merge({}, dashboardConfig, {
status: {
...dashboardConfig.status,
dependencyOperators: {
redhatOpenshiftPipelines: {
queriedForStatus: true,
available: exists,
},
},
},
});
});
}

return dashboardConfig;
};

const createDashboardCR = (fastify: KubeFastifyInstance): Promise<DashboardConfig> => {
return fastify.kube.customObjectsApi
.createNamespacedCustomObject(
Expand Down
2 changes: 2 additions & 0 deletions docs/dashboard-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ spec:
modelMetricsNamespace: ''
disableBiasMetrics: false
disablePerformanceMetrics: false
disablePipelineExperiments: false
```
## Additional fields
Expand Down Expand Up @@ -148,6 +149,7 @@ spec:
modelMetricsNamespace: ''
disableBiasMetrics: false
disablePerformanceMetrics: false
disablePipelineExperiments: true
notebookController:
enabled: true
gpuSetting: autodetect
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/__mocks__/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export * from './mockDashboardConfig';
export * from './mockDataSciencePipelinesApplicationK8sResource';
export * from './mockK8sResourceList';
export * from './mockProjectK8sResource';
export * from './mockRouteK8sResource';
export * from './mockStatus';
export * from './mockRunKF';
export * from './mockJobKF';
export * from './mockExperimentKF';
export * from './mockPipelineVersionsProxy';
export * from './mockPipelinesProxy';
export * from './mockDscStatus';
export * from './mockNotebookK8sResource';
export * from './mockPipelineKF';
export * from './mockSecretK8sResource';
11 changes: 3 additions & 8 deletions frontend/src/__mocks__/mockDashboardConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type MockDashboardConfigType = {
disableAcceleratorProfiles?: boolean;
disablePerformanceMetrics?: boolean;
disableBiasMetrics?: boolean;
disablePipelineExperiments?: boolean;
disableDistributedWorkloads?: boolean;
};

Expand All @@ -39,6 +40,7 @@ export const mockDashboardConfig = ({
disableAcceleratorProfiles = false,
disablePerformanceMetrics = false,
disableBiasMetrics = false,
disablePipelineExperiments = true,
disableDistributedWorkloads = false,
}: MockDashboardConfigType): DashboardConfigKind => ({
apiVersion: 'opendatahub.io/v1alpha',
Expand Down Expand Up @@ -71,6 +73,7 @@ export const mockDashboardConfig = ({
disableKServe,
disableModelMesh,
disableAcceleratorProfiles,
disablePipelineExperiments,
disableDistributedWorkloads,
},
notebookController: {
Expand Down Expand Up @@ -197,12 +200,4 @@ export const mockDashboardConfig = ({
templateOrder: ['test-model'],
templateDisablement: ['test-model'],
},
status: {
dependencyOperators: {
redhatOpenshiftPipelines: {
available: !disablePipelines,
queriedForStatus: false,
},
},
},
});
10 changes: 5 additions & 5 deletions frontend/src/__mocks__/mockDataConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export const mockDataConnection = ({
},
data: {
[AwsKeys.NAME]: name,
AWS_ACCESS_KEY_ID: 'c2RzZA==',
AWS_DEFAULT_REGION: 'us-east-1',
AWS_S3_BUCKET: s3Bucket,
AWS_S3_ENDPOINT: 'http://aws.com',
AWS_SECRET_ACCESS_KEY: 'aHR0cHM6Ly9zMy5hbWF6b25hd3MuY29tLw==',
[AwsKeys.ACCESS_KEY_ID]: 'c2RzZA==',
[AwsKeys.DEFAULT_REGION]: 'us-east-1',
[AwsKeys.AWS_S3_BUCKET]: s3Bucket,
[AwsKeys.S3_ENDPOINT]: 'http://aws.com',
[AwsKeys.SECRET_ACCESS_KEY]: 'aHR0cHM6Ly9zMy5hbWF6b25hd3MuY29tLw==',
},
type: 'Opaque',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import { DSPipelineKind } from '~/k8sTypes';

type MockResourceConfigType = {
name?: string;
namespace?: string;
dspVersion?: string;
displayName?: string;
initializing?: boolean;
dspaSecretName?: string;
};

export const mockDataSciencePipelineApplicationK8sResource = ({
namespace = 'test-project',
dspVersion = 'v2',
initializing = false,
dspaSecretName = 'aws-connection-testdb',
}: MockResourceConfigType): DSPipelineKind => ({
apiVersion: 'datasciencepipelinesapplications.opendatahub.io/v1alpha1',
kind: 'DataSciencePipelinesApplication',
metadata: {
name: 'pipelines-definition',
name: 'dspa',
namespace,
},
spec: {
dspVersion,
apiServer: {
enableSamplePipeline: false,
},
Expand All @@ -31,6 +33,7 @@ export const mockDataSciencePipelineApplicationK8sResource = ({
},
objectStorage: {
externalStorage: {
region: 'us-east-2',
bucket: 'test-pipelines-bucket',
host: 's3.amazonaws.com',
port: '',
Expand Down
25 changes: 25 additions & 0 deletions frontend/src/__mocks__/mockExperimentKF.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* eslint-disable camelcase */
import { ExperimentKFv2, StorageStateKF } from '~/concepts/pipelines/kfTypes';

export const buildMockExperimentKF = (experiment?: Partial<ExperimentKFv2>): ExperimentKFv2 => ({
experiment_id: 'a9947051-ead5-480c-acca-fd26ae14b81b',
display_name: 'Default',
description: 'All runs created without specifying an experiment will be grouped here.',
created_at: '2024-01-31T15:46:33Z',
storage_state: StorageStateKF.AVAILABLE,
...experiment,
});

export const buildMockExperiments = (
experiments: ExperimentKFv2[] = [buildMockExperimentKF()],
totalSize?: number,
nextPageToken?: string,
): {
total_size?: number | undefined;
next_page_token?: string | undefined;
experiments: ExperimentKFv2[];
} => ({
experiments,
total_size: totalSize || experiments.length,
next_page_token: nextPageToken,
});
46 changes: 26 additions & 20 deletions frontend/src/__mocks__/mockJobKF.ts

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion frontend/src/__mocks__/mockPipelineKF.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
/* eslint-disable camelcase */
import { PipelineKF, RelationshipKF, ResourceTypeKF } from '~/concepts/pipelines/kfTypes';
import {
PipelineKF,
PipelineKFv2,
RelationshipKF,
ResourceTypeKF,
} from '~/concepts/pipelines/kfTypes';

type MockResourceConfigType = {
name?: string;
id?: string;
};

/**
* @deprecated use buildMockPipelineV2 instead
*/
export const mockPipelineKF = ({
name = 'test-pipeline',
id = 'test-pipeline',
Expand All @@ -30,3 +38,14 @@ export const mockPipelineKF = ({
],
},
});

export const mockPipelineKFv2 = ({
name = 'test-pipeline',
id = 'test-pipeline',
}: MockResourceConfigType): PipelineKFv2 => ({
pipeline_id: id,
created_at: '2023-11-23T17:16:37Z',
display_name: name,
description:
'[source code](https://github.com/opendatahub-io/data-science-pipelines/tree/master/samples/flip-coin) A conditional pipeline to flip coins based on a random number generator.',
});
Loading

0 comments on commit 0231f8d

Please sign in to comment.