Skip to content

Commit

Permalink
fixed side effect for label
Browse files Browse the repository at this point in the history
  • Loading branch information
YuliaKrimerman committed Dec 19, 2024
1 parent 0c9dff7 commit 2dadc96
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion frontend/src/api/modelRegistry/__tests__/custom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('createModelVersionForRegisteredModel', () => {
state: ModelState.LIVE,
customProperties: {},
}),
).toBe(mockResultPromise);
).toEqual(mockResultPromise);
expect(proxyCREATEMock).toHaveBeenCalledTimes(1);
expect(proxyCREATEMock).toHaveBeenCalledWith(
'hostPath',
Expand Down
35 changes: 16 additions & 19 deletions frontend/src/api/modelRegistry/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
ModelVersion,
RegisteredModelList,
RegisteredModel,
ModelRegistryMetadataType,
} from '~/concepts/modelRegistry/types';
import { MODEL_REGISTRY_API_VERSION } from '~/concepts/modelRegistry/const';
import { bumpRegisteredModelTimestamp } from '~/concepts/modelRegistry/utils/updateTimestamps';
import { proxyCREATE, proxyGET, proxyPATCH } from '~/api/proxyUtils';
import { K8sAPIOptions } from '~/k8sTypes';
import { MODEL_REGISTRY_API_VERSION } from '~/concepts/modelRegistry/const';
import { handleModelRegistryFailures } from './errorUtils';

export const createRegisteredModel =
Expand Down Expand Up @@ -47,7 +47,6 @@ export const createModelVersionForRegisteredModel =
registeredModelId: string,
data: CreateModelVersionData,
): Promise<ModelVersion> => {
// First create the version
const newVersion = await handleModelRegistryFailures<ModelVersion>(
proxyCREATE(
hostpath,
Expand All @@ -58,22 +57,20 @@ export const createModelVersionForRegisteredModel =
),
);

const currentTime = new Date().toISOString();
await handleModelRegistryFailures<RegisteredModel>(
proxyPATCH(
hostpath,
`/api/model_registry/${MODEL_REGISTRY_API_VERSION}/registered_models/${registeredModelId}`,
{
state: 'LIVE',
customProperties: {
_lastModified: {
metadataType: ModelRegistryMetadataType.STRING,
stringValue: currentTime,
},
},
},
opts,
),
// Use the established timestamp update utility
await bumpRegisteredModelTimestamp(
{
patchRegisteredModel: (apiOpts, patchData, id) =>
handleModelRegistryFailures(
proxyPATCH(
hostpath,
`/api/model_registry/${MODEL_REGISTRY_API_VERSION}/registered_models/${id}`,
patchData,
apiOpts,
),
),
},
registeredModelId,
);

return newVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
ModelRegistryMetadataType,
} from '~/concepts/modelRegistry/types';

type MinimalModelRegistryAPI = Pick<ModelRegistryAPIs, 'patchRegisteredModel'>;

export const bumpModelVersionTimestamp = async (
api: ModelRegistryAPIs,
modelVersionId: string,
Expand All @@ -24,7 +26,7 @@ export const bumpModelVersionTimestamp = async (
};

export const bumpRegisteredModelTimestamp = async (
api: ModelRegistryAPIs,
api: MinimalModelRegistryAPI,
registeredModelId: string,
): Promise<void> => {
if (!registeredModelId) {
Expand Down

0 comments on commit 2dadc96

Please sign in to comment.