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


##########
clients/client-python/gravitino/client/generic_model_catalog.py:
##########
@@ -0,0 +1,534 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from typing import Dict, List
+
+from gravitino.name_identifier import NameIdentifier
+from gravitino.api.catalog import Catalog
+from gravitino.api.model import Model
+from gravitino.api.model_version import ModelVersion
+from gravitino.client.base_schema_catalog import BaseSchemaCatalog
+from gravitino.client.generic_model import GenericModel
+from gravitino.client.generic_model_version import GenericModelVersion
+from gravitino.dto.audit_dto import AuditDTO
+from gravitino.dto.requests.model_register_request import ModelRegisterRequest
+from gravitino.dto.requests.model_version_link_request import 
ModelVersionLinkRequest
+from gravitino.dto.responses.base_response import BaseResponse
+from gravitino.dto.responses.drop_response import DropResponse
+from gravitino.dto.responses.entity_list_response import EntityListResponse
+from gravitino.dto.responses.model_response import ModelResponse
+from gravitino.dto.responses.model_version_list_response import 
ModelVersionListResponse
+from gravitino.dto.responses.model_vesion_response import ModelVersionResponse
+from gravitino.exceptions.base import NoSuchModelException, 
NoSuchModelVersionException
+from gravitino.exceptions.handlers.model_error_handler import 
MODEL_ERROR_HANDLER
+from gravitino.namespace import Namespace
+from gravitino.rest.rest_utils import encode_string
+from gravitino.utils import HTTPClient
+
+
+class GenericModelCatalog(BaseSchemaCatalog):
+    """
+    The generic model catalog is a catalog that supports model and model 
version operations,
+    for example, model register, model version link, model and model version 
list, etc.
+    A model catalog is under the metalake.
+    """
+
+    def __init__(
+        self,
+        namespace: Namespace,
+        name: str = None,
+        catalog_type: Catalog.Type = Catalog.Type.UNSUPPORTED,
+        provider: str = None,
+        comment: str = None,
+        properties: Dict[str, str] = None,
+        audit: AuditDTO = None,
+        rest_client: HTTPClient = None,
+    ):
+        super().__init__(
+            namespace,
+            name,
+            catalog_type,
+            provider,
+            comment,
+            properties,
+            audit,
+            rest_client,
+        )
+
+    def as_model_catalog(self):
+        return self
+
+    def list_models(self, namespace: Namespace) -> List[NameIdentifier]:
+        """List the models in a schema namespace from the catalog.
+
+        Args:
+            namespace: The namespace of the schema.
+
+        Raises:
+            NoSuchSchemaException: If the schema does not exist.
+
+        Returns:
+            A list of NameIdentifier of models under the given namespace.
+        """
+        self._check_model_namespace(namespace)
+
+        model_full_ns = self._model_full_namespace(namespace)
+        resp = self.rest_client.get(
+            self._format_model_request_path(model_full_ns),
+            error_handler=MODEL_ERROR_HANDLER,
+        )

Review Comment:
   I think such kind of exceptions/errors is handled by rest_client, we don't 
need to handle it here in this class.



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