class_docstr: A DJL SageMaker ``Model`` that can be deployed to a SageMaker ``Endpoint``.
docstr: Deploy this ``Model`` to an ``Endpoint`` and optionally return a ``Predictor``.
  
  Create a SageMaker ``Model`` and ``EndpointConfig``, and deploy an
  ``Endpoint`` from this ``Model``. If ``self.predictor_cls`` is not None,
  this method returns the result of invoking ``self.predictor_cls`` on
  the created endpoint name.
  
  The name of the created model is accessible in the ``name`` field of
  this ``Model`` after deploy returns
  
  The name of the created endpoint is accessible in the
  ``endpoint_name`` field of this ``Model`` after deploy returns.
  
  Args:
      instance_type (str): The EC2 instance type to deploy this Model to.
          For example, 'ml.p4d.24xlarge'.
      initial_instance_count (int): The initial number of instances to run
          in the ``Endpoint`` created from this ``Model``. It needs to be at least 1 (
          default: 1)
      serializer (:class:`~sagemaker.serializers.BaseSerializer`): A
          serializer object, used to encode data for an inference endpoint
          (default: None). If ``serializer`` is not None, then
          ``serializer`` will override the default serializer. The
          default serializer is set by the ``predictor_cls``.
      deserializer (:class:`~sagemaker.deserializers.BaseDeserializer`): A
          deserializer object, used to decode data from an inference
          endpoint (default: None). If ``deserializer`` is not None, then
          ``deserializer`` will override the default deserializer. The
          default deserializer is set by the ``predictor_cls``.
      endpoint_name (str): The name of the endpoint to create (default:
          None). If not specified, a unique endpoint name will be created.
      tags (Optional[Tags]): The list of tags to attach to this
          specific endpoint.
      kms_key (str): The ARN of the KMS key that is used to encrypt the
          data on the storage volume attached to the instance hosting the
          endpoint.
      wait (bool): Whether the call should wait until the deployment of
          this model completes (default: True).
      data_capture_config (sagemaker.model_monitor.DataCaptureConfig): Specifies
          configuration related to Endpoint data capture for use with
          Amazon SageMaker Model Monitoring. Default: None.
      volume_size (int): The size, in GB, of the ML storage volume attached to individual
          inference instance associated with the production variant. Currenly only Amazon EBS
          gp2 storage volumes are supported.
      model_data_download_timeout (int): The timeout value, in seconds, to download and
          extract model data from Amazon S3 to the individual inference instance associated
          with this production variant.
      container_startup_health_check_timeout (int): The timeout value, in seconds, for your
          inference container to pass health check by SageMaker Hosting. For more information
          about health check see:
          https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code
          .html#your-algorithms-inference-algo-ping-requests
  
  Returns:
      callable[string, sagemaker.session.Session] or None: Invocation of
          ``self.predictor_cls`` on the created endpoint name, if ``self.predictor_cls``
          is not None. Otherwise, return None.
docstr_tok: ["Deploy","this","``","Model","``","to","an","``","Endpoint","``","and","optionally","return","a","``","Predictor","``",".","Create","a","SageMaker","``","Model","``","and","``","EndpointConfig","``",",","and","deploy","an","``","Endpoint","``","from","this","``","Model","``",".","If","``","self.predictor_cls","``","is","not","None",",","this","method","returns","the","result","of","invoking","``","self.predictor_cls","``","on","the","created","endpoint","name",".","The","name","of","the","created","model","is","accessible","in","the","``","name","``","field","of","this","``","Model","``","after","deploy","returns","The","name","of","the","created","endpoint","is","accessible","in","the","``","endpoint_name","``","field","of","this","``","Model","``","after","deploy","returns",".","Args",":","instance_type","(","str",")",":","The","EC2","instance","type","to","deploy","this","Model","to",".","For","example",",","'ml.p4d.24xlarge","'",".","initial_instance_count","(","int",")",":","The","initial","number","of","instances","to","run","in","the","``","Endpoint","``","created","from","this","``","Model","``",".","It","needs","to","be","at","least","1","(","default",":","1",")","serializer","(",":","class",":","`","~sagemaker.serializers.BaseSerializer","`",")",":","A","serializer","object",",","used","to","encode","data","for","an","inference","endpoint","(","default",":","None",")",".","If","``","serializer","``","is","not","None",",","then","``","serializer","``","will","override","the","default","serializer",".","The","default","serializer","is","set","by","the","``","predictor_cls","``",".","deserializer","(",":","class",":","`","~sagemaker.deserializers.BaseDeserializer","`",")",":","A","deserializer","object",",","used","to","decode","data","from","an","inference","endpoint","(","default",":","None",")",".","If","``","deserializer","``","is","not","None",",","then","``","deserializer","``","will","override","the","default","deserializer",".","The","default","deserializer","is","set","by","the","``","predictor_cls","``",".","endpoint_name","(","str",")",":","The","name","of","the","endpoint","to","create","(","default",":","None",")",".","If","not","specified",",","a","unique","endpoint","name","will","be","created",".","tags","(","Optional","[","Tags","]",")",":","The","list","of","tags","to","attach","to","this","specific","endpoint",".","kms_key","(","str",")",":","The","ARN","of","the","KMS","key","that","is","used","to","encrypt","the","data","on","the","storage","volume","attached","to","the","instance","hosting","the","endpoint",".","wait","(","bool",")",":","Whether","the","call","should","wait","until","the","deployment","of","this","model","completes","(","default",":","True",")",".","data_capture_config","(","sagemaker.model_monitor.DataCaptureConfig",")",":","Specifies","configuration","related","to","Endpoint","data","capture","for","use","with","Amazon","SageMaker","Model","Monitoring",".","Default",":","None",".","volume_size","(","int",")",":","The","size",",","in","GB",",","of","the","ML","storage","volume","attached","to","individual","inference","instance","associated","with","the","production","variant",".","Currenly","only","Amazon","EBS","gp2","storage","volumes","are","supported",".","model_data_download_timeout","(","int",")",":","The","timeout","value",",","in","seconds",",","to","download","and","extract","model","data","from","Amazon","S3","to","the","individual","inference","instance","associated","with","this","production","variant",".","container_startup_health_check_timeout","(","int",")",":","The","timeout","value",",","in","seconds",",","for","your","inference","container","to","pass","health","check","by","SageMaker","Hosting",".","For","more","information","about","health","check","see",":","https",":","\/\/docs.aws.amazon.com\/sagemaker\/latest\/dg\/your-algorithms-inference-code",".html","#","your-algorithms-inference-algo-ping-requests","Returns",":","callable","[","string",",","sagemaker.session.Session","]","or","None",":","Invocation","of","``","self.predictor_cls","``","on","the","created","endpoint","name",",","if","``","self.predictor_cls","``","is","not","None",".","Otherwise",",","return","None","."]
code: def deploy(
      self,
      instance_type,
      initial_instance_count=1,
      serializer=None,
      deserializer=None,
      endpoint_name=None,
      tags=None,
      kms_key=None,
      wait=True,
      data_capture_config=None,
      volume_size=None,
      model_data_download_timeout=None,
      container_startup_health_check_timeout=None,
      **kwargs,
  ):
      """Deploy this ``Model`` to an ``Endpoint`` and optionally return a ``Predictor``.
  
      Create a SageMaker ``Model`` and ``EndpointConfig``, and deploy an
      ``Endpoint`` from this ``Model``. If ``self.predictor_cls`` is not None,
      this method returns the result of invoking ``self.predictor_cls`` on
      the created endpoint name.
  
      The name of the created model is accessible in the ``name`` field of
      this ``Model`` after deploy returns
  
      The name of the created endpoint is accessible in the
      ``endpoint_name`` field of this ``Model`` after deploy returns.
  
      Args:
          instance_type (str): The EC2 instance type to deploy this Model to.
              For example, 'ml.p4d.24xlarge'.
          initial_instance_count (int): The initial number of instances to run
              in the ``Endpoint`` created from this ``Model``. It needs to be at least 1 (
              default: 1)
          serializer (:class:`~sagemaker.serializers.BaseSerializer`): A
              serializer object, used to encode data for an inference endpoint
              (default: None). If ``serializer`` is not None, then
              ``serializer`` will override the default serializer. The
              default serializer is set by the ``predictor_cls``.
          deserializer (:class:`~sagemaker.deserializers.BaseDeserializer`): A
              deserializer object, used to decode data from an inference
              endpoint (default: None). If ``deserializer`` is not None, then
              ``deserializer`` will override the default deserializer. The
              default deserializer is set by the ``predictor_cls``.
          endpoint_name (str): The name of the endpoint to create (default:
              None). If not specified, a unique endpoint name will be created.
          tags (Optional[Tags]): The list of tags to attach to this
              specific endpoint.
          kms_key (str): The ARN of the KMS key that is used to encrypt the
              data on the storage volume attached to the instance hosting the
              endpoint.
          wait (bool): Whether the call should wait until the deployment of
              this model completes (default: True).
          data_capture_config (sagemaker.model_monitor.DataCaptureConfig): Specifies
              configuration related to Endpoint data capture for use with
              Amazon SageMaker Model Monitoring. Default: None.
          volume_size (int): The size, in GB, of the ML storage volume attached to individual
              inference instance associated with the production variant. Currenly only Amazon EBS
              gp2 storage volumes are supported.
          model_data_download_timeout (int): The timeout value, in seconds, to download and
              extract model data from Amazon S3 to the individual inference instance associated
              with this production variant.
          container_startup_health_check_timeout (int): The timeout value, in seconds, for your
              inference container to pass health check by SageMaker Hosting. For more information
              about health check see:
              https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-inference-code
              .html#your-algorithms-inference-algo-ping-requests
  
      Returns:
          callable[string, sagemaker.session.Session] or None: Invocation of
              ``self.predictor_cls`` on the created endpoint name, if ``self.predictor_cls``
              is not None. Otherwise, return None.
      """
  
      instance_family = instance_type.rsplit(".", 1)[0]
      if instance_family not in defaults.ALLOWED_INSTANCE_FAMILIES:
          raise ValueError(
              f"Invalid instance type. DJLModels only support deployment to instances"
              f"with GPUs. Supported instance families are {defaults.ALLOWED_INSTANCE_FAMILIES}"
          )
  
      return super(DJLModel, self).deploy(
          initial_instance_count=initial_instance_count,
          instance_type=instance_type,
          serializer=serializer,
          deserializer=deserializer,
          endpoint_name=endpoint_name,
          tags=format_tags(tags),
          kms_key=kms_key,
          wait=wait,
          data_capture_config=data_capture_config,
          volume_size=volume_size,
          model_data_download_timeout=model_data_download_timeout,
          container_startup_health_check_timeout=container_startup_health_check_timeout,
          **kwargs,
      )
  
imports: from __future__ import absolute_import
  import json
  import logging
  import os.path
  import urllib.request
  from json import JSONDecodeError
  from urllib.error import HTTPError, URLError
  from enum import Enum
  from typing import Optional, Union, Dict, Any, List
  import sagemaker
  from sagemaker import s3, Predictor, image_uris, fw_utils
  from sagemaker.deserializers import JSONDeserializer, BaseDeserializer
  from sagemaker.djl_inference import defaults
  from sagemaker.model import FrameworkModel
  from sagemaker.s3_utils import s3_path_join
  from sagemaker.serializers import JSONSerializer, BaseSerializer
  from sagemaker.session import Session
  from sagemaker.utils import _tmpdir, _create_or_update_code_dir, format_tags
  from sagemaker.workflow.entities import PipelineVariable
  from sagemaker.estimator import Estimator
  from sagemaker.s3 import S3Uploader
label_desc: Use image node_id 8 for calling the DJLModel obj's underlying member method code with example usage: obj.deploy(instance_type, initial_instance_count, serializer, deserializer, endpoint_name, tags, kms_key, wait, data_capture_config, volume_size, model_data_download_timeout, container_startup_health_check_timeout) and returns: super