File tree Expand file tree Collapse file tree 4 files changed +23
-7
lines changed Expand file tree Collapse file tree 4 files changed +23
-7
lines changed Original file line number Diff line number Diff line change 17
17
from typing import List
18
18
19
19
_lock = threading .Lock ()
20
- MAX_LABELS_COUNT = 64
20
+
21
+ # The limit is 64 (https://cloud.google.com/bigquery/docs/labels-intro#requirements),
22
+ # but leave a few spare for internal labels to be added.
23
+ # See internal issue 386825477.
24
+ MAX_LABELS_COUNT = 64 - 8
25
+
21
26
_api_methods : List = []
22
27
_excluded_methods = ["__setattr__" , "__getattr__" ]
23
28
Original file line number Diff line number Diff line change @@ -373,10 +373,18 @@ def close(self):
373
373
"""Delete resources that were created with this session's session_id.
374
374
This includes BigQuery tables, remote functions and cloud functions
375
375
serving the remote functions."""
376
- self ._temp_storage_manager .clean_up_tables ()
377
- self ._remote_function_session .clean_up (
378
- self .bqclient , self .cloudfunctionsclient , self .session_id
379
- )
376
+
377
+ # Protect against failure when the Session is a fake for testing or
378
+ # failed to initialize.
379
+ temp_storage_manager = getattr (self , "_temp_storage_manager" , None )
380
+ if temp_storage_manager :
381
+ self ._temp_storage_manager .clean_up_tables ()
382
+
383
+ remote_function_session = getattr (self , "_remote_function_session" , None )
384
+ if remote_function_session :
385
+ self ._remote_function_session .clean_up (
386
+ self .bqclient , self .cloudfunctionsclient , self .session_id
387
+ )
380
388
381
389
def read_gbq (
382
390
self ,
Original file line number Diff line number Diff line change 16
16
17
17
from bigframes .core import log_adapter
18
18
19
- MAX_LABELS_COUNT = 64
19
+ # The limit is 64 (https://cloud.google.com/bigquery/docs/labels-intro#requirements),
20
+ # but leave a few spare for internal labels to be added.
21
+ # See internal issue 386825477.
22
+ MAX_LABELS_COUNT = 56
20
23
21
24
22
25
@pytest .fixture
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ def test_create_job_configs_labels_length_limit_met_and_labels_is_none():
114
114
job_configs_labels = None , api_methods = api_methods
115
115
)
116
116
assert labels is not None
117
- assert len (labels ) == 64
117
+ assert len (labels ) == log_adapter . MAX_LABELS_COUNT
118
118
assert "dataframe-head" in labels .values ()
119
119
120
120
You can’t perform that action at this time.
0 commit comments