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
10 changes: 6 additions & 4 deletions google/cloud/aiplatform/metadata/schema/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
from typing import Optional, Dict, List
from dataclasses import dataclass

_RESOURCE_NAME_REGEX = re.compile(
r"^projects/(?P<project>[\w-]+)/locations/(?P<location>[\w-]+)"
r"(?:/metadataStores/(?P<store>[\w-]+))?/[\w-]+/(?P<id>[\w-]+)(?P<version>@[\w-]+)?$"
)


@dataclass
class PredictSchemata:
Expand Down Expand Up @@ -349,10 +354,7 @@ def create_uri_from_resource_name(resource_name: str) -> str:
ValueError: If resource_name does not match the specified format.
"""
# TODO: support nested resource names such as models/123/evaluations/456
match_results = re.match(
r"^projects\/(?P<project>[\w-]+)\/locations\/(?P<location>[\w-]+)(\/metadataStores\/(?P<store>[\w-]+))?\/[\w-]+\/(?P<id>[\w-]+)(?P<version>@[\w-]+)?$",
resource_name,
)
match_results = _RESOURCE_NAME_REGEX.match(resource_name)
if not match_results:
raise ValueError(f"Invalid resource_name format for {resource_name}.")

Expand Down