World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#3253] improvement(python): add git pre-commit hook to client-python (#6929)
Yunchi Pang689c0e303053
diff --git a/clients/client-python/.pre-commit-config.yaml b/clients/client-python/.pre-commit-config.yamlnew file mode 100644index 0000000000..3efc883501--- /dev/null+++ b/clients/client-python/.pre-commit-config.yaml@@ -0,0 +1,25 @@+# 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.++repos:+ - repo: https://github.com/astral-sh/ruff-pre-commit+ rev: v0.3.0+ hooks:+ - id: ruff # runs the linter+ - id: ruff-format # runs the formatter++default_stages: [pre-commit]\ No newline at end of filediff --git a/clients/client-python/docs/source/conf.py b/clients/client-python/docs/source/conf.pyindex ff06cc2f23..7141577709 100644--- a/clients/client-python/docs/source/conf.py+++ b/clients/client-python/docs/source/conf.py@@ -26,11 +26,11 @@ import osimport sysimport re-sys.path.insert(0, os.path.abspath('../..'))-from gravitino.constants.version import SETUP_FILEfrom gravitino.exceptions.base import GravitinoRuntimeException+sys.path.insert(0, os.path.abspath("../.."))+VERSION_PATTERN = r"version\s*=\s*['\"]([^'\"]+)['\"]"AUTHOR_PATTERN = r"author\s*=\s*['\"]([^'\"]+)['\"]"@@ -43,15 +43,15 @@ with open(SETUP_FILE, "r", encoding="utf-8") as f:project_version = version_group.group(1)else:raise GravitinoRuntimeException("Can't find valid author info in setup.py")-+author_group = re.search(AUTHOR_PATTERN, setup_content)if author_group is not None:project_author = author_group.group(1)else:raise GravitinoRuntimeException("Can't find valid author info in setup.py")-project = 'Apache Gravitino Python Client'-copyright = '2024, Apache Software Foundation'+project = "Apache Gravitino Python Client"+copyright = "2024, Apache Software Foundation"author = project_authorrelease = project_version@@ -60,15 +60,15 @@ release = project_versionextensions = [- 'sphinx.ext.autodoc',- 'sphinx.ext.autosummary',+ "sphinx.ext.autodoc",+ "sphinx.ext.autosummary",]-templates_path = ['_templates']+templates_path = ["_templates"]exclude_patterns = []# -- Options for HTML output -------------------------------------------------# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output-html_theme = 'furo'-html_static_path = ['_static']+html_theme = "furo"+html_static_path = ["_static"]diff --git a/clients/client-python/gravitino/__init__.py b/clients/client-python/gravitino/__init__.pyindex c9f4aac347..63ccaacf73 100644--- a/clients/client-python/gravitino/__init__.py+++ b/clients/client-python/gravitino/__init__.py@@ -26,3 +26,17 @@ from gravitino.client.gravitino_admin_client import GravitinoAdminClientfrom gravitino.client.gravitino_metalake import GravitinoMetalakefrom gravitino.name_identifier import NameIdentifierfrom gravitino.filesystem import gvfs++__all__ = [+ "Catalog",+ "Schema",+ "Fileset",+ "FilesetChange",+ "MetalakeChange",+ "SchemaChange",+ "GravitinoClient",+ "GravitinoAdminClient",+ "GravitinoMetalake",+ "NameIdentifier",+ "gvfs",+]diff --git a/clients/client-python/gravitino/api/catalog.py b/clients/client-python/gravitino/api/catalog.pyindex babf0421b8..8a28dedb3f 100644--- a/clients/client-python/gravitino/api/catalog.py+++ b/clients/client-python/gravitino/api/catalog.py@@ -147,7 +147,7 @@ class Catalog(Auditable):"Catalog does not support schema operations")- def as_table_catalog(self) -> "TableCatalog":+ def as_table_catalog(self) -> "TableCatalog": # noqa: F821"""Raises:UnsupportedOperationException if the catalog does not support table operations.@@ -157,7 +157,7 @@ class Catalog(Auditable):"""raise UnsupportedOperationException("Catalog does not support table operations")- def as_fileset_catalog(self) -> "FilesetCatalog":+ def as_fileset_catalog(self) -> "FilesetCatalog": # noqa: F821"""Raises:UnsupportedOperationException if the catalog does not support fileset operations.@@ -169,7 +169,7 @@ class Catalog(Auditable):"Catalog does not support fileset operations")- def as_topic_catalog(self) -> "TopicCatalog":+ def as_topic_catalog(self) -> "TopicCatalog": # noqa: F821"""Returns:the {@link TopicCatalog} if the catalog supports topic operations.@@ -179,7 +179,7 @@ class Catalog(Auditable):"""raise UnsupportedOperationException("Catalog does not support topic operations")- def as_model_catalog(self) -> "ModelCatalog":+ def as_model_catalog(self) -> "ModelCatalog": # noqa: F821"""Returns:the {@link ModelCatalog} if the catalog supports model operations.diff --git a/clients/client-python/gravitino/api/expressions/partitions/partitions.py b/clients/client-python/gravitino/api/expressions/partitions/partitions.pyindex 6cb4b4a472..c116b3bdcb 100644--- a/clients/client-python/gravitino/api/expressions/partitions/partitions.py+++ b/clients/client-python/gravitino/api/expressions/partitions/partitions.py@@ -177,7 +177,7 @@ class ListPartitionImpl(ListPartition):return hash((self._name,- tuple(tuple(l) for l in self._lists),+ tuple(tuple(sublist) for sublist in self._lists),frozenset(self._properties.items()),))diff --git a/clients/client-python/gravitino/api/expressions/sorts/sort_orders.py b/clients/client-python/gravitino/api/expressions/sorts/sort_orders.pyindex 9deaa4bacd..4d01cb1421 100644--- a/clients/client-python/gravitino/api/expressions/sorts/sort_orders.py+++ b/clients/client-python/gravitino/api/expressions/sorts/sort_orders.py@@ -23,7 +23,6 @@ from gravitino.api.expressions.sorts.sort_order import SortOrderclass SortImpl(SortOrder):-def __init__(self,expression: Expression,diff --git a/clients/client-python/gravitino/auth/default_oauth2_token_provider.py b/clients/client-python/gravitino/auth/default_oauth2_token_provider.pyindex 127123c539..8b3fa4937d 100644--- a/clients/client-python/gravitino/auth/default_oauth2_token_provider.py+++ b/clients/client-python/gravitino/auth/default_oauth2_token_provider.py@@ -72,7 +72,6 @@ class DefaultOAuth2TokenProvider(OAuth2TokenProvider):raise IllegalArgumentException("OAuth2TokenProvider must set path")def _get_access_token(self) -> Optional[str]:-expires = self._expires_at_millis()if expires is None:@@ -102,7 +101,6 @@ class DefaultOAuth2TokenProvider(OAuth2TokenProvider):return client_id, client_secretdef _fetch_token(self) -> str:-client_id, client_secret = self._parse_credential()client_credential_request = OAuth2ClientCredentialRequest(diff --git a/clients/client-python/gravitino/client/fileset_catalog.py b/clients/client-python/gravitino/client/fileset_catalog.pyindex d5bf996be4..27931f7d70 100644--- a/clients/client-python/gravitino/client/fileset_catalog.py+++ b/clients/client-python/gravitino/client/fileset_catalog.py@@ -61,7 +61,6 @@ class FilesetCatalog(BaseSchemaCatalog, SupportsCredentials):audit: AuditDTO = None,rest_client: HTTPClient = None,):-super().__init__(namespace,name,diff --git a/clients/client-python/gravitino/client/generic_fileset.py b/clients/client-python/gravitino/client/generic_fileset.pyindex cb3728c187..ccadb26335 100644--- a/clients/client-python/gravitino/client/generic_fileset.py+++ b/clients/client-python/gravitino/client/generic_fileset.py@@ -31,7 +31,6 @@ from gravitino.utils import HTTPClientclass GenericFileset(Fileset, SupportsCredentials):-_fileset: FilesetDTO"""The fileset data transfer object"""diff --git a/clients/client-python/gravitino/client/generic_model.py b/clients/client-python/gravitino/client/generic_model.pyindex 68c479232f..882383a119 100644--- a/clients/client-python/gravitino/client/generic_model.py+++ b/clients/client-python/gravitino/client/generic_model.py@@ -22,7 +22,6 @@ from gravitino.dto.model_dto import ModelDTOclass GenericModel(Model):-_model_dto: ModelDTO"""The model DTO object."""diff --git a/clients/client-python/gravitino/client/generic_model_version.py b/clients/client-python/gravitino/client/generic_model_version.pyindex cbeab85ac4..3cd5003977 100644--- a/clients/client-python/gravitino/client/generic_model_version.py+++ b/clients/client-python/gravitino/client/generic_model_version.py@@ -22,7 +22,6 @@ from gravitino.dto.model_version_dto import ModelVersionDTOclass GenericModelVersion(ModelVersion):-_model_version_dto: ModelVersionDTO"""The model version DTO object."""diff --git a/clients/client-python/gravitino/client/metadata_object_impl.py b/clients/client-python/gravitino/client/metadata_object_impl.pyindex af16b71c4f..8186307552 100644--- a/clients/client-python/gravitino/client/metadata_object_impl.py+++ b/clients/client-python/gravitino/client/metadata_object_impl.py@@ -21,7 +21,6 @@ from gravitino.api.metadata_object import MetadataObjectclass MetadataObjectImpl(MetadataObject):-_DOT: ClassVar[str] = "."def __init__(self, names: List[str], metadata_object_type: MetadataObject.Type):diff --git a/clients/client-python/gravitino/dto/requests/oauth2_client_credential_request.py b/clients/client-python/gravitino/dto/requests/oauth2_client_credential_request.pyindex cf10502a76..8f41d517d4 100644--- a/clients/client-python/gravitino/dto/requests/oauth2_client_credential_request.py+++ b/clients/client-python/gravitino/dto/requests/oauth2_client_credential_request.py@@ -21,7 +21,6 @@ from dataclasses import dataclass@dataclassclass OAuth2ClientCredentialRequest:-grant_type: strclient_id: Optional[str]client_secret: strdiff --git a/clients/client-python/gravitino/dto/responses/oauth2_token_response.py b/clients/client-python/gravitino/dto/responses/oauth2_token_response.pyindex 55113a4904..9d0cee9178 100644--- a/clients/client-python/gravitino/dto/responses/oauth2_token_response.py+++ b/clients/client-python/gravitino/dto/responses/oauth2_token_response.py@@ -26,7 +26,6 @@ from gravitino.exceptions.base import IllegalArgumentException@dataclassclass OAuth2TokenResponse(BaseResponse):-_access_token: str = field(metadata=config(field_name="access_token"))_issue_token_type: Optional[str] = field(metadata=config(field_name="issued_token_type")diff --git a/clients/client-python/gravitino/exceptions/handlers/catalog_error_handler.py b/clients/client-python/gravitino/exceptions/handlers/catalog_error_handler.pyindex 7835f96773..2a921fd268 100644--- a/clients/client-python/gravitino/exceptions/handlers/catalog_error_handler.py+++ b/clients/client-python/gravitino/exceptions/handlers/catalog_error_handler.py@@ -29,9 +29,7 @@ from gravitino.exceptions.base import (class CatalogErrorHandler(RestErrorHandler):-def handle(self, error_response: ErrorResponse):-error_message = error_response.format_error_message()code = error_response.code()exception_type = error_response.type()diff --git a/clients/client-python/gravitino/exceptions/handlers/credential_error_handler.py b/clients/client-python/gravitino/exceptions/handlers/credential_error_handler.pyindex 542fb27cf7..3706163fb3 100644--- a/clients/client-python/gravitino/exceptions/handlers/credential_error_handler.py+++ b/clients/client-python/gravitino/exceptions/handlers/credential_error_handler.py@@ -25,9 +25,7 @@ from gravitino.exceptions.base import (class CredentialErrorHandler(RestErrorHandler):-def handle(self, error_response: ErrorResponse):-error_message = error_response.format_error_message()code = error_response.code()exception_type = error_response.type()diff --git a/clients/client-python/gravitino/exceptions/handlers/fileset_error_handler.py b/clients/client-python/gravitino/exceptions/handlers/fileset_error_handler.pyindex 569ce1832b..f11bda7ba2 100644--- a/clients/client-python/gravitino/exceptions/handlers/fileset_error_handler.py+++ b/clients/client-python/gravitino/exceptions/handlers/fileset_error_handler.py@@ -27,9 +27,7 @@ from gravitino.exceptions.base import (class FilesetErrorHandler(RestErrorHandler):-def handle(self, error_response: ErrorResponse):-error_message = error_response.format_error_message()code = error_response.code()exception_type = error_response.type()diff --git a/clients/client-python/gravitino/exceptions/handlers/metalake_error_handler.py b/clients/client-python/gravitino/exceptions/handlers/metalake_error_handler.pyindex 60a7dd0ac3..86f7404a08 100644--- a/clients/client-python/gravitino/exceptions/handlers/metalake_error_handler.py+++ b/clients/client-python/gravitino/exceptions/handlers/metalake_error_handler.py@@ -27,9 +27,7 @@ from gravitino.exceptions.base import (class MetalakeErrorHandler(RestErrorHandler):-def handle(self, error_response: ErrorResponse):-error_message = error_response.format_error_message()code = error_response.code()diff --git a/clients/client-python/gravitino/exceptions/handlers/model_error_handler.py b/clients/client-python/gravitino/exceptions/handlers/model_error_handler.pyindex 9f5e97260e..eec52d19d5 100644--- a/clients/client-python/gravitino/exceptions/handlers/model_error_handler.py+++ b/clients/client-python/gravitino/exceptions/handlers/model_error_handler.py@@ -32,7 +32,6 @@ from gravitino.exceptions.handlers.rest_error_handler import RestErrorHandlerclass ModelErrorHandler(RestErrorHandler):-def handle(self, error_response: ErrorResponse):error_message = error_response.format_error_message()code = error_response.code()diff --git a/clients/client-python/gravitino/exceptions/handlers/oauth_error_handler.py b/clients/client-python/gravitino/exceptions/handlers/oauth_error_handler.pyindex 7f4d0f3684..cce8145e71 100644--- a/clients/client-python/gravitino/exceptions/handlers/oauth_error_handler.py+++ b/clients/client-python/gravitino/exceptions/handlers/oauth_error_handler.py@@ -28,9 +28,7 @@ INVALID_SCOPE_ERROR = "invalid_scope"class OAuthErrorHandler(RestErrorHandler):-def handle(self, error_response: OAuth2ErrorResponse):-error_message = error_response.message()exception_type = error_response.type()diff --git a/clients/client-python/gravitino/exceptions/handlers/rest_error_handler.py b/clients/client-python/gravitino/exceptions/handlers/rest_error_handler.pyindex ccfcbb6287..578410cea2 100644--- a/clients/client-python/gravitino/exceptions/handlers/rest_error_handler.py+++ b/clients/client-python/gravitino/exceptions/handlers/rest_error_handler.py@@ -22,7 +22,6 @@ from gravitino.exceptions.base import RESTExceptionclass RestErrorHandler(ErrorHandler):-def handle(self, error_response: ErrorResponse):error_message = error_response.format_error_message()code = error_response.code()diff --git a/clients/client-python/gravitino/exceptions/handlers/schema_error_handler.py b/clients/client-python/gravitino/exceptions/handlers/schema_error_handler.pyindex fa805de81d..42a0a8894b 100644--- a/clients/client-python/gravitino/exceptions/handlers/schema_error_handler.py+++ b/clients/client-python/gravitino/exceptions/handlers/schema_error_handler.py@@ -28,9 +28,7 @@ from gravitino.exceptions.base import (class SchemaErrorHandler(RestErrorHandler):-def handle(self, error_response: ErrorResponse):-error_message = error_response.format_error_message()code = error_response.code()exception_type = error_response.type()diff --git a/clients/client-python/gravitino/rest/rest_utils.py b/clients/client-python/gravitino/rest/rest_utils.pyindex 4243922c6c..58c4d55b7a 100644--- a/clients/client-python/gravitino/rest/rest_utils.py+++ b/clients/client-python/gravitino/rest/rest_utils.py@@ -20,7 +20,6 @@ from gravitino.exceptions.base import IllegalArgumentExceptiondef encode_string(to_encode: str):-if to_encode is None:raise IllegalArgumentException("Invalid string to encode: None")diff --git a/clients/client-python/gravitino/utils/__init__.py b/clients/client-python/gravitino/utils/__init__.pyindex ee8b21b902..091797d89a 100644--- a/clients/client-python/gravitino/utils/__init__.py+++ b/clients/client-python/gravitino/utils/__init__.py@@ -16,3 +16,5 @@# under the License.from gravitino.utils.http_client import Response, HTTPClient, unpack++__all__ = ["Response", "HTTPClient", "unpack"]diff --git a/clients/client-python/gravitino/utils/http_client.py b/clients/client-python/gravitino/utils/http_client.pyindex b3e38a5d35..1e51b4ef62 100644--- a/clients/client-python/gravitino/utils/http_client.py+++ b/clients/client-python/gravitino/utils/http_client.py@@ -79,7 +79,6 @@ class Response:class HTTPClient:-FORMDATA_HEADER = {"Content-Type": "application/x-www-form-urlencoded","Accept": "application/vnd.gravitino.v1+json",diff --git a/clients/client-python/pyproject.toml b/clients/client-python/pyproject.tomlnew file mode 100644index 0000000000..e402f51007--- /dev/null+++ b/clients/client-python/pyproject.toml@@ -0,0 +1,25 @@+# 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.++[tool.ruff]+line-length = 88++[tool.ruff.lint]+ignore-init-module-imports = true++[tool.ruff.format]+quote-style = "double"\ No newline at end of filediff --git a/clients/client-python/requirements.txt b/clients/client-python/requirements.txtindex 70699bc672..d2e67ee346 100644--- a/clients/client-python/requirements.txt+++ b/clients/client-python/requirements.txt@@ -26,4 +26,7 @@ cachetools==5.5.2gcsfs==2024.3.1s3fs==2024.3.1ossfs==2023.12.0-adlfs==2023.12.0\ No newline at end of file+adlfs==2023.12.0+black==24.4.2+flake8==7.0.0+pre-commit==3.5.0\ No newline at end of filediff --git a/clients/client-python/tests/integration/auth/test_auth_common.py b/clients/client-python/tests/integration/auth/test_auth_common.pyindex ede3a4e2ad..8c09664566 100644--- a/clients/client-python/tests/integration/auth/test_auth_common.py+++ b/clients/client-python/tests/integration/auth/test_auth_common.py@@ -111,7 +111,6 @@ class TestCommonAuth:os.environ["GRAVITINO_USER"] = ""def init_test_env(self):-catalog = self.gravitino_client.create_catalog(name=self.catalog_name,catalog_type=Catalog.Type.FILESET,diff --git a/clients/client-python/tests/integration/auth/test_oauth2_client.py b/clients/client-python/tests/integration/auth/test_oauth2_client.pyindex 0f4a1e4ca9..a3add01562 100644--- a/clients/client-python/tests/integration/auth/test_oauth2_client.py+++ b/clients/client-python/tests/integration/auth/test_oauth2_client.py@@ -46,12 +46,10 @@ DOCKER_TEST = os.environ.get("DOCKER_TEST")"Skipping tests when DOCKER_TEST=false",)class TestOAuth2(IntegrationTestEnv, TestCommonAuth):-oauth2_container: OAuth2Container = None@classmethoddef setUpClass(cls):-cls._get_gravitino_home()cls.oauth2_container = OAuth2Container()@@ -90,7 +88,6 @@ class TestOAuth2(IntegrationTestEnv, TestCommonAuth):@classmethoddef _get_default_sign_key(cls) -> str:-jwk_uri = f"{cls.oauth2_server_uri}/oauth2/jwks"# Get JWK from OAuth2 Server@@ -156,7 +153,6 @@ class TestOAuth2(IntegrationTestEnv, TestCommonAuth):self.init_test_env()def init_test_env(self):-self.gravitino_admin_client.create_metalake(self.metalake_name, comment="", properties={})diff --git a/clients/client-python/tests/integration/auth/test_simple_auth_client.py b/clients/client-python/tests/integration/auth/test_simple_auth_client.pyindex 09309abb74..1d365e7673 100644--- a/clients/client-python/tests/integration/auth/test_simple_auth_client.py+++ b/clients/client-python/tests/integration/auth/test_simple_auth_client.py@@ -31,7 +31,6 @@ logger = logging.getLogger(__name__)class TestSimpleAuthClient(IntegrationTestEnv, TestCommonAuth):-def setUp(self):os.environ["GRAVITINO_USER"] = self.creatorself.gravitino_admin_client = GravitinoAdminClient(diff --git a/clients/client-python/tests/integration/base_hadoop_env.py b/clients/client-python/tests/integration/base_hadoop_env.pyindex c8e6cb9dae..ef820a0f57 100644--- a/clients/client-python/tests/integration/base_hadoop_env.py+++ b/clients/client-python/tests/integration/base_hadoop_env.py@@ -30,7 +30,6 @@ PYTHON_BUILD_PATH = os.environ.get("PYTHON_BUILD_PATH")class BaseHadoopEnvironment:-@classmethoddef init_hadoop_env(cls):cls._unzip_hadoop_pack()diff --git a/clients/client-python/tests/integration/containers/hdfs_container.py b/clients/client-python/tests/integration/containers/hdfs_container.pyindex a3e0859434..3f34d65435 100644--- a/clients/client-python/tests/integration/containers/hdfs_container.py+++ b/clients/client-python/tests/integration/containers/hdfs_container.py@@ -70,7 +70,6 @@ async def check_hdfs_container_status(hdfs_container):class HDFSContainer(BaseContainer):-def __init__(self):container_name = "python-hdfs"image_name = os.environ.get("GRAVITINO_CI_HIVE_DOCKER_IMAGE")diff --git a/clients/client-python/tests/integration/containers/oauth2_container.py b/clients/client-python/tests/integration/containers/oauth2_container.pyindex 02ebc7d1d2..56fb504b7b 100644--- a/clients/client-python/tests/integration/containers/oauth2_container.py+++ b/clients/client-python/tests/integration/containers/oauth2_container.py@@ -36,7 +36,6 @@ async def check_oauth2_container_status(oauth2_container: "OAuth2Container"):class OAuth2Container(BaseContainer):-def __init__(self):container_name = "sample-auth-server"image_name = os.environ.get("GRAVITINO_OAUTH2_SAMPLE_SERVER")diff --git a/clients/client-python/tests/integration/test_fileset_catalog.py b/clients/client-python/tests/integration/test_fileset_catalog.pyindex 11e83c0b20..12d9d190e2 100644--- a/clients/client-python/tests/integration/test_fileset_catalog.py+++ b/clients/client-python/tests/integration/test_fileset_catalog.py@@ -90,7 +90,6 @@ class TestFilesetCatalog(IntegrationTestEnv):self.clean_test_data()def clean_test_data(self):-self.gravitino_client = GravitinoClient(uri="http://localhost:8090", metalake_name=self.metalake_name)diff --git a/clients/client-python/tests/integration/test_gvfs_with_hdfs.py b/clients/client-python/tests/integration/test_gvfs_with_hdfs.pyindex f07a2e0328..7c8272a2e8 100644--- a/clients/client-python/tests/integration/test_gvfs_with_hdfs.py+++ b/clients/client-python/tests/integration/test_gvfs_with_hdfs.py@@ -100,7 +100,6 @@ class TestGvfsWithHDFS(IntegrationTestEnv):@classmethoddef setUpClass(cls):-cls._get_gravitino_home()cls.hdfs_container = HDFSContainer()@@ -161,9 +160,7 @@ class TestGvfsWithHDFS(IntegrationTestEnv):schema_name=cls.schema_name, comment="", properties={})- cls.fileset_storage_location: str = (- f"hdfs://{cls.hdfs_container.get_ip()}:9000/{cls.catalog_name}/{cls.schema_name}/{cls.fileset_name}"- )+ cls.fileset_storage_location: str = f"hdfs://{cls.hdfs_container.get_ip()}:9000/{cls.catalog_name}/{cls.schema_name}/{cls.fileset_name}"cls.fileset_gvfs_location = (f"gvfs://fileset/{cls.catalog_name}/{cls.schema_name}/{cls.fileset_name}")diff --git a/clients/client-python/tests/unittests/audit/test_caller_context.py b/clients/client-python/tests/unittests/audit/test_caller_context.pyindex 4243d2d5c2..f34abe1343 100644--- a/clients/client-python/tests/unittests/audit/test_caller_context.py+++ b/clients/client-python/tests/unittests/audit/test_caller_context.py@@ -22,7 +22,6 @@ from gravitino.audit.caller_context import CallerContextHolder, CallerContextclass TestCallerContext(unittest.TestCase):-def test_caller_context(self):thread_names_and_values = [("Thread1", {"k1": "v1", "k2": "v2"}),diff --git a/clients/client-python/tests/unittests/auth/test_oauth2_token_provider.py b/clients/client-python/tests/unittests/auth/test_oauth2_token_provider.pyindex 6388a292e4..dcc80bba56 100644--- a/clients/client-python/tests/unittests/auth/test_oauth2_token_provider.py+++ b/clients/client-python/tests/unittests/auth/test_oauth2_token_provider.py@@ -31,9 +31,7 @@ OAUTH_PORT = 1082class TestOAuth2TokenProvider(unittest.TestCase):-def test_provider_init_exception(self):-with self.assertRaises(IllegalArgumentException):_ = DefaultOAuth2TokenProvider(uri="test")@@ -48,7 +46,6 @@ class TestOAuth2TokenProvider(unittest.TestCase):return_value=mock_base.mock_authentication_invalid_client_error(),)def test_authertication_invalid_client_error(self, *mock_methods):-with self.assertRaises(UnauthorizedException):_ = DefaultOAuth2TokenProvider(uri=f"http://127.0.0.1:{OAUTH_PORT}",@@ -62,7 +59,6 @@ class TestOAuth2TokenProvider(unittest.TestCase):return_value=mock_base.mock_authentication_invalid_grant_error(),)def test_authertication_invalid_grant_error(self, *mock_methods):-with self.assertRaises(BadRequestException):_ = DefaultOAuth2TokenProvider(uri=f"http://127.0.0.1:{OAUTH_PORT}",@@ -76,7 +72,6 @@ class TestOAuth2TokenProvider(unittest.TestCase):return_value=mock_base.mock_authentication_with_error_authentication_type(),)def test_authentication_with_error_authentication_type(self, *mock_methods):-with self.assertRaises(IllegalArgumentException):_ = DefaultOAuth2TokenProvider(uri=f"http://127.0.0.1:{OAUTH_PORT}",diff --git a/clients/client-python/tests/unittests/auth/test_simple_auth_provider.py b/clients/client-python/tests/unittests/auth/test_simple_auth_provider.pyindex d5e0f168a7..91d9a1a49c 100644--- a/clients/client-python/tests/unittests/auth/test_simple_auth_provider.py+++ b/clients/client-python/tests/unittests/auth/test_simple_auth_provider.py@@ -25,7 +25,6 @@ from gravitino.auth.simple_auth_provider import SimpleAuthProviderclass TestSimpleAuthProvider(unittest.TestCase):-def test_auth_provider(self):os.environ["user.name"] = "test_auth1"provider: AuthDataProvider = SimpleAuthProvider()diff --git a/clients/client-python/tests/unittests/mock_base.py b/clients/client-python/tests/unittests/mock_base.pyindex dd3316b697..fb30715441 100644--- a/clients/client-python/tests/unittests/mock_base.py+++ b/clients/client-python/tests/unittests/mock_base.py@@ -131,5 +131,4 @@ def mock_data(cls):def mock_name_identifier_json(name, namespace):-return json.dumps({"name": name, "namespace": namespace}).encode("utf-8")diff --git a/clients/client-python/tests/unittests/rel/test_distributions.py b/clients/client-python/tests/unittests/rel/test_distributions.pyindex a9e0637c57..85976aaf95 100644--- a/clients/client-python/tests/unittests/rel/test_distributions.py+++ b/clients/client-python/tests/unittests/rel/test_distributions.py@@ -34,7 +34,6 @@ class MockExpression(Expression):class TestDistributions(unittest.TestCase):-def setUp(self):# Create mock expressions for testingself.expr1 = MockExpression() # Use the MockExpression classdiff --git a/clients/client-python/tests/unittests/rel/test_types.py b/clients/client-python/tests/unittests/rel/test_types.pyindex bf5685c4ac..2acdbcf4ea 100644--- a/clients/client-python/tests/unittests/rel/test_types.py+++ b/clients/client-python/tests/unittests/rel/test_types.py@@ -21,7 +21,6 @@ from gravitino.api.types.types import Types, Nameclass TestTypes(unittest.TestCase):-def test_null_type(self):instance: Types.NullType = Types.NullType.get()self.assertIsInstance(instance, Types.NullType)diff --git a/clients/client-python/tests/unittests/test_credential_api.py b/clients/client-python/tests/unittests/test_credential_api.pyindex 2811a226f9..bf96b1a25e 100644--- a/clients/client-python/tests/unittests/test_credential_api.py+++ b/clients/client-python/tests/unittests/test_credential_api.py@@ -31,7 +31,6 @@ from tests.unittests import mock_base@mock_base.mock_dataclass TestCredentialApi(unittest.TestCase):-def test_get_credentials(self, *mock_method):json_str = self._get_s3_token_str()mock_resp = self._get_mock_http_resp(json_str)diff --git a/clients/client-python/tests/unittests/test_credential_factory.py b/clients/client-python/tests/unittests/test_credential_factory.pyindex fddbbc098b..0e67e81fea 100644--- a/clients/client-python/tests/unittests/test_credential_factory.py+++ b/clients/client-python/tests/unittests/test_credential_factory.py@@ -32,7 +32,6 @@ from gravitino.api.credential.azure_account_key_credential import (class TestCredentialFactory(unittest.TestCase):-def test_s3_token_credential(self):s3_credential_info = {S3TokenCredential._SESSION_ACCESS_KEY_ID: "access_key",diff --git a/clients/client-python/tests/unittests/test_error_handler.py b/clients/client-python/tests/unittests/test_error_handler.pyindex a402ae111f..688e6c3480 100644--- a/clients/client-python/tests/unittests/test_error_handler.py+++ b/clients/client-python/tests/unittests/test_error_handler.py@@ -49,9 +49,7 @@ from gravitino.exceptions.handlers.schema_error_handler import SCHEMA_ERROR_HANDclass TestErrorHandler(unittest.TestCase):-def test_rest_error_handler(self):-with self.assertRaises(RESTException):REST_ERROR_HANDLER.handle(ErrorResponse.generate_error_response(RESTException, "mock error")@@ -106,7 +104,6 @@ class TestErrorHandler(unittest.TestCase):)def test_fileset_error_handler(self):-with self.assertRaises(NoSuchFilesetException):FILESET_ERROR_HANDLER.handle(ErrorResponse.generate_error_response(@@ -132,7 +129,6 @@ class TestErrorHandler(unittest.TestCase):)def test_credential_error_handler(self):-with self.assertRaises(NoSuchCredentialException):CREDENTIAL_ERROR_HANDLER.handle(ErrorResponse.generate_error_response(@@ -151,7 +147,6 @@ class TestErrorHandler(unittest.TestCase):)def test_metalake_error_handler(self):-with self.assertRaises(NoSuchMetalakeException):METALAKE_ERROR_HANDLER.handle(ErrorResponse.generate_error_response(@@ -177,7 +172,6 @@ class TestErrorHandler(unittest.TestCase):)def test_catalog_error_handler(self):-with self.assertRaises(ConnectionFailedException):CATALOG_ERROR_HANDLER.handle(ErrorResponse.generate_error_response(@@ -217,7 +211,6 @@ class TestErrorHandler(unittest.TestCase):)def test_schema_error_handler(self):-with self.assertRaises(NoSuchCatalogException):SCHEMA_ERROR_HANDLER.handle(ErrorResponse.generate_error_response(diff --git a/clients/client-python/tests/unittests/test_fileset_catalog_api.py b/clients/client-python/tests/unittests/test_fileset_catalog_api.pyindex 06c27d3dfa..93fdf77205 100644--- a/clients/client-python/tests/unittests/test_fileset_catalog_api.py+++ b/clients/client-python/tests/unittests/test_fileset_catalog_api.py@@ -31,7 +31,6 @@ from tests.unittests import mock_base@mock_base.mock_dataclass TestFilesetCatalogApi(unittest.TestCase):-def test_get_file_location(self, *mock_method):json_data = {"code": 0, "fileLocation": "file:/test/1"}json_str = json.dumps(json_data)diff --git a/clients/client-python/tests/unittests/test_precondition.py b/clients/client-python/tests/unittests/test_precondition.pyindex 78a246597e..e7eeee00bc 100644--- a/clients/client-python/tests/unittests/test_precondition.py+++ b/clients/client-python/tests/unittests/test_precondition.py@@ -24,7 +24,6 @@ from gravitino.utils.precondition import Preconditionclass TestPrecondition(unittest.TestCase):-def test_check_argument(self):with self.assertRaises(IllegalArgumentException):Precondition.check_argument(False, "error")diff --git a/dev/docker/iceberg-rest-server/rewrite_config.py b/dev/docker/iceberg-rest-server/rewrite_config.pyindex 9bb7d467d3..ac24ad9c08 100755--- a/dev/docker/iceberg-rest-server/rewrite_config.py+++ b/dev/docker/iceberg-rest-server/rewrite_config.py@@ -19,66 +19,68 @@import osenv_map = {- "GRAVITINO_IO_IMPL" : "io-impl",- "GRAVITINO_URI" : "uri",- "GRAVITINO_CATALOG_BACKEND" : "catalog-backend",- "GRAVITINO_JDBC_DRIVER": "jdbc-driver",- "GRAVITINO_JDBC_USER": "jdbc-user",- "GRAVITINO_JDBC_PASSWORD": "jdbc-password",- "GRAVITINO_WAREHOUSE" : "warehouse",- "GRAVITINO_CREDENTIAL_PROVIDER_TYPE" : "credential-providers",- "GRAVITINO_CREDENTIAL_PROVIDERS" : "credential-providers",- "GRAVITINO_GCS_CREDENTIAL_FILE_PATH" : "gcs-service-account-file",- "GRAVITINO_GCS_SERVICE_ACCOUNT_FILE" : "gcs-service-account-file",- "GRAVITINO_S3_ACCESS_KEY" : "s3-access-key-id",- "GRAVITINO_S3_SECRET_KEY" : "s3-secret-access-key",- "GRAVITINO_S3_ENDPOINT" : "s3-endpoint",- "GRAVITINO_S3_REGION" : "s3-region",- "GRAVITINO_S3_ROLE_ARN" : "s3-role-arn",- "GRAVITINO_S3_EXTERNAL_ID" : "s3-external-id",- "GRAVITINO_AZURE_STORAGE_ACCOUNT_NAME" : "azure-storage-account-name",- "GRAVITINO_AZURE_STORAGE_ACCOUNT_KEY" : "azure-storage-account-key",- "GRAVITINO_AZURE_TENANT_ID" : "azure-tenant-id",- "GRAVITINO_AZURE_CLIENT_ID" : "azure-client-id",- "GRAVITINO_AZURE_CLIENT_SECRET" : "azure-client-secret",- "GRAVITINO_OSS_ACCESS_KEY": "oss-access-key-id",- "GRAVITINO_OSS_SECRET_KEY": "oss-secret-access-key",- "GRAVITINO_OSS_ENDPOINT": "oss-endpoint",- "GRAVITINO_OSS_REGION": "oss-region",- "GRAVITINO_OSS_ROLE_ARN": "oss-role-arn",- "GRAVITINO_OSS_EXTERNAL_ID": "oss-external-id",-+ "GRAVITINO_IO_IMPL": "io-impl",+ "GRAVITINO_URI": "uri",+ "GRAVITINO_CATALOG_BACKEND" : "catalog-backend",+ "GRAVITINO_JDBC_DRIVER": "jdbc-driver",+ "GRAVITINO_JDBC_USER": "jdbc-user",+ "GRAVITINO_JDBC_PASSWORD": "jdbc-password",+ "GRAVITINO_WAREHOUSE": "warehouse",+ "GRAVITINO_CREDENTIAL_PROVIDER_TYPE": "credential-providers",+ "GRAVITINO_CREDENTIAL_PROVIDERS": "credential-providers",+ "GRAVITINO_GCS_CREDENTIAL_FILE_PATH": "gcs-service-account-file",+ "GRAVITINO_GCS_SERVICE_ACCOUNT_FILE": "gcs-service-account-file",+ "GRAVITINO_S3_ACCESS_KEY": "s3-access-key-id",+ "GRAVITINO_S3_SECRET_KEY": "s3-secret-access-key",+ "GRAVITINO_S3_ENDPOINT": "s3-endpoint",+ "GRAVITINO_S3_REGION": "s3-region",+ "GRAVITINO_S3_ROLE_ARN": "s3-role-arn",+ "GRAVITINO_S3_EXTERNAL_ID": "s3-external-id",+ "GRAVITINO_AZURE_STORAGE_ACCOUNT_NAME": "azure-storage-account-name",+ "GRAVITINO_AZURE_STORAGE_ACCOUNT_KEY": "azure-storage-account-key",+ "GRAVITINO_AZURE_TENANT_ID": "azure-tenant-id",+ "GRAVITINO_AZURE_CLIENT_ID": "azure-client-id",+ "GRAVITINO_AZURE_CLIENT_SECRET": "azure-client-secret",+ "GRAVITINO_OSS_ACCESS_KEY": "oss-access-key-id",+ "GRAVITINO_OSS_SECRET_KEY": "oss-secret-access-key",+ "GRAVITINO_OSS_ENDPOINT": "oss-endpoint",+ "GRAVITINO_OSS_REGION": "oss-region",+ "GRAVITINO_OSS_ROLE_ARN": "oss-role-arn",+ "GRAVITINO_OSS_EXTERNAL_ID": "oss-external-id",}init_config = {- "catalog-backend" : "jdbc",- "jdbc-driver" : "org.sqlite.JDBC",- "uri" : "jdbc:sqlite::memory:",- "jdbc-user" : "iceberg",- "jdbc-password" : "iceberg",- "jdbc-initialize" : "true",- "jdbc.schema-version" : "V1"+ "catalog-backend": "jdbc",+ "jdbc-driver": "org.sqlite.JDBC",+ "uri": "jdbc:sqlite::memory:",+ "jdbc-user": "iceberg",+ "jdbc-password": "iceberg",+ "jdbc-initialize": "true",+ "jdbc.schema-version": "V1",}-def parse_config_file(file_path):- config_map = {}- with open(file_path, 'r') as file:- for line in file:- stripped_line = line.strip()- if stripped_line and not stripped_line.startswith('#'):- key, value = stripped_line.split('=', 1)- key = key.strip()- value = value.strip()- config_map[key] = value- return config_map+def parse_config_file(file_path):+ config_map = {}+ with open(file_path, "r") as file:+ for line in file:+ stripped_line = line.strip()+ if stripped_line and not stripped_line.startswith("#"):+ key, value = stripped_line.split("=", 1)+ key = key.strip()+ value = value.strip()+ config_map[key] = value+ return config_map+config_prefix = "gravitino.iceberg-rest."+def update_config(config, key, value):config[config_prefix + key] = value--config_file_path = 'conf/gravitino-iceberg-rest-server.conf'+++config_file_path = "conf/gravitino-iceberg-rest-server.conf"config_map = parse_config_file(config_file_path)for k, v in init_config.items():@@ -87,11 +89,11 @@ for k, v in init_config.items():for k, v in env_map.items():if k in os.environ:update_config(config_map, v, os.environ[k])--if os.path.exists(config_file_path):- os.remove(config_file_path)-with open(config_file_path, 'w') as file:- for key, value in config_map.items():- line = "{} = {}\n".format(key, value)- file.write(line)+if os.path.exists(config_file_path):+ os.remove(config_file_path)++with open(config_file_path, "w") as file:+ for key, value in config_map.items():+ line = "{} = {}\n".format(key, value)+ file.write(line)