Abyss-lord commented on code in PR #10861: URL: https://github.com/apache/gravitino/pull/10861#discussion_r3198703291
########## clients/client-python/tests/integration/test_supports_tags.py: ########## @@ -0,0 +1,416 @@ +# 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. +import typing as tp +from random import randint + +from gravitino import Catalog, GravitinoAdminClient, GravitinoClient, GravitinoMetalake +from gravitino.api.file.fileset import Fileset +from gravitino.api.model.model import Model +from gravitino.api.rel.table import Table +from gravitino.api.rel.table_catalog import TableCatalog +from gravitino.api.rel.types.types import Types +from gravitino.api.tag import Tag +from gravitino.api.tag.supports_tags import SupportsTags +from gravitino.dto.rel.column_dto import ColumnDTO +from gravitino.dto.rel.partitioning.identity_partitioning_dto import ( + IdentityPartitioningDTO, +) +from gravitino.exceptions.base import NoSuchTagException +from gravitino.name_identifier import NameIdentifier +from tests.integration.containers.hdfs_container import HDFSContainer +from tests.integration.integration_test_env import IntegrationTestEnv + +# pylint: disable=too-many-instance-attributes + + +class TestSupportsTags(IntegrationTestEnv): + relational_catalog_provider: str = "hive" + fileset_comment: str = "fileset_comment" + catalog_location_prop: str = "location" + + fileset_location: str = "/tmp/TestFilesetCatalog" + fileset_properties_key1: str = "fileset_properties_key1" + fileset_properties_value1: str = "fileset_properties_value1" + fileset_properties_key2: str = "fileset_properties_key2" + fileset_properties_value2: str = "fileset_properties_value2" + fileset_properties: tp.Dict[str, str] = { + fileset_properties_key1: fileset_properties_value1, + fileset_properties_key2: fileset_properties_value2, + } + multiple_locations_fileset_properties: tp.Dict[str, str] = { + Fileset.PROPERTY_DEFAULT_LOCATION_NAME: "location1", + **fileset_properties, + } + + _metalake_name: str = "tag_it_metalake" + str(randint(0, 1000)) + _relational_catalog_name: str = "relational_catalog" + str(randint(0, 1000)) + _model_catalog_name: str = "model_catalog" + str(randint(0, 1000)) + _fileset_catalog_name: str = "fileset_catalog" + str(randint(0, 1000)) + # SCHEMA + _schema_name = "tag_it_schema" + str(randint(0, 1000)) + # OTHER + _table_name: str = "tag_it_table" + str(randint(0, 1000)) + _fileset_name: str = "tag_it_fileset" + str(randint(0, 1000)) + _model_name: str = "tag_it_model" + str(randint(0, 1000)) + + _tag_name1: str = "tag_it_tag1" + str(randint(0, 1000)) + _tag_name2: str = "tag_it_tag2" + str(randint(0, 1000)) + _tag_name3: str = "tag_it_tag3" + str(randint(0, 1000)) + _tag_name4: str = "tag_it_tag4" + str(randint(0, 1000)) + + _gravitino_admin_client: GravitinoAdminClient + _gravitino_client: GravitinoClient + _metalake: GravitinoMetalake + _model_catalog: Catalog + _table_catalog: TableCatalog + _relational_catalog: Catalog + _fileset_catalog: Catalog + _tag1: Tag + _tag2: Tag + _tag3: Tag + _tag4: Tag + + _table_ident: NameIdentifier + _fileset_ident: NameIdentifier + _model_ident: NameIdentifier + _hdfs_container: HDFSContainer + + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls._hdfs_container = HDFSContainer() + cls._gravitino_admin_client = GravitinoAdminClient(uri="http://localhost:8090") + + cls._metalake = cls._gravitino_admin_client.create_metalake( + cls._metalake_name, comment="test metalake", properties={} + ) + cls._gravitino_client = GravitinoClient( + uri="http://localhost:8090", metalake_name=cls._metalake_name + ) + + cls._gravitino_client.create_tag(cls._tag_name1, "test tag1", {}) + cls._gravitino_client.create_tag(cls._tag_name2, "test tag2", {}) + cls._gravitino_client.create_tag(cls._tag_name3, "test tag3", {}) + cls._gravitino_client.create_tag(cls._tag_name4, "test tag4", {}) + + cls._tag1 = cls._gravitino_client.get_tag(cls._tag_name1) + cls._tag2 = cls._gravitino_client.get_tag(cls._tag_name2) + cls._tag3 = cls._gravitino_client.get_tag(cls._tag_name3) + cls._tag4 = cls._gravitino_client.get_tag(cls._tag_name4) + + hive_metastore_uri = f"thrift://{cls._hdfs_container.get_ip()}:9083" + + cls._model_catalog = cls._gravitino_client.create_catalog( + name=cls._model_catalog_name, + catalog_type=Catalog.Type.MODEL, + provider="", + comment="comment", + properties={}, + ) + cls._fileset_catalog = cls._gravitino_client.create_catalog( + name=cls._fileset_catalog_name, + catalog_type=Catalog.Type.FILESET, + provider="", Review Comment: fix -- 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]
