hqbhoho commented on code in PR #7679: URL: https://github.com/apache/gravitino/pull/7679#discussion_r2262471065
########## clients/client-python/gravitino/client/gravitino_client_config.py: ########## @@ -0,0 +1,130 @@ +# 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 TypeVar + +from gravitino.constants.timeout import TIMEOUT + +T = TypeVar("T") + + +class GravitinoClientConfig: + """ + Configuration class for Gravitino Python client; + It encapsulates HTTP connection configurations and validates client properties. + """ + + POSITIVE_NUMBER_ERROR_MSG: str = "The value must be a positive number" + """Error message for positive number validation""" + + GRAVITINO_CLIENT_CONFIG_PREFIX: str = "client_" + """Configuration key prefix for Gravitino client config""" + + CLIENT_TIMEOUT_DEFAULT: int = TIMEOUT + """Default HTTP request timeout in seconds""" + + CLIENT_TIMEOUT: str = "client_timeout" + """Configuration key for request timeout""" Review Comment: done ########## docs/how-to-use-python-client.md: ########## @@ -32,6 +32,33 @@ pip install apache-gravitino 1. [Manage metalake using Gravitino Python API](./manage-metalake-using-gravitino.md?language=python) 2. [Manage fileset metadata using Gravitino Python API](./manage-fileset-metadata-using-gravitino.md?language=python) +#### Gravitino Python client configuration + +You can customize the Gravitino Python client with config properties like this: + +```python +gravitino_admin_client = GravitinoAdminClient( + uri="http://localhost:8090", + client_config={"client_timeout": 60}, +) +# ... + +gravitino_client = GravitinoClient( + uri="http://localhost:8090", + metalake_name="test", + client_config={"client_timeout": 60}, +) +# ... +``` + +The following are supported Python client configuration: + +| Configuration item | Description | Default value | Required | Since version | +|--------------------|----------------------------------------|---------------|----------|---------------| +| `client_timeout` | An optional client timeout in seconds. | `10` | No | 1.0.0 | + +**Note:** Invalid configuration properties will result in exceptions. Review Comment: done -- 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]
