in pai/pipeline/types/artifact.py [0:0]
def from_resource_url(cls, resource_url):
"""Parse MaxCompute(ODPS) resource in url schema and returns artifact value and metadata.
Args:
resource_url: An ODPS(MaxCompute) table, tablePartition, offline-model or volume in url schema.
Returns:
tuple: A tuple of MaxCompute artifact value and artifact metadata.
"""
matches = cls.MaxComputeResourceUrlPattern.match(resource_url)
if not matches:
raise ValueError("Not support MaxCompute resource url format.")
resource_type = matches.group("resource_type")
project = matches.group("project")
if resource_type == "tables":
table = matches.group("resource_name")
partition = matches.group("sub_resource")
return (
MaxComputeTableArtifact(
project=project,
table=table,
partition=partition.strip("/") if partition else None,
),
ArtifactMetadataUtils.maxc_table(),
)
elif resource_type == "volumes":
volume = matches.group("resource_name")
sub_resource = matches.group("sub_resource").strip("/")
idx = sub_resource.find("/")
partition = sub_resource[:idx]
file_name = sub_resource[idx + 1 :]
return (
MaxComputeVolumeArtifact(
project=project,
volume=volume,
partition=partition,
file_name=file_name,
),
ArtifactMetadataUtils.maxc_volume(),
)
elif resource_type == "offlinemodels":
name = matches.group("resource_name")
return (
MaxComputeOfflineModelArtifact(
project=project,
offline_model=name,
),
ArtifactMetadataUtils.maxc_offlinemodel(),
)
else:
raise ValueError("Not support MaxCompute resource type :%s" % resource_type)