class_docstr: Base class of Amazon SageMaker Explainability API model monitors.
  
  This class is an ``abstract base class``, please instantiate its subclasses
  if you want to monitor bias metrics or feature attribution of an endpoint.
class_docstr_tok: ["Base","class","of","Amazon","SageMaker","Explainability","API","model","monitors",".","This","class","is","an","``","abstract","base","class","``",",","please","instantiate","its","subclasses","if","you","want","to","monitor","bias","metrics","or","feature","attribution","of","an","endpoint","."]
docstr: Build the request for job definition creation API
  
  Args:
      monitoring_schedule_name (str): Monitoring schedule name.
      job_definition_name (str): Job definition name.
          If not specified then a default one will be generated.
      image_uri (str): The uri of the image to use for the jobs started by the Monitor.
      latest_baselining_job_name (str): name of the last baselining job.
      latest_baselining_job_config (ClarifyBaseliningConfig): analysis config from
           last baselining job.
      existing_job_desc (dict): description of existing job definition. It will be updated by
           values that were passed in, and then used to create the new job definition.
      endpoint_input (str or sagemaker.model_monitor.EndpointInput): The endpoint to monitor.
          This can either be the endpoint name or an EndpointInput.
      ground_truth_input (str): S3 URI to ground truth dataset.
      analysis_config (str or BiasAnalysisConfig or ExplainabilityAnalysisConfig): URI to the
          analysis_config.json for the bias job. If it is None then configuration of latest
          baselining job config will be reused. If no baselining job then fail the call.
      output_s3_uri (str): S3 destination of the constraint_violations and analysis result.
          Default: "s3://<default_session_bucket>/<job_name>/output"
      constraints (sagemaker.model_monitor.Constraints or str): If provided it will be used
          for monitoring the endpoint. It can be a Constraints object or an S3 uri pointing
          to a constraints JSON file.
      enable_cloudwatch_metrics (bool): Whether to publish cloudwatch metrics as part of
          the baselining or monitoring jobs.
      role (str): An AWS IAM role. The Amazon SageMaker jobs use this role.
      instance_count (int): The number of instances to run
          the jobs with.
      instance_type (str): Type of EC2 instance to use for
          the job, for example, 'ml.m5.xlarge'.
      volume_size_in_gb (int): Size in GB of the EBS volume
          to use for storing data during processing (default: 30).
      volume_kms_key (str): A KMS key for the job's volume.
      output_kms_key (str): KMS key id for output.
      max_runtime_in_seconds (int): Timeout in seconds. After this amount of
          time, Amazon SageMaker terminates the job regardless of its current status.
          Default: 3600
      env (dict): Environment variables to be passed to the job.
      tags (Optional[Tags]): List of tags to be passed to the job.
      network_config (sagemaker.network.NetworkConfig): A NetworkConfig
          object that configures network isolation, encryption of
          inter-container traffic, security group IDs, and subnets.
      batch_transform_input (sagemaker.model_monitor.BatchTransformInput): Inputs to run
          the monitoring schedule on the batch transform
  
  Returns:
      dict: request parameters to create job definition.
code: def _build_create_job_definition_request(
      self,
      monitoring_schedule_name,
      job_definition_name,
      image_uri,
      latest_baselining_job_name=None,
      latest_baselining_job_config=None,
      existing_job_desc=None,
      endpoint_input=None,
      ground_truth_input=None,
      analysis_config=None,
      output_s3_uri=None,
      constraints=None,
      enable_cloudwatch_metrics=None,
      role=None,
      instance_count=None,
      instance_type=None,
      volume_size_in_gb=None,
      volume_kms_key=None,
      output_kms_key=None,
      max_runtime_in_seconds=None,
      env=None,
      tags=None,
      network_config=None,
      batch_transform_input=None,
  ):
      """Build the request for job definition creation API
  
      Args:
          monitoring_schedule_name (str): Monitoring schedule name.
          job_definition_name (str): Job definition name.
              If not specified then a default one will be generated.
          image_uri (str): The uri of the image to use for the jobs started by the Monitor.
          latest_baselining_job_name (str): name of the last baselining job.
          latest_baselining_job_config (ClarifyBaseliningConfig): analysis config from
               last baselining job.
          existing_job_desc (dict): description of existing job definition. It will be updated by
               values that were passed in, and then used to create the new job definition.
          endpoint_input (str or sagemaker.model_monitor.EndpointInput): The endpoint to monitor.
              This can either be the endpoint name or an EndpointInput.
          ground_truth_input (str): S3 URI to ground truth dataset.
          analysis_config (str or BiasAnalysisConfig or ExplainabilityAnalysisConfig): URI to the
              analysis_config.json for the bias job. If it is None then configuration of latest
              baselining job config will be reused. If no baselining job then fail the call.
          output_s3_uri (str): S3 destination of the constraint_violations and analysis result.
              Default: "s3://<default_session_bucket>/<job_name>/output"
          constraints (sagemaker.model_monitor.Constraints or str): If provided it will be used
              for monitoring the endpoint. It can be a Constraints object or an S3 uri pointing
              to a constraints JSON file.
          enable_cloudwatch_metrics (bool): Whether to publish cloudwatch metrics as part of
              the baselining or monitoring jobs.
          role (str): An AWS IAM role. The Amazon SageMaker jobs use this role.
          instance_count (int): The number of instances to run
              the jobs with.
          instance_type (str): Type of EC2 instance to use for
              the job, for example, 'ml.m5.xlarge'.
          volume_size_in_gb (int): Size in GB of the EBS volume
              to use for storing data during processing (default: 30).
          volume_kms_key (str): A KMS key for the job's volume.
          output_kms_key (str): KMS key id for output.
          max_runtime_in_seconds (int): Timeout in seconds. After this amount of
              time, Amazon SageMaker terminates the job regardless of its current status.
              Default: 3600
          env (dict): Environment variables to be passed to the job.
          tags (Optional[Tags]): List of tags to be passed to the job.
          network_config (sagemaker.network.NetworkConfig): A NetworkConfig
              object that configures network isolation, encryption of
              inter-container traffic, security group IDs, and subnets.
          batch_transform_input (sagemaker.model_monitor.BatchTransformInput): Inputs to run
              the monitoring schedule on the batch transform
  
      Returns:
          dict: request parameters to create job definition.
      """
      if existing_job_desc is not None:
          app_specification = existing_job_desc[
              "{}AppSpecification".format(self.monitoring_type())
          ]
          baseline_config = existing_job_desc.get(
              "{}BaselineConfig".format(self.monitoring_type()), {}
          )
          job_input = existing_job_desc[
              "{}JobInput".format(self.monitoring_type())
          ]
          job_output = existing_job_desc[
              "{}JobOutputConfig".format(self.monitoring_type())
          ]
          cluster_config = existing_job_desc["JobResources"][
              "ClusterConfig"
          ]
          if role is None:
              role = existing_job_desc["RoleArn"]
          existing_network_config = existing_job_desc.get(
              "NetworkConfig"
          )
          stop_condition = existing_job_desc.get(
              "StoppingCondition", {}
          )
      else:
          app_specification = {}
          baseline_config = {}
          job_input = {}
          job_output = {}
          cluster_config = {}
          existing_network_config = None
          stop_condition = {}
  
      # job output
      if output_s3_uri is not None:
          normalized_monitoring_output = (
              self._normalize_monitoring_output(
                  monitoring_schedule_name, output_s3_uri
              )
          )
          job_output["MonitoringOutputs"] = [
              normalized_monitoring_output._to_request_dict()
          ]
      if output_kms_key is not None:
          job_output["KmsKeyId"] = output_kms_key
  
      # app specification
      if analysis_config is None:
          if latest_baselining_job_config is not None:
              analysis_config = (
                  latest_baselining_job_config.analysis_config
              )
          elif app_specification:
              analysis_config = app_specification["ConfigUri"]
          else:
              raise ValueError("analysis_config is mandatory.")
          # backfill analysis_config
      if isinstance(analysis_config, str):
          analysis_config_uri = analysis_config
      else:
          analysis_config_uri = self._upload_analysis_config(
              analysis_config._to_dict(),
              output_s3_uri,
              job_definition_name,
              output_kms_key,
          )
      app_specification["ConfigUri"] = analysis_config_uri
      app_specification["ImageUri"] = image_uri
      normalized_env = self._generate_env_map(
          env=env, enable_cloudwatch_metrics=enable_cloudwatch_metrics
      )
      if normalized_env:
          app_specification["Environment"] = normalized_env
  
      # baseline config
      if constraints:
          # noinspection PyTypeChecker
          _, constraints_object = self._get_baseline_files(
              statistics=None,
              constraints=constraints,
              sagemaker_session=self.sagemaker_session,
          )
          constraints_s3_uri = None
          if constraints_object is not None:
              constraints_s3_uri = constraints_object.file_s3_uri
          baseline_config["ConstraintsResource"] = dict(
              S3Uri=constraints_s3_uri
          )
      elif latest_baselining_job_name:
          baseline_config[
              "BaseliningJobName"
          ] = latest_baselining_job_name
  
      # job input
      if endpoint_input is not None:
          normalized_endpoint_input = self._normalize_endpoint_input(
              endpoint_input=endpoint_input
          )
          # backfill attributes to endpoint input
          if latest_baselining_job_config is not None:
              if normalized_endpoint_input.features_attribute is None:
                  normalized_endpoint_input.features_attribute = (
                      latest_baselining_job_config.features_attribute
                  )
              if normalized_endpoint_input.inference_attribute is None:
                  normalized_endpoint_input.inference_attribute = (
                      latest_baselining_job_config.inference_attribute
                  )
              if (
                  normalized_endpoint_input.probability_attribute
                  is None
              ):
                  normalized_endpoint_input.probability_attribute = (
                      latest_baselining_job_config.probability_attribute
                  )
              if (
                  normalized_endpoint_input.probability_threshold_attribute
                  is None
              ):
                  normalized_endpoint_input.probability_threshold_attribute = (
                      latest_baselining_job_config.probability_threshold_attribute
                  )
          job_input = normalized_endpoint_input._to_request_dict()
      elif batch_transform_input is not None:
          # backfill attributes to batch transform input
          if latest_baselining_job_config is not None:
              if batch_transform_input.features_attribute is None:
                  batch_transform_input.features_attribute = (
                      latest_baselining_job_config.features_attribute
                  )
              if batch_transform_input.inference_attribute is None:
                  batch_transform_input.inference_attribute = (
                      latest_baselining_job_config.inference_attribute
                  )
              if batch_transform_input.probability_attribute is None:
                  batch_transform_input.probability_attribute = (
                      latest_baselining_job_config.probability_attribute
                  )
              if (
                  batch_transform_input.probability_threshold_attribute
                  is None
              ):
                  batch_transform_input.probability_threshold_attribute = (
                      latest_baselining_job_config.probability_threshold_attribute
                  )
          job_input = batch_transform_input._to_request_dict()
  
      if ground_truth_input is not None:
          job_input["GroundTruthS3Input"] = dict(
              S3Uri=ground_truth_input
          )
  
      # cluster config
      if instance_count is not None:
          cluster_config["InstanceCount"] = instance_count
      if instance_type is not None:
          cluster_config["InstanceType"] = instance_type
      if volume_size_in_gb is not None:
          cluster_config["VolumeSizeInGB"] = volume_size_in_gb
      if volume_kms_key is not None:
          cluster_config["VolumeKmsKeyId"] = volume_kms_key
  
      # stop condition
      if max_runtime_in_seconds is not None:
          stop_condition["MaxRuntimeInSeconds"] = max_runtime_in_seconds
  
      request_dict = {
          "JobDefinitionName": job_definition_name,
          "{}AppSpecification".format(
              self.monitoring_type()
          ): app_specification,
          "{}JobInput".format(self.monitoring_type()): job_input,
          "{}JobOutputConfig".format(
              self.monitoring_type()
          ): job_output,
          "JobResources": dict(ClusterConfig=cluster_config),
          "RoleArn": self.sagemaker_session.expand_role(role),
      }
  
      if baseline_config:
          request_dict[
              "{}BaselineConfig".format(self.monitoring_type())
          ] = baseline_config
  
      if network_config is not None:
          network_config_dict = network_config._to_request_dict()
          request_dict["NetworkConfig"] = network_config_dict
      elif existing_network_config is not None:
          request_dict["NetworkConfig"] = existing_network_config
  
      if stop_condition:
          request_dict["StoppingCondition"] = stop_condition
  
      if tags is not None:
          request_dict["Tags"] = format_tags(tags)
  
      return request_dict
  
imports: from __future__ import print_function, absolute_import
  import copy
  import json
  import logging
  import uuid
  from sagemaker.model_monitor import model_monitoring
  from sagemaker import image_uris, s3
  from sagemaker.session import Session
  from sagemaker.utils import name_from_base, format_tags
  from sagemaker.clarify import SageMakerClarifyProcessor, ModelPredictedLabelConfig
  from sagemaker.lineage._utils import get_resource_name_from_arn
label_desc: Use image node_id 8 for calling the ClarifyModelMonitor obj's underlying member method code with example usage: obj._build_create_job_definition_request(monitoring_schedule_name, job_definition_name, image_uri, latest_baselining_job_name, latest_baselining_job_config, existing_job_desc, endpoint_input, ground_truth_input, analysis_config, output_s3_uri, constraints, enable_cloudwatch_metrics, role, instance_count, instance_type, volume_size_in_gb, volume_kms_key, output_kms_key, max_runtime_in_seconds, env, tags, network_config, batch_transform_input) and returns: request_dict