Skip to content

Commit

Permalink
OAS: add generic artifacts routes (#406)
Browse files Browse the repository at this point in the history
* OAS: add generic artifacts routes

Signed-off-by: Isabella do Amaral <[email protected]>

* OAS: make discriminator explicit as model prop

Signed-off-by: Isabella do Amaral <[email protected]>

* update existing artifact with custom helper

Signed-off-by: Isabella do Amaral <[email protected]>

---------

Signed-off-by: Isabella do Amaral <[email protected]>
  • Loading branch information
isinyaaa authored Sep 25, 2024
1 parent 3110d1b commit 0d77878
Show file tree
Hide file tree
Showing 37 changed files with 4,719 additions and 261 deletions.
209 changes: 187 additions & 22 deletions api/openapi/model-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,129 @@ servers:
- url: "https://localhost:8080"
- url: "http://localhost:8080"
paths:
/api/model_registry/v1alpha3/artifact:
summary: Path used to search for an artifact.
description: >-
The REST endpoint/path used to search for an `Artifact` entity. This path contains a `GET` operation to perform the find task.
get:
tags:
- ModelRegistryService
responses:
"200":
$ref: "#/components/responses/ArtifactResponse"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
operationId: findArtifact
summary: Get an Artifact that matches search parameters.
description: Gets the details of a single instance of an `Artifact` that matches search parameters.
parameters:
- $ref: "#/components/parameters/name"
- $ref: "#/components/parameters/externalId"
- $ref: "#/components/parameters/parentResourceId"
/api/model_registry/v1alpha3/artifacts:
summary: Path used to manage the list of artifacts.
description: >-
The REST endpoint/path used to list and create zero or more `Artifact` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively.
get:
tags:
- ModelRegistryService
parameters:
- $ref: "#/components/parameters/pageSize"
- $ref: "#/components/parameters/orderBy"
- $ref: "#/components/parameters/sortOrder"
- $ref: "#/components/parameters/nextPageToken"
responses:
"200":
$ref: "#/components/responses/ArtifactListResponse"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
operationId: getArtifacts
summary: List All Artifacts
description: Gets a list of all `Artifact` entities.
post:
requestBody:
description: A new `Artifact` to be created.
content:
application/json:
schema:
$ref: "#/components/schemas/ArtifactCreate"
required: true
tags:
- ModelRegistryService
responses:
"201":
$ref: "#/components/responses/ArtifactResponse"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"500":
$ref: "#/components/responses/InternalServerError"
operationId: createArtifact
summary: Create an Artifact
description: Creates a new instance of an `Artifact`.
/api/model_registry/v1alpha3/artifacts/{id}:
summary: Path used to manage a single Artifact.
description: >-
The REST endpoint/path used to get and update single instances of an `Artifact`. This path contains `GET` and `PATCH` operations used to perform the get and update tasks, respectively.
get:
tags:
- ModelRegistryService
responses:
"200":
$ref: "#/components/responses/ArtifactResponse"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
operationId: getArtifact
summary: Get an Artifact
description: Gets the details of a single instance of an `Artifact`.
patch:
requestBody:
description: Updated `Artifact` information.
content:
application/json:
schema:
$ref: "#/components/schemas/ArtifactUpdate"
required: true
tags:
- ModelRegistryService
responses:
"200":
$ref: "#/components/responses/ArtifactResponse"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
operationId: updateArtifact
summary: Update an Artifact
description: Updates an existing `Artifact`.
parameters:
- name: id
description: A unique identifier for an `Artifact`.
schema:
type: string
in: path
required: true
/api/model_registry/v1alpha3/model_artifact:
summary: Path used to search for a modelartifact.
description: >-
Expand Down Expand Up @@ -991,15 +1114,36 @@ components:
default: "doc-artifact"
allOf:
- $ref: "#/components/schemas/BaseArtifact"
- $ref: "#/components/schemas/DocArtifactCreate"
DocArtifactCreate:
description: A document artifact to be created.
type: object
required:
- artifactType
properties:
artifactType:
type: string
default: "doc-artifact"
allOf:
- $ref: "#/components/schemas/BaseArtifactCreate"
- $ref: "#/components/schemas/DocArtifactUpdate"
DocArtifactUpdate:
description: A document artifact to be updated.
required:
- artifactType
properties:
artifactType:
type: string
default: "doc-artifact"
allOf:
- $ref: "#/components/schemas/BaseArtifactUpdate"
RegisteredModel:
description: A registered model in model registry. A registered model has ModelVersion children.
allOf:
- $ref: "#/components/schemas/BaseResource"
- type: object
- $ref: "#/components/schemas/RegisteredModelCreate"
ModelVersionList:
description: List of ModelVersion entities.
type: object
allOf:
- type: object
properties:
Expand All @@ -1011,7 +1155,6 @@ components:
- $ref: "#/components/schemas/BaseResourceList"
ModelArtifactList:
description: List of ModelArtifact entities.
type: object
allOf:
- type: object
properties:
Expand All @@ -1026,9 +1169,9 @@ components:
required:
- name
allOf:
- type: object
- $ref: "#/components/schemas/BaseResourceCreate"
- $ref: "#/components/schemas/RegisteredModelUpdate"
- type: object
properties:
name:
description: |-
Expand Down Expand Up @@ -1098,12 +1241,10 @@ components:
BaseExecution:
allOf:
- $ref: "#/components/schemas/BaseExecutionCreate"
- type: object
- $ref: "#/components/schemas/BaseResource"
BaseExecutionCreate:
allOf:
- $ref: "#/components/schemas/BaseExecutionUpdate"
- type: object
- $ref: "#/components/schemas/BaseResourceCreate"
BaseExecutionUpdate:
type: object
Expand Down Expand Up @@ -1286,7 +1427,6 @@ components:
type: integer
ArtifactList:
description: A list of Artifact entities.
type: object
allOf:
- type: object
properties:
Expand All @@ -1297,7 +1437,13 @@ components:
$ref: "#/components/schemas/Artifact"
- $ref: "#/components/schemas/BaseResourceList"
ModelArtifactUpdate:
description: An ML model artifact.
description: An ML model artifact to be updated.
required:
- artifactType
properties:
artifactType:
type: string
default: "model-artifact"
allOf:
- $ref: "#/components/schemas/BaseArtifactUpdate"
- type: object
Expand All @@ -1319,7 +1465,12 @@ components:
type: string
ModelArtifactCreate:
description: An ML model artifact.
type: object
required:
- artifactType
properties:
artifactType:
type: string
default: "model-artifact"
allOf:
- $ref: "#/components/schemas/BaseArtifactCreate"
- $ref: "#/components/schemas/ModelArtifactUpdate"
Expand Down Expand Up @@ -1363,9 +1514,28 @@ components:
allOf:
- $ref: "#/components/schemas/BaseArtifactCreate"
- $ref: "#/components/schemas/BaseResource"
ArtifactCreate:
description: An Artifact to be created.
oneOf:
- $ref: "#/components/schemas/ModelArtifactCreate"
- $ref: "#/components/schemas/DocArtifactCreate"
discriminator:
propertyName: artifactType
mapping:
model-artifact: "#/components/schemas/ModelArtifactCreate"
doc-artifact: "#/components/schemas/DocArtifactCreate"
ArtifactUpdate:
description: An Artifact to be updated.
oneOf:
- $ref: "#/components/schemas/ModelArtifactUpdate"
- $ref: "#/components/schemas/DocArtifactUpdate"
discriminator:
propertyName: artifactType
mapping:
model-artifact: "#/components/schemas/ModelArtifactUpdate"
doc-artifact: "#/components/schemas/DocArtifactUpdate"
ServingEnvironmentList:
description: List of ServingEnvironments.
type: object
allOf:
- type: object
properties:
Expand All @@ -1378,7 +1548,6 @@ components:
- $ref: "#/components/schemas/BaseResourceList"
RegisteredModelList:
description: List of RegisteredModels.
type: object
allOf:
- type: object
properties:
Expand All @@ -1402,7 +1571,6 @@ components:
ServingEnvironmentCreate:
description: A Model Serving environment for serving `RegisteredModels`.
allOf:
- type: object
- $ref: "#/components/schemas/BaseResourceCreate"
- $ref: "#/components/schemas/ServingEnvironmentUpdate"
InferenceService:
Expand All @@ -1413,7 +1581,6 @@ components:
- $ref: "#/components/schemas/InferenceServiceCreate"
InferenceServiceList:
description: List of InferenceServices.
type: object
allOf:
- type: object
properties:
Expand All @@ -1426,7 +1593,6 @@ components:
- $ref: "#/components/schemas/BaseResourceList"
ServeModelList:
description: List of ServeModel entities.
type: object
allOf:
- type: object
properties:
Expand All @@ -1438,7 +1604,6 @@ components:
- $ref: "#/components/schemas/BaseResourceList"
ServeModel:
description: An ML model serving action.
type: object
allOf:
- $ref: "#/components/schemas/BaseExecution"
- $ref: "#/components/schemas/ServeModelCreate"
Expand All @@ -1448,12 +1613,12 @@ components:
- $ref: "#/components/schemas/BaseExecutionUpdate"
ServeModelCreate:
description: An ML model serving action.
required:
- modelVersionId
allOf:
- $ref: "#/components/schemas/BaseExecutionCreate"
- $ref: "#/components/schemas/ServeModelUpdate"
- required:
- modelVersionId
type: object
- type: object
properties:
modelVersionId:
description: ID of the `ModelVersion` that was served in `InferenceService`.
Expand All @@ -1477,13 +1642,13 @@ components:
InferenceServiceCreate:
description: >-
An `InferenceService` entity in a `ServingEnvironment` represents a deployed `ModelVersion` from a `RegisteredModel` created by Model Serving.
required:
- registeredModelId
- servingEnvironmentId
allOf:
- $ref: "#/components/schemas/BaseResourceCreate"
- $ref: "#/components/schemas/InferenceServiceUpdate"
- required:
- registeredModelId
- servingEnvironmentId
type: object
- type: object
properties:
registeredModelId:
description: ID of the `RegisteredModel` to serve.
Expand Down
4 changes: 4 additions & 0 deletions clients/python/src/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ mr_openapi/configuration.py
mr_openapi/exceptions.py
mr_openapi/models/__init__.py
mr_openapi/models/artifact.py
mr_openapi/models/artifact_create.py
mr_openapi/models/artifact_list.py
mr_openapi/models/artifact_state.py
mr_openapi/models/artifact_update.py
mr_openapi/models/base_artifact.py
mr_openapi/models/base_artifact_create.py
mr_openapi/models/base_artifact_update.py
Expand All @@ -20,6 +22,8 @@ mr_openapi/models/base_resource_create.py
mr_openapi/models/base_resource_list.py
mr_openapi/models/base_resource_update.py
mr_openapi/models/doc_artifact.py
mr_openapi/models/doc_artifact_create.py
mr_openapi/models/doc_artifact_update.py
mr_openapi/models/error.py
mr_openapi/models/execution_state.py
mr_openapi/models/inference_service.py
Expand Down
2 changes: 2 additions & 0 deletions clients/python/src/model_registry/types/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def create(self, **kwargs) -> ModelArtifactCreate:
return ModelArtifactCreate(
customProperties=self._map_custom_properties(),
**self._props_as_dict(exclude=("id", "custom_properties")),
artifactType="model-artifact",
**kwargs,
)

Expand All @@ -161,6 +162,7 @@ def update(self, **kwargs) -> ModelArtifactUpdate:
return ModelArtifactUpdate(
customProperties=self._map_custom_properties(),
**self._props_as_dict(exclude=("id", "name", "custom_properties")),
artifactType="model-artifact",
**kwargs,
)

Expand Down
Loading

0 comments on commit 0d77878

Please sign in to comment.