Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions google/cloud/aiplatform/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
reservation_affinity_v1 as gca_reservation_affinity_v1,
)

_PROJECT_LOCATION_RE = re.compile(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)(/|$)"
)

VertexAiServiceClient = TypeVar(
"VertexAiServiceClient",
# v1beta1
Expand Down Expand Up @@ -399,9 +403,7 @@ def extract_project_and_location_from_parent(
Dict[str, str]
A project, location dict from provided parent resource name.
"""
parent_resources = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)(/|$)", parent
)
parent_resources = _PROJECT_LOCATION_RE.match(parent)
return parent_resources.groupdict() if parent_resources else {}


Expand Down