Skip to content

Commit 2848b98

Browse files
committed
chore(enhancement): fix Python Client CI / build job
1 parent cf8d62f commit 2848b98

File tree

9 files changed

+31
-72
lines changed

9 files changed

+31
-72
lines changed

client/python/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,3 @@ target/
6464

6565
#Ipython Notebook
6666
.ipynb_checkpoints
67-
68-
# OpenAPI spec
69-
spec/
Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +0,0 @@
1-
#
2-
# Licensed to the Apache Software Foundation (ASF) under one
3-
# or more contributor license agreements. See the NOTICE file
4-
# distributed with this work for additional information
5-
# regarding copyright ownership. The ASF licenses this file
6-
# to you under the Apache License, Version 2.0 (the
7-
# "License"); you may not use this file except in compliance
8-
# with the License. You may obtain a copy of the License at
9-
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
11-
#
12-
# Unless required by applicable law or agreed to in writing,
13-
# software distributed under the License is distributed on an
14-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
# KIND, either express or implied. See the License for the
16-
# specific language governing permissions and limitations
17-
# under the License.
18-
#
19-
Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +0,0 @@
1-
#
2-
# Licensed to the Apache Software Foundation (ASF) under one
3-
# or more contributor license agreements. See the NOTICE file
4-
# distributed with this work for additional information
5-
# regarding copyright ownership. The ASF licenses this file
6-
# to you under the Apache License, Version 2.0 (the
7-
# "License"); you may not use this file except in compliance
8-
# with the License. You may obtain a copy of the License at
9-
#
10-
# http://www.apache.org/licenses/LICENSE-2.0
11-
#
12-
# Unless required by applicable law or agreed to in writing,
13-
# software distributed under the License is distributed on an
14-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
# KIND, either express or implied. See the License for the
16-
# specific language governing permissions and limitations
17-
# under the License.
18-
#
19-

client/python/integration_tests/conftest.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -381,31 +381,31 @@ def format_namespace(namespace: List[str]) -> str:
381381
def _patch_generated_models() -> None:
382382
"""
383383
The OpenAPI generator creates an `api_client` that dynamically looks up
384-
model classes from the `polaris.catalog.models` module using `getattr()`.
384+
model classes from the `apache_polaris.sdk.catalog.models` module using `getattr()`.
385385
For example, when a response for a `create_policy` call is received, the
386386
deserializer tries to find the `LoadPolicyResponse` class by looking for
387-
`polaris.catalog.models.LoadPolicyResponse`.
387+
`apache_polaris.sdk.catalog.models.LoadPolicyResponse`.
388388
389389
However, the generator fails to add the necessary `import` statements
390390
to the `polaris/catalog/models/__init__.py` file. This means that even
391391
though the model files exist (e.g., `load_policy_response.py`), the classes
392-
are not part of the `polaris.catalog.models` namespace.
392+
are not part of the `apache_polaris.sdk.catalog.models` namespace.
393393
394394
This fixture works around the bug in the generated code without modifying
395395
the source files. It runs once per test session, before any tests, and
396396
manually injects the missing response-side model classes into the
397-
`polaris.catalog.models` namespace, allowing the deserializer to find them.
397+
`apache_polaris.sdk.catalog.models` namespace, allowing the deserializer to find them.
398398
"""
399-
import polaris.catalog.models
400-
from polaris.catalog.models.applicable_policy import ApplicablePolicy
401-
from polaris.catalog.models.get_applicable_policies_response import (
399+
import apache_polaris.sdk.catalog.models
400+
from apache_polaris.sdk.catalog.models.applicable_policy import ApplicablePolicy
401+
from apache_polaris.sdk.catalog.models.get_applicable_policies_response import (
402402
GetApplicablePoliciesResponse,
403403
)
404-
from polaris.catalog.models.list_policies_response import ListPoliciesResponse
405-
from polaris.catalog.models.load_policy_response import LoadPolicyResponse
406-
from polaris.catalog.models.policy import Policy
407-
from polaris.catalog.models.policy_attachment_target import PolicyAttachmentTarget
408-
from polaris.catalog.models.policy_identifier import PolicyIdentifier
404+
from apache_polaris.sdk.catalog.models.list_policies_response import ListPoliciesResponse
405+
from apache_polaris.sdk.catalog.models.load_policy_response import LoadPolicyResponse
406+
from apache_polaris.sdk.catalog.models.policy import Policy
407+
from apache_polaris.sdk.catalog.models.policy_attachment_target import PolicyAttachmentTarget
408+
from apache_polaris.sdk.catalog.models.policy_identifier import PolicyIdentifier
409409

410410
models_to_patch = {
411411
"ApplicablePolicy": ApplicablePolicy,
@@ -418,4 +418,4 @@ def _patch_generated_models() -> None:
418418
}
419419

420420
for name, model_class in models_to_patch.items():
421-
setattr(polaris.catalog.models, name, model_class)
421+
setattr(apache_polaris.sdk.catalog.models, name, model_class)

regtests/.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
.pytest_cache
2222
t_pyspark/src/spark-warehouse
2323
t_pyspark/src/.pytest_cache
24-
polaris/polaris.management.egg-info
24+
polaris/apache_polaris.sdk.management.egg-info

regtests/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ docker run --rm \
193193
-v ${PWD}:/local openapitools/openapi-generator-cli generate \
194194
-i /local/spec/polaris-management-service.yml \
195195
-g python \
196-
-o /local/client/python --additional-properties=packageName=polaris.management --additional-properties=apiNamePrefix=polaris
196+
-o /local/client/python --additional-properties=packageName=apache_polaris.sdk.management --additional-properties=apiNamePrefix=polaris
197197

198198
# generate the iceberg rest client
199199
docker run --rm \
200200
-v ${PWD}:/local openapitools/openapi-generator-cli generate \
201201
-i /local/spec/polaris-catalog-service.yaml \
202202
-g python \
203-
-o /local/client/python --additional-properties=packageName=polaris.catalog --additional-properties=apiNameSuffix="" --additional-properties=apiNamePrefix=Iceberg
203+
-o /local/client/python --additional-properties=packageName=apache_polaris.sdk.catalog --additional-properties=apiNameSuffix="" --additional-properties=apiNamePrefix=Iceberg
204204
```
205205

206206
Tests rely on Python 3.9 or higher. `pyenv` can be used to install a current version and mapped to the local directory

regtests/t_pyspark/src/conftest.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424

2525
import pytest
2626

27-
from polaris.catalog.api.iceberg_catalog_api import IcebergCatalogAPI
28-
from polaris.catalog.api_client import ApiClient as CatalogApiClient
29-
from polaris.management import Catalog, AwsStorageConfigInfo, ApiClient, PolarisDefaultApi, Configuration, \
27+
from apache_polaris.sdk.catalog.api.iceberg_catalog_api import IcebergCatalogAPI
28+
from apache_polaris.sdk.catalog.api_client import ApiClient as CatalogApiClient
29+
from apache_polaris.sdk.management import Catalog, AwsStorageConfigInfo, ApiClient, PolarisDefaultApi, Configuration, \
3030
CreateCatalogRequest, GrantCatalogRoleRequest, CatalogRole, ApiException, AddGrantRequest, CatalogGrant, \
3131
CatalogPrivilege, CreateCatalogRoleRequest, CatalogProperties
3232

@@ -192,7 +192,7 @@ def _create_catalog_with_storage(root_client, catalog_client, catalog_name, stor
192192
storage_config_info: Storage configuration (S3 or FILE)
193193
base_location: Base location for the catalog
194194
"""
195-
from polaris.management import AwsStorageConfigInfo
195+
from apache_polaris.sdk.management import AwsStorageConfigInfo
196196

197197
# Build properties dict
198198
catalog_properties = {
@@ -256,7 +256,7 @@ def file_catalog(root_client, catalog_client):
256256
Catalog that always uses FILE storage for local testing.
257257
This fixture runs in any environment without external dependencies.
258258
"""
259-
from polaris.management import FileStorageConfigInfo
259+
from apache_polaris.sdk.management import FileStorageConfigInfo
260260

261261
catalog_name = f'file_catalog_{str(uuid.uuid4())[-10:]}'
262262
storage_config = FileStorageConfigInfo(storage_type="FILE", allowed_locations=["file:///tmp"])
@@ -273,7 +273,7 @@ def s3_catalog(root_client, catalog_client, test_bucket, aws_role_arn, aws_bucke
273273
Catalog that always uses S3 storage for AWS testing.
274274
Tests using this fixture should include @pytest.mark.skipif for AWS_TEST_ENABLED.
275275
"""
276-
from polaris.management import AwsStorageConfigInfo
276+
from apache_polaris.sdk.management import AwsStorageConfigInfo
277277

278278
catalog_name = f's3_catalog_{str(uuid.uuid4())[-10:]}'
279279
storage_config = AwsStorageConfigInfo(

regtests/t_pyspark/src/test_spark_sql_fine_grained_authz.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from py4j.protocol import Py4JJavaError
3232

3333
from iceberg_spark import IcebergSparkSession
34-
from polaris.management import PrincipalRole, CatalogRole, CatalogGrant, CatalogPrivilege, \
34+
from apache_polaris.sdk.management import PrincipalRole, CatalogRole, CatalogGrant, CatalogPrivilege, \
3535
AddGrantRequest, GrantCatalogRoleRequest, GrantPrincipalRoleRequest
3636

3737
# Import existing helper functions instead of copying them
@@ -45,7 +45,7 @@ def fine_grained_authz_test_catalog(root_client, catalog_client):
4545
Catalog specifically for fine-grained authorization testing.
4646
Does NOT assign catalog_admin to service_admin to avoid privilege inheritance issues.
4747
"""
48-
from polaris.management import FileStorageConfigInfo, Catalog, CatalogProperties, CreateCatalogRequest
48+
from apache_polaris.sdk.management import FileStorageConfigInfo, Catalog, CatalogProperties, CreateCatalogRequest
4949
from conftest import create_catalog_role
5050

5151
catalog_name = f'fine_grained_authz_test_catalog_{str(uuid.uuid4())[-10:]}'

regtests/t_pyspark/src/test_spark_sql_s3_with_privileges.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030

3131

3232
from iceberg_spark import IcebergSparkSession
33-
from polaris.catalog import CreateNamespaceRequest, CreateTableRequest, ModelSchema
34-
from polaris.catalog.api.iceberg_catalog_api import IcebergCatalogAPI
35-
from polaris.catalog.api.iceberg_o_auth2_api import IcebergOAuth2API
36-
from polaris.catalog.api_client import ApiClient as CatalogApiClient
37-
from polaris.catalog.configuration import Configuration
38-
from polaris.management import ApiClient as ManagementApiClient
39-
from polaris.management import PolarisDefaultApi, Principal, PrincipalRole, CatalogRole, \
33+
from apache_polaris.sdk.catalog import CreateNamespaceRequest, CreateTableRequest, ModelSchema
34+
from apache_polaris.sdk.catalog.api.iceberg_catalog_api import IcebergCatalogAPI
35+
from apache_polaris.sdk.catalog.api.iceberg_o_auth2_api import IcebergOAuth2API
36+
from apache_polaris.sdk.catalog.api_client import ApiClient as CatalogApiClient
37+
from apache_polaris.sdk.catalog.configuration import Configuration
38+
from apache_polaris.sdk.management import ApiClient as ManagementApiClient
39+
from apache_polaris.sdk.management import PolarisDefaultApi, Principal, PrincipalRole, CatalogRole, \
4040
CatalogGrant, CatalogPrivilege, ApiException, CreateCatalogRoleRequest, CreatePrincipalRoleRequest, \
4141
CreatePrincipalRequest, AddGrantRequest, GrantCatalogRoleRequest, GrantPrincipalRoleRequest, UpdateCatalogRequest
4242

0 commit comments

Comments
 (0)