jerryshao commented on code in PR #6921:
URL: https://github.com/apache/gravitino/pull/6921#discussion_r2053396609


##########
docs/manage-model-metadata-using-gravitino.md:
##########
@@ -302,6 +302,116 @@ 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
+cat <<EOF >model.json
+{
+  "updates": [
+    {
+      "@type": "updateComment",
+      "newComment": "Updated model comment"
+    },
+    {
+      "@type": "rename",
+      "newName": "new_name"
+    },
+    {
+      "@type": "setProperty",
+      "property": "k2",
+      "value": "v2"
+    },
+    {
+      "@type": "removeProperty",
+      "property": "k1"
+    }
+  ]
+}
+EOF
+ 
+curl -X PUT \
+  -H "Accept: application/vnd.gravitino.v1+json" \
+  -H "Content-Type: application/json" \
+  -d '@model.json' \
+  
http://localhost:8090/api/metalakes/mymetalake/catalogs/mycatalog/schemas/myschema/models/mymodel
+ ```
+
+
+ </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
+client = GravitinoClient(uri="http://localhost:8090";, 
+                         metalake_name="mymetalake")
+
+catalog = client.load_catalog(name="mycatalog").as_model_catalog()
+
+# Define modifications
+changes = (
+    ModelChange.update_comment("Updated model comment"),
+    ModelChange.rename("renamed"),
+    ModelChange.set_property("k2", "v2"),
+    ModelChange.remove_property("k1"),
+)
+
+# Apply changes
+updated_model = model_catalog.alter_model(
+    ident=NameIdentifier.of("myschema", "mymodel"), *changes
+)
+ ```
+ </TabItem>
+ </Tabs>
+
+#### Supported modifications
+
+The following operations are supported for altering a model:
+
+
+| Operation               | JSON Example                                       
                          | Java Method                               | Python 
Method                         |
+ 
|-------------------------|------------------------------------------------------------------------------|-------------------------------------------|---------------------------------------|
+| **Rename model**        | `{"@type":"rename","newName":"new_name"}`          
                          | `ModelChange.rename("new_name")`         | 
`ModelChange.rename("new_name")`      |
+| **Update comment**      | 
`{"@type":"updateComment","newComment":"new_comment"}`                       | 
`ModelChange.updateComment("new_comment")` | 
`ModelChange.update_comment("new_comment")` |

Review Comment:
   We haven't supported update comment for now, please remove this. We should 
align the doc with the code.



-- 
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]

Reply via email to