Skip to content

Commit

Permalink
Improve the doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryshao committed Jan 6, 2025
1 parent 5e4102f commit 8573e52
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void linkModelVersion(
NameIdentifier modelFullIdent = modelFullNameIdentifier(ident);
BaseResponse resp =
restClient.post(
formatModelVersionRequestPath(modelFullIdent),
formatModelVersionRequestPath(modelFullIdent) + "/versions",
req,
BaseResponse.class,
Collections.emptyMap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ public void testLinkModelVersion() throws JsonProcessingException {
String modelVersionPath =
withSlash(
GenericModelCatalog.formatModelVersionRequestPath(
NameIdentifier.of(METALAKE_NAME, CATALOG_NAME, "schema1", "model1")));
NameIdentifier.of(METALAKE_NAME, CATALOG_NAME, "schema1", "model1"))
+ "/versions");

ModelVersionLinkRequest request =
new ModelVersionLinkRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def link_model_version(
request.validate()

resp = self.rest_client.post(
f"{self._format_model_version_request_path(model_full_ident)}",
f"{self._format_model_version_request_path(model_full_ident)}/versions",
request,
error_handler=MODEL_ERROR_HANDLER,
)
Expand Down
8 changes: 4 additions & 4 deletions docs/manage-model-metadata-using-gravitino.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ same.

### Register a model

You can create a model by sending a `POST` request to the `/api/metalakes/{metalake_name}
You can register a model by sending a `POST` request to the `/api/metalakes/{metalake_name}
/catalogs/{catalog_name}/schemas/{schema_name}/models` endpoint or just use the Gravitino
Java/Python client. The following is an example of creating a model:

Expand Down Expand Up @@ -345,7 +345,7 @@ Note that the delete operation will delete all the model versions under this mod
### List models

You can list all the models in a schema by sending a `GET` request to the `/api/metalakes/
{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/moldes` endpoint or by using the
{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models` endpoint or by using the
Gravitino Java/Python client. The following is an example of listing all the models in a schema:

<Tabs groupId="language" queryString>
Expand Down Expand Up @@ -390,7 +390,7 @@ model_list = catalog.as_model_catalog().list_models(namespace=Namespace.of("mode
### Link a ModelVersion

You can link a ModelVersion by sending a `POST` request to the `/api/metalakes/{metalake_name}
/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}` endpoint or by using
/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}/versions` endpoint or by using
the Gravitino Java/Python client. The following is an example of linking a ModelVersion:

<Tabs groupId="language" queryString>
Expand All @@ -405,7 +405,7 @@ curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
"properties": {
"k1": "v1"
}
}' http://localhost:8090/api/metalakes/example/catalogs/model_catalog/schemas/model_schema/models/example_model
}' http://localhost:8090/api/metalakes/example/catalogs/model_catalog/schemas/model_schema/models/example_model/versions
```

</TabItem>
Expand Down
54 changes: 27 additions & 27 deletions docs/open-api/models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,33 @@ paths:
"5xx":
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

/metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/models/{model}/versions:
parameters:
- $ref: "./openapi.yaml#/components/parameters/metalake"
- $ref: "./openapi.yaml#/components/parameters/catalog"
- $ref: "./openapi.yaml#/components/parameters/schema"
- $ref: "./openapi.yaml#/components/parameters/model"

get:
tags:
- model
summary: List model versions
operationId: listModelVersions
responses:
"200":
$ref: "#/components/responses/ModelVersionListResponse"
"404":
description: Not Found - The target model does not exist
content:
application/vnd.gravitino.v1+json:
schema:
$ref: "./openapi.yaml#/components/schemas/ErrorModel"
examples:
NoSuchModelException:
$ref: "#/components/examples/NoSuchModelException"
"5xx":
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

post:
tags:
- model
Expand Down Expand Up @@ -159,33 +186,6 @@ paths:
"5xx":
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

/metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/models/{model}/versions:
parameters:
- $ref: "./openapi.yaml#/components/parameters/metalake"
- $ref: "./openapi.yaml#/components/parameters/catalog"
- $ref: "./openapi.yaml#/components/parameters/schema"
- $ref: "./openapi.yaml#/components/parameters/model"

get:
tags:
- model
summary: List model versions
operationId: listModelVersions
responses:
"200":
$ref: "#/components/responses/ModelVersionListResponse"
"404":
description: Not Found - The target model does not exist
content:
application/vnd.gravitino.v1+json:
schema:
$ref: "./openapi.yaml#/components/schemas/ErrorModel"
examples:
NoSuchModelException:
$ref: "#/components/examples/NoSuchModelException"
"5xx":
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"

/metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/models/{model}/versions/{version}:
parameters:
- $ref: "./openapi.yaml#/components/parameters/metalake"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public Response getModelVersionByAlias(
}

@POST
@Path("{model}")
@Path("{model}/versions")
@Produces("application/vnd.gravitino.v1+json")
@Timed(name = "link-model-version." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
@ResponseMetered(name = "link-model-version", absolute = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ public void testLinkModelVersion() {
Response resp =
target(modelPath())
.path("model1")
.path("versions")
.request(MediaType.APPLICATION_JSON_TYPE)
.accept("application/vnd.gravitino.v1+json")
.post(Entity.entity(req, MediaType.APPLICATION_JSON_TYPE));
Expand All @@ -619,6 +620,7 @@ public void testLinkModelVersion() {
Response resp1 =
target(modelPath())
.path("model1")
.path("versions")
.request(MediaType.APPLICATION_JSON_TYPE)
.accept("application/vnd.gravitino.v1+json")
.post(Entity.entity(req, MediaType.APPLICATION_JSON_TYPE));
Expand All @@ -637,6 +639,7 @@ public void testLinkModelVersion() {
Response resp2 =
target(modelPath())
.path("model1")
.path("versions")
.request(MediaType.APPLICATION_JSON_TYPE)
.accept("application/vnd.gravitino.v1+json")
.post(Entity.entity(req, MediaType.APPLICATION_JSON_TYPE));
Expand All @@ -656,6 +659,7 @@ public void testLinkModelVersion() {
Response resp3 =
target(modelPath())
.path("model1")
.path("versions")
.request(MediaType.APPLICATION_JSON_TYPE)
.accept("application/vnd.gravitino.v1+json")
.post(Entity.entity(req, MediaType.APPLICATION_JSON_TYPE));
Expand Down
2 changes: 1 addition & 1 deletion web/web/src/lib/api/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Apis = {
LINK_VERSION: ({ metalake, catalog, schema, model }) =>
`/api/metalakes/${encodeURIComponent(metalake)}/catalogs/${encodeURIComponent(
catalog
)}/schemas/${encodeURIComponent(schema)}/models/${encodeURIComponent(model)}`,
)}/schemas/${encodeURIComponent(schema)}/models/${encodeURIComponent(model)}/versions`,
DELETE_VERSION: ({ metalake, catalog, schema, model, version }) => {
return `/api/metalakes/${encodeURIComponent(metalake)}/catalogs/${encodeURIComponent(
catalog
Expand Down

0 comments on commit 8573e52

Please sign in to comment.