Skip to content

AttributeError: 'NoneType' object has no attribute '_create_model_request' #2993

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
neilmcguigan opened this issue Mar 12, 2022 · 5 comments
Closed
Labels
component: hosting Relates to the SageMaker Hosting Platform component: model Relates to SageMaker Model Pending information type: bug

Comments

@neilmcguigan
Copy link

Describe the bug
Create a model without specifying sagemaker_session and you get this error

To reproduce

model = Model(
    image_uri = "246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-scikit-learn:0.23-1-cpu-py3",
    model_data = my_model_data_url,
    role = role_arn,
    source_dir = s3_url_to_targz,
    entry_point= "encoder.py"
)

model_step = CreateModelStep(
    name="createmodel",
    model = model,
    inputs = CreateModelInput(instance_type = "ml.m5.large")
)

pipeline = Pipeline(name="pipeline1", steps=[model_step])
pipeline.upsert(role_arn=role_arn)
pipeline.start()

if you add sagemaker_session = Session() to Model() it magically works

Expected behavior
work without specifying sagemaker_session

Screenshots or logs

    request_dict = self.model.sagemaker_session._create_model_request(
AttributeError: 'NoneType' object has no attribute '_create_model_request'

System information
A description of your system. Please provide:

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

Additional context
Add any other context about the problem here.

@mouhannadali
Copy link

any update here?

@timxieICN
Copy link

Running into the same issue. Any update?

@bernadinel
Copy link

any updates ? got the same issue

@davidbrochart
Copy link
Collaborator

There is a method to set a default session:

def _init_sagemaker_session_if_does_not_exist(self, instance_type=None):

But it doesn't seem to be called early enough.
Since it is accessed from another place:
request_dict = self.model.sagemaker_session._create_model_request(

Maybe a solution would be for the sagemaker_session to be a @property of the model, so that it can be initialized lazily by calling _init_sagemaker_session_if_does_not_exist()?

@knikure knikure added component: model Relates to SageMaker Model component: hosting Relates to the SageMaker Hosting Platform labels Apr 11, 2024
@pintaoz-aws
Copy link
Contributor

Fixed by #5062

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hosting Relates to the SageMaker Hosting Platform component: model Relates to SageMaker Model Pending information type: bug
Projects
None yet
Development

No branches or pull requests

7 participants