Skip to content

SageMaker Session not created by default upon Model Class Instantiation #1184

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
matthewfollegot opened this issue Dec 18, 2019 · 2 comments
Closed
Labels
status: pending release The fix have been merged but not yet released to PyPI type: bug

Comments

@matthewfollegot
Copy link
Contributor

matthewfollegot commented Dec 18, 2019

System Information

  • Framework (e.g. TensorFlow) / Algorithm (e.g. KMeans): Sagemaker / sagemaker.model.Model
  • Framework Version: stable
  • Python Version: 3.6
  • CPU or GPU: CPU
  • Python SDK Version:
  • Are you using a custom image: Yes

Describe the problem

When creating a model, sagemaker.model.Model, if a sagemaker_session is not specified, an AttributeError: 'NoneType' object has no attribute 'create_model' is raised when invoking one of the model's functions. In the docs, also pasted below, it specifies that if the parameter is not specified, one is created. This did not work and I can confirm because when I passed in a valid sagemaker_session, the code worked fine.

sagemaker_session (sagemaker.session.Session) – A SageMaker Session object, used for SageMaker interactions (default: None). If not specified, one is created using the default AWS configuration chain.

Note: created a PR for this issue here

Minimal repro / logs

AttributeError                            Traceback (most recent call last)
<ipython-input-4-b38a2118e690> in <module>()
      3     target_data_s3_location='s3://pd-ds-workbench-sagemaker-stg/projects/responder_recommendations/data/output',
      4     instance_type='ml.m4.xlarge',
----> 5     instance_count=1
      6 )
~/SageMaker/ds-python-utils/dsutils/ml/model.py in get_predictions_s3(self, input_data_s3_location, target_data_s3_location, instance_type, instance_count, wait)
    136             instance_type=instance_type,
    137             output_path=target_data_s3_location,
--> 138             tags=self.aws_tags()
    139         )
    140 
~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/model.py in transformer(self, instance_count, instance_type, strategy, assemble_with, output_path, output_kms_key, accept, env, max_concurrent_transforms, max_payload, tags, volume_kms_key)
    520                 attached to the ML compute instance (default: None).
    521         """
--> 522         self._create_sagemaker_model(instance_type, tags=tags)
    523         if self.enable_network_isolation():
    524             env = None
~/anaconda3/envs/python3/lib/python3.6/site-packages/sagemaker/model.py in _create_sagemaker_model(self, instance_type, accelerator_type, tags)
    186         self.name = self.name or utils.name_from_image(container_def["Image"])
    187         enable_network_isolation = self.enable_network_isolation()
--> 188         self.sagemaker_session.create_model(
    189             self.name,
    190             self.role,
AttributeError: 'NoneType' object has no attribute 'create_model'
  • Exact command to reproduce: Call one of the sagemaker.model.Model class methods without specifying a sagemaker_session when instantiating the object (I called sagemaker.model.Model.transformer()).
@matthewfollegot matthewfollegot changed the title SageMaker Session not getting created by default SageMaker Session not created by default upon Model Class Instantiation Dec 18, 2019
matthewfollegot added a commit to matthewfollegot/sagemaker-python-sdk that referenced this issue Dec 18, 2019
@nadiaya
Copy link
Contributor

nadiaya commented Dec 19, 2019

Thank you for your contribution!

laurenyu pushed a commit to laurenyu/sagemaker-python-sdk that referenced this issue Feb 12, 2020
@laurenyu laurenyu added the status: pending release The fix have been merged but not yet released to PyPI label Feb 12, 2020
@laurenyu
Copy link
Contributor

fix was released in v1.50.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pending release The fix have been merged but not yet released to PyPI type: bug
Projects
None yet
Development

No branches or pull requests

3 participants