class_docstr: `AutoMLStep` for SageMaker Pipelines Workflows.
class_docstr_tok: ["`","AutoMLStep","`","for","SageMaker","Pipelines","Workflows","."]
docstr: Get the best candidate model artifacts, image uri and env variables for the best model.
  
  Args:
      role (str): An AWS IAM role (either name or full ARN). The Amazon
          SageMaker AutoML jobs and APIs that create Amazon SageMaker
          endpoints use this role to access training data and model
          artifacts.
      sagemaker_session (sagemaker.session.Session): A SageMaker Session
          object, used for SageMaker interactions.
          If the best model will be used as part of ModelStep, then sagemaker_session
          should be class:`~sagemaker.workflow.pipeline_context.PipelineSession`. Example::
               model = Model(sagemaker_session=PipelineSession())
               model_step = ModelStep(step_args=model.register())
docstr_tok: ["Get","the","best","candidate","model","artifacts",",","image","uri","and","env","variables","for","the","best","model",".","Args",":","role","(","str",")",":","An","AWS","IAM","role","(","either","name","or","full","ARN",")",".","The","Amazon","SageMaker","AutoML","jobs","and","APIs","that","create","Amazon","SageMaker","endpoints","use","this","role","to","access","training","data","and","model","artifacts",".","sagemaker_session","(","sagemaker.session.Session",")",":","A","SageMaker","Session","object",",","used","for","SageMaker","interactions",".","If","the","best","model","will","be","used","as","part","of","ModelStep",",","then","sagemaker_session","should","be","class",":","`","~sagemaker.workflow.pipeline_context.PipelineSession","`",".","Example",":",":","model","=","Model","(","sagemaker_session=PipelineSession","(",")",")","model_step","=","ModelStep","(","step_args=model.register","(",")",")"]
code: def get_best_auto_ml_model(self, role, sagemaker_session=None):
      """Get the best candidate model artifacts, image uri and env variables for the best model.
  
      Args:
          role (str): An AWS IAM role (either name or full ARN). The Amazon
              SageMaker AutoML jobs and APIs that create Amazon SageMaker
              endpoints use this role to access training data and model
              artifacts.
          sagemaker_session (sagemaker.session.Session): A SageMaker Session
              object, used for SageMaker interactions.
              If the best model will be used as part of ModelStep, then sagemaker_session
              should be class:`~sagemaker.workflow.pipeline_context.PipelineSession`. Example::
                   model = Model(sagemaker_session=PipelineSession())
                   model_step = ModelStep(step_args=model.register())
      """
      inference_container = (
          self.properties.BestCandidate.InferenceContainers[0]
      )
      inference_container_environment = inference_container.Environment
      image = inference_container.Image
      model_data = inference_container.ModelDataUrl
      model = Model(
          image_uri=image,
          model_data=model_data,
          env={
              "MODEL_NAME": inference_container_environment[
                  "MODEL_NAME"
              ],
              "SAGEMAKER_DEFAULT_INVOCATIONS_ACCEPT": inference_container_environment[
                  "SAGEMAKER_DEFAULT_INVOCATIONS_ACCEPT"
              ],
              "SAGEMAKER_SUBMIT_DIRECTORY": inference_container_environment[
                  "SAGEMAKER_SUBMIT_DIRECTORY"
              ],
              "SAGEMAKER_INFERENCE_SUPPORTED": inference_container_environment[
                  "SAGEMAKER_INFERENCE_SUPPORTED"
              ],
              "SAGEMAKER_INFERENCE_OUTPUT": inference_container_environment[
                  "SAGEMAKER_INFERENCE_OUTPUT"
              ],
              "SAGEMAKER_PROGRAM": inference_container_environment[
                  "SAGEMAKER_PROGRAM"
              ],
          },
          sagemaker_session=sagemaker_session,
          role=role,
      )
  
      return model
  
file_path: sagemaker-python-sdk/src/sagemaker/workflow/automl_step.py
imports: from __future__ import absolute_import
  from typing import Union, Optional, List
  from sagemaker import Session, Model
  from sagemaker.exceptions import AutoMLStepInvalidModeError
  from sagemaker.workflow.entities import RequestType
  from sagemaker.workflow.pipeline_context import _JobStepArguments
  from sagemaker.workflow.properties import Properties
  from sagemaker.workflow.retry import RetryPolicy
  from sagemaker.workflow.steps import ConfigurableRetryStep, CacheConfig, Step, StepTypeEnum
  from sagemaker.workflow.utilities import validate_step_args_input, trim_request_dict
  from sagemaker.workflow.step_collections import StepCollection
label_desc: Use image node_id 5 for calling the AutoMLStep obj's underlying member method code with example usage: obj.get_best_auto_ml_model(role, sagemaker_session) and returns: model