Skip to content

Commit b03e44f

Browse files
authored
fix: use dictionaries to avoid problematic google.iam namespace (#1611)
1 parent 293f676 commit b03e44f

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

bigframes/clients.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import google.api_core.exceptions
2525
import google.api_core.retry
2626
from google.cloud import bigquery_connection_v1, resourcemanager_v3
27-
from google.iam.v1 import iam_policy_pb2, policy_pb2
2827

2928
logger = logging.getLogger(__name__)
3029

@@ -161,7 +160,9 @@ def _ensure_iam_binding(
161160
project = f"projects/{project_id}"
162161
service_account = f"serviceAccount:{service_account_id}"
163162
role = f"roles/{iam_role}"
164-
request = iam_policy_pb2.GetIamPolicyRequest(resource=project)
163+
request = {
164+
"resource": project
165+
} # Use a dictionary to avoid problematic google.iam namespace package.
165166
policy = self._cloud_resource_manager_client.get_iam_policy(request=request)
166167

167168
# Check if the binding already exists, and if does, do nothing more
@@ -171,9 +172,15 @@ def _ensure_iam_binding(
171172
return
172173

173174
# Create a new binding
174-
new_binding = policy_pb2.Binding(role=role, members=[service_account])
175+
new_binding = {
176+
"role": role,
177+
"members": [service_account],
178+
} # Use a dictionary to avoid problematic google.iam namespace package.
175179
policy.bindings.append(new_binding)
176-
request = iam_policy_pb2.SetIamPolicyRequest(resource=project, policy=policy)
180+
request = {
181+
"resource": project,
182+
"policy": policy,
183+
} # Use a dictionary to avoid problematic google.iam namespace package.
177184
self._cloud_resource_manager_client.set_iam_policy(request=request)
178185

179186
# We would wait for the IAM policy change to take effect

bigframes/functions/function.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
from bigframes.session import Session
2828

2929
import google.api_core.exceptions
30-
import google.api_core.retry
3130
from google.cloud import bigquery
32-
import google.iam.v1
3331

3432
import bigframes.core.compile.ibis_types
3533
import bigframes.dtypes

0 commit comments

Comments
 (0)