Skip to content

DJL not passing through sagemaker session when downloading s3 artifact #3769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jbarz1 opened this issue Apr 7, 2023 · 1 comment · Fixed by #3775
Closed

DJL not passing through sagemaker session when downloading s3 artifact #3769

jbarz1 opened this issue Apr 7, 2023 · 1 comment · Fixed by #3775
Assignees

Comments

@jbarz1
Copy link
Contributor

jbarz1 commented Apr 7, 2023

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

I pass in a sagemaker session with region set into DJLModel but when downloading the s3 artifact, it complains about region not being set

I think the self.sagemaker_session needs to be passed in here.

model_config = json.loads(s3.S3Downloader.read_file(config_file))

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

region='us-west-2'
boto_session = boto3.Session(profile_name='default', region_name=region)
session = Session(boto_session=boto_session)

model = DJLModel(
    pretrained_model_location,
    role,
    task="text-generation",
    number_of_partitions=2,
    data_type="fp16",
    sagemaker_session=session,
)

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

pass

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

ValueError                                Traceback (most recent call last)
/tmp/ipykernel_12/3966350342.py in <module>
      7     number_of_partitions=2,
      8     data_type="fp16",
----> 9     sagemaker_session=session,
     10 )
     11 

/usr/local/lib/python3.7/site-packages/sagemaker/djl_inference/model.py in __new__(cls, model_id, *args, **kwargs)
    199             )
    200         if model_id.startswith("s3://"):
--> 201             model_config = _get_model_config_properties_from_s3(model_id)
    202         else:
    203             model_config = _get_model_config_properties_from_hf(model_id)

/usr/local/lib/python3.7/site-packages/sagemaker/djl_inference/model.py in _get_model_config_properties_from_s3(model_s3_uri)
    139     """Placeholder docstring"""
    140 
--> 141     s3_files = s3.S3Downloader.list(model_s3_uri)
    142     model_config = None
    143     for config in defaults.VALID_MODEL_CONFIG_FILES:

/usr/local/lib/python3.7/site-packages/sagemaker/s3.py in list(s3_uri, sagemaker_session)
    179             [str]: The list of S3 URIs in the given S3 base uri.
    180         """
--> 181         sagemaker_session = sagemaker_session or Session()
    182         bucket, key_prefix = parse_s3_url(url=s3_uri)
    183 

/usr/local/lib/python3.7/site-packages/sagemaker/session.py in __init__(self, boto_session, sagemaker_client, sagemaker_runtime_client, sagemaker_featurestore_runtime_client, default_bucket, settings, sagemaker_metrics_client, sagemaker_config)
    215             sagemaker_featurestore_runtime_client=sagemaker_featurestore_runtime_client,
    216             sagemaker_metrics_client=sagemaker_metrics_client,
--> 217             sagemaker_config=sagemaker_config,
    218         )
    219 

/usr/local/lib/python3.7/site-packages/sagemaker/session.py in _initialize(self, boto_session, sagemaker_client, sagemaker_runtime_client, sagemaker_featurestore_runtime_client, sagemaker_metrics_client, sagemaker_config)
    237         if self._region_name is None:
    238             raise ValueError(
--> 239                 "Must setup local AWS configuration with a region supported by SageMaker."
    240             )
    241 

ValueError: Must setup local AWS configuration with a region supported by SageMaker.

System information
A description of your system. Please provide:

  • SageMaker Python SDK version: 2.145.0
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans): DJL
  • Framework version:
  • Python version:
  • CPU or GPU:
  • Custom Docker image (Y/N):N

Additional context
Add any other context about the problem here.

@mufaddal-rohawala
Copy link
Member

Hi thanks for bringing this to Sagemaker's attention! This is a fairly new offering and our team is looking into this issue and hope to reply back soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants