Skip to content

Commit 2c1cd45

Browse files
DevStephanietswast
andauthored
chore: add BigQuery locations to bigframes/constants.py (#578)
* chore: add BigQuery locations to bigframes/constants.py * Apply suggestions from code review --------- Co-authored-by: Tim Sweña (Swast) <swast@google.com>
1 parent 8add6b1 commit 2c1cd45

File tree

3 files changed

+75
-76
lines changed

3 files changed

+75
-76
lines changed

bigframes/constants.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,68 @@
2727
ABSTRACT_METHOD_ERROR_MESSAGE = f"Abstract method. You have likely encountered a bug. Please share this stacktrace and how you reached it with the BigQuery DataFrames team. {FEEDBACK_LINK}"
2828

2929
DEFAULT_EXPIRATION = datetime.timedelta(days=7)
30+
31+
# https://cloud.google.com/bigquery/docs/locations
32+
ALL_BIGQUERY_LOCATIONS = frozenset(
33+
{
34+
"us-east5",
35+
"us-south1",
36+
"us-central1",
37+
"us-west4",
38+
"us-west2",
39+
"northamerica-northeast1",
40+
"us-east4",
41+
"us-west1",
42+
"us-west3",
43+
"southamerica-east1",
44+
"southamerica-west1",
45+
"us-east1",
46+
"northamerica-northeast2",
47+
"asia-south2",
48+
"asia-east2",
49+
"asia-southeast2",
50+
"australia-southeast2",
51+
"asia-south1",
52+
"asia-northeast2",
53+
"asia-northeast3",
54+
"asia-southeast1",
55+
"australia-southeast1",
56+
"asia-east1",
57+
"asia-northeast1",
58+
"europe-west1",
59+
"europe-west10",
60+
"europe-north1",
61+
"europe-west3",
62+
"europe-west2",
63+
"europe-southwest1",
64+
"europe-west8",
65+
"europe-west4",
66+
"europe-west9",
67+
"europe-west12",
68+
"europe-central2",
69+
"europe-west6",
70+
"me-central2",
71+
"me-central1",
72+
"me-west1",
73+
"me-central2",
74+
"me-central1",
75+
"me-west1",
76+
"africa-south1",
77+
}
78+
)
79+
80+
# https://cloud.google.com/storage/docs/regional-endpoints
81+
REP_ENABLED_BIGQUERY_LOCATIONS = frozenset(
82+
{
83+
"me-central2",
84+
"europe-west9",
85+
"europe-west3",
86+
"us-east4",
87+
"us-west1",
88+
}
89+
)
90+
91+
# https://cloud.google.com/storage/docs/locational-endpoints
92+
LEP_ENABLED_BIGQUERY_LOCATIONS = frozenset(
93+
ALL_BIGQUERY_LOCATIONS - REP_ENABLED_BIGQUERY_LOCATIONS
94+
)

tests/config.py

Lines changed: 0 additions & 72 deletions
This file was deleted.

tests/system/large/test_location.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import pytest
1919

2020
import bigframes
21+
import bigframes.constants
2122
import bigframes.session.clients
22-
from tests import config
2323

2424

2525
def _assert_bq_execution_location(session: bigframes.Session):
@@ -66,7 +66,11 @@ def test_bq_location_default():
6666
_assert_bq_execution_location(session)
6767

6868

69-
@pytest.mark.parametrize("bigquery_location", config.ALL_BIGQUERY_LOCATIONS)
69+
@pytest.mark.parametrize(
70+
"bigquery_location",
71+
# Sort the set to avoid nondeterminism.
72+
sorted(bigframes.constants.ALL_BIGQUERY_LOCATIONS),
73+
)
7074
def test_bq_location(bigquery_location):
7175
session = bigframes.Session(
7276
context=bigframes.BigQueryOptions(location=bigquery_location)
@@ -85,7 +89,8 @@ def test_bq_location(bigquery_location):
8589

8690
@pytest.mark.parametrize(
8791
"bigquery_location",
88-
config.REP_ENABLED_BIGQUERY_LOCATIONS,
92+
# Sort the set to avoid nondeterminism.
93+
sorted(bigframes.constants.REP_ENABLED_BIGQUERY_LOCATIONS),
8994
)
9095
def test_bq_rep_endpoints(bigquery_location):
9196
session = bigframes.Session(
@@ -108,7 +113,8 @@ def test_bq_rep_endpoints(bigquery_location):
108113

109114
@pytest.mark.parametrize(
110115
"bigquery_location",
111-
config.LEP_ENABLED_BIGQUERY_LOCATIONS,
116+
# Sort the set to avoid nondeterminism.
117+
sorted(bigframes.constants.LEP_ENABLED_BIGQUERY_LOCATIONS),
112118
)
113119
def test_bq_lep_endpoints(bigquery_location):
114120
# We are not testing BigFrames Session for LEP endpoints because it involves

0 commit comments

Comments
 (0)