Skip to content

Conversation

@mollyheamazon
Copy link
Contributor

@mollyheamazon mollyheamazon commented May 1, 2025

*Issue #289 *

Description of changes:
I added the extract_name_mapping variable and logic that extracts HubName from HubContentArn and ImageName from ImageVersionArn. This variable is similar to custom_key_mapping, but is a parallel condition.

Tests done:

from sagemaker_core.resources import HubContent

models = HubContent.get_all(
    hub_name="SageMakerPublicHub",
    hub_content_type="Model",
    name_contains="huggingface"
)

for model in models:
    print(model.hub_content_name)
from sagemaker_core.resources import ImageVersion

images = ImageVersion.get_all(
    image_name="sagemaker-core"
)

for image in images:
    print(image.creation_time)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mollyheamazon mollyheamazon requested a review from a team as a code owner May 1, 2025 18:58
@mollyheamazon mollyheamazon requested a review from rsareddy0329 May 1, 2025 18:58
if self.custom_key_mapping:
init_data = {self.custom_key_mapping.get(k, k): v for k, v in init_data.items()}

# Extract name from arn. Currently implemented for HubContent and ImageVersion
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this only work for these 2 cases or applies to all arns?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially work for other arns, but it depends on the structure of arn and what we want to extract. HubContentArn and ImageVersionArn shares the same structure where there is "hub-content/" and "image-version/" string before the hub name and image name we want to extract.

@mollyheamazon mollyheamazon merged commit e52a926 into aws:main May 8, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants