Skip to content

model.register() repackages model_data to session's default bucket when being passed entry_point, source_dir and model_data #3396

Open
@ViktorMalesevic

Description

@ViktorMalesevic

Describe the bug
A clear and concise description of what the bug is.

model.register() repackages model_data to sagemaker or pipeline session's default_bucket when being passed entry_point, source_dir and model_data, instead of bucket provided through model_data

To reproduce
A clear, step-by-step set of instructions to reproduce the bug.

Step to register model with custom scripts (entry_point and source_dir) and model_data

import boto3
import sagemaker
from sagemaker.model import Model


boto_session = boto3.session.Session()
region = boto_session.region_name
sagemaker_session = sagemaker.Session()
role = get_execution_role()

model_package_group_name="MY_PACKAGE_GROUP_NAME"

image_uri = sagemaker.image_uris.retrieve(
     framework="pytorch",
     region=region,
     version="1.11.0",
     py_version="py38",
     image_scope="inference",
     instance_type="ml.g4dn.xlarge",
 )

model = Model(
    image_uri=image_uri,
    model_data="s3://MY_BUCKET/somepath/model.tar.gz",
    entry_point="inference.py",
    source_dir="scripts/",
    sagemaker_session=pipeline_session,
    role=role,
)

model.register(
    model_package_group_name=model_package_group_name,
    domain="NATURAL_LANGUAGE_PROCESSING",
    content_types=["text/csv","application/json","application/jsonlines"],
    response_types=["text/csv","application/json","application/jsonlines"],
    inference_instances=["ml.g4dn.xlarge","ml.m5.xlarge","ml.c5.xlarge"],
    transform_instances=["ml.g4dn.xlarge","ml.m5.xlarge","ml.c5.xlarge"],
)

Step to inspect model container definition in SageMaker Model Registry

response = client.list_model_packages(ModelPackageGroupName=model_package_group_name)
response = client.describe_model_package(
    ModelPackageName=response['ModelPackageSummaryList'][0]['ModelPackageArn']
)
print(response)

Expected behavior
A clear and concise description of what you expected to happen.

We should get in response:

...
'InferenceSpecification': {'Containers': [...
'ModelDataUrl': 's3://MY_BUCKET/somepath/model.tar.gz'
....
]

Screenshots or logs
If applicable, add screenshots or logs to help explain your problem.

What we get instead:

...
'InferenceSpecification': {'Containers': [...
'ModelDataUrl': 's3://SAGEMAKER_SESSION_DEFAULT_BUCKET/somepath/model.tar.gz'
....
]

System information
A description of your system. Please provide:

  • SageMaker Python SDK version:
    '2.107.0'
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans):
    Observed for PyTorch, but issues expected for all Frameworks
  • Framework version:
    1.11.0 but likely irrelevant
  • Python version:
    py38 but likely irrelevant
  • CPU or GPU:
    GPU but likely irrelevant
  • Custom Docker image (Y/N):
    N

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions