tengqm commented on code in PR #6921:
URL: https://github.com/apache/gravitino/pull/6921#discussion_r2042085753
##########
docs/manage-model-metadata-using-gravitino.md:
##########
@@ -302,6 +302,110 @@ model: Model =
catalog.as_model_catalog().get_model(ident=NameIdentifier.of("mod
</TabItem>
</Tabs>
+### alter a model
+
+You can modify a model's metadata (e.g., rename, update comment, or modify
properties) by sending a `PUT` request to the
`/api/metalakes/{metalake_name}/catalogs/{catalog_name}/schemas/{schema_name}/models/{model_name}`
endpoint or using the Gravitino Java/Python client. The following is an
example of modifying a model:
+
+<Tabs groupId="language" queryString>
+ <TabItem value="shell" label="Shell">
+
+```shell
+ curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
+ -H "Content-Type: application/json" -d '{
+ "updates": [
+ {
+ "@type": "updateComment",
+ "newComment": "Updated model comment"
+ },
+ {
+ "@type": "rename",
+ "newName": "example_model_renamed"
+ },
+ {
+ "@type": "setProperty",
+ "property": "k2",
+ "value": "v2"
+ },
+ {
+ "@type": "removeProperty",
+ "property": "k1"
+ }
+ ]
+ }'
http://localhost:8090/api/metalakes/example/catalogs/model_catalog/schemas/model_schema/models/example_model
+ ```
+
+
+ </TabItem>
+ <TabItem value="java" label="Java">
+
+ ```java
+ // Load the catalog and model
+ GravitinoClient gravitinoClient = GravitinoClient
+ .builder("http://localhost:8090")
+ .withMetalake("example")
+ .build();
+
+ Catalog catalog = gravitinoClient.loadCatalog("model_catalog");
+ ModelCatalog modelCatalog = catalog.asModelCatalog();
+
+ // Define modifications
+ ModelChange[] changes = {
+ ModelChange.updateComment("Updated model comment"),
+ ModelChange.rename("example_model_renamed"),
+ ModelChange.setProperty("k2", "v2"),
+ ModelChange.removeProperty("k1")
+ };
+
+ // Apply changes
+ Model updatedModel = modelCatalog.alterModel(
+ NameIdentifier.of("model_schema", "example_model"),
+ changes
+ );
+ ```
+
+ </TabItem>
+<TabItem value="python" label="Python">
+
+ ```python
+ gravitino_client: GravitinoClient =
GravitinoClient(uri="http://localhost:8090", metalake_name="example")
+
+ catalog: Catalog = gravitino_client.load_catalog(name="model_catalog")
Review Comment:
Following the same spirit of delivering consistent, precise, readable docs,
in the docs rework effort, I have simplified all these Python code without
breaking the syntax, as exemplified in the suggestion block below.
The key revision is that we don't need explicit types for variables in
Python. This is especially true for elegant code and it is actually the beauty
of Python. There is no need to name the client as `gravitino_client`. Long
names hurts readability and maintainability. Use long names only when there is
a globally enforced style, or you have to do that to distinguish something from
others.
```suggestion
client = GravitinoClient(uri="http://localhost:8090",
metalake_name="mymetalake")
catalog = client.load_catalog(name="mycatalog")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]