From c937e41d8c761986ab2debf5a9584d9d738fe631 Mon Sep 17 00:00:00 2001 From: Tim Swena Date: Thu, 10 Apr 2025 16:42:42 -0500 Subject: [PATCH] fix: use dictionaries to avoid problematic google.iam namespace --- bigframes/clients.py | 15 +++++++++++---- bigframes/functions/function.py | 2 -- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bigframes/clients.py b/bigframes/clients.py index 6b331d6fef..f1f6d686fd 100644 --- a/bigframes/clients.py +++ b/bigframes/clients.py @@ -24,7 +24,6 @@ import google.api_core.exceptions import google.api_core.retry from google.cloud import bigquery_connection_v1, resourcemanager_v3 -from google.iam.v1 import iam_policy_pb2, policy_pb2 logger = logging.getLogger(__name__) @@ -161,7 +160,9 @@ def _ensure_iam_binding( project = f"projects/{project_id}" service_account = f"serviceAccount:{service_account_id}" role = f"roles/{iam_role}" - request = iam_policy_pb2.GetIamPolicyRequest(resource=project) + request = { + "resource": project + } # Use a dictionary to avoid problematic google.iam namespace package. policy = self._cloud_resource_manager_client.get_iam_policy(request=request) # Check if the binding already exists, and if does, do nothing more @@ -171,9 +172,15 @@ def _ensure_iam_binding( return # Create a new binding - new_binding = policy_pb2.Binding(role=role, members=[service_account]) + new_binding = { + "role": role, + "members": [service_account], + } # Use a dictionary to avoid problematic google.iam namespace package. policy.bindings.append(new_binding) - request = iam_policy_pb2.SetIamPolicyRequest(resource=project, policy=policy) + request = { + "resource": project, + "policy": policy, + } # Use a dictionary to avoid problematic google.iam namespace package. self._cloud_resource_manager_client.set_iam_policy(request=request) # We would wait for the IAM policy change to take effect diff --git a/bigframes/functions/function.py b/bigframes/functions/function.py index 30b3d23056..858c25fada 100644 --- a/bigframes/functions/function.py +++ b/bigframes/functions/function.py @@ -27,9 +27,7 @@ from bigframes.session import Session import google.api_core.exceptions -import google.api_core.retry from google.cloud import bigquery -import google.iam.v1 import bigframes.core.compile.ibis_types import bigframes.dtypes