class_docstr: Class for interacting with Vertex CustomJob.
class_docstr_tok: ["Class","for","interacting","with","Vertex","CustomJob","."]
docstr: Get training args for runner._launch_aip_training.
  
  The training args contain the inputs/outputs/exec_properties to the
  tfx.scripts.run_executor module.
  
  Args:
    input_dict: Passthrough input dict for tfx.components.Trainer.executor.
    output_dict: Passthrough input dict for tfx.components.Trainer.executor.
    exec_properties: Passthrough input dict for
      tfx.components.Trainer.executor.
    executor_class_path: class path for TFX core default trainer.
    job_args: CustomJob for Vertex AI custom training. See
      https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.customJobs#CustomJob
        for the detailed schema.
      [Deprecated]: job_args also support specifying only the CustomJobSpec
        instead of CustomJob. However, this functionality is deprecated.
    job_id: Display name for AI Platform (Unified) custom training job. If not
      supplied, system-determined unique ID is given. Refer to
      https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.customJobs#CustomJob
    job_labels: Not applicable for Vertex AI, where labels are specified in
      the CustomJob as defined in
      https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.customJobs#CustomJob.
  
  Returns:
    A dict containing the Vertex AI CustomJob
docstr_tok: ["Get","training","args","for","runner._launch_aip_training",".","The","training","args","contain","the","inputs\/outputs\/exec_properties","to","the","tfx.scripts.run_executor","module",".","Args",":","input_dict",":","Passthrough","input","dict","for","tfx.components.Trainer.executor",".","output_dict",":","Passthrough","input","dict","for","tfx.components.Trainer.executor",".","exec_properties",":","Passthrough","input","dict","for","tfx.components.Trainer.executor",".","executor_class_path",":","class","path","for","TFX","core","default","trainer",".","job_args",":","CustomJob","for","Vertex","AI","custom","training",".","See","https",":","\/\/cloud.google.com\/vertex-ai\/docs\/reference\/rest\/v1\/projects.locations.customJobs","#","CustomJob","for","the","detailed","schema",".","[","Deprecated","]",":","job_args","also","support","specifying","only","the","CustomJobSpec","instead","of","CustomJob",".","However",",","this","functionality","is","deprecated",".","job_id",":","Display","name","for","AI","Platform","(","Unified",")","custom","training","job",".","If","not","supplied",",","system-determined","unique","ID","is","given",".","Refer","to","https",":","\/\/cloud.google.com\/vertex-ai\/docs\/reference\/rest\/v1\/projects.locations.customJobs","#","CustomJob","job_labels",":","Not","applicable","for","Vertex","AI",",","where","labels","are","specified","in","the","CustomJob","as","defined","in","https",":","\/\/cloud.google.com\/vertex-ai\/docs\/reference\/rest\/v1\/projects.locations.customJobs","#","CustomJob",".","Returns",":","A","dict","containing","the","Vertex","AI","CustomJob"]
code: def create_training_job(
      self,
      input_dict: Dict[str, List[types.Artifact]],
      output_dict: Dict[str, List[types.Artifact]],
      exec_properties: Dict[str, Any],
      executor_class_path: str,
      job_args: Dict[str, Any],
      job_id: Optional[str],
      job_labels: Optional[Dict[str, Any]],
  ) -> Dict[str, Any]:
      """Get training args for runner._launch_aip_training.
  
      The training args contain the inputs/outputs/exec_properties to the
      tfx.scripts.run_executor module.
  
      Args:
        input_dict: Passthrough input dict for tfx.components.Trainer.executor.
        output_dict: Passthrough input dict for tfx.components.Trainer.executor.
        exec_properties: Passthrough input dict for
          tfx.components.Trainer.executor.
        executor_class_path: class path for TFX core default trainer.
        job_args: CustomJob for Vertex AI custom training. See
          https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.customJobs#CustomJob
            for the detailed schema.
          [Deprecated]: job_args also support specifying only the CustomJobSpec
            instead of CustomJob. However, this functionality is deprecated.
        job_id: Display name for AI Platform (Unified) custom training job. If not
          supplied, system-determined unique ID is given. Refer to
          https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.customJobs#CustomJob
        job_labels: Not applicable for Vertex AI, where labels are specified in
          the CustomJob as defined in
          https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.customJobs#CustomJob.
  
      Returns:
        A dict containing the Vertex AI CustomJob
      """
      if job_labels:
          logging.warn(
              "Job labels in custom_config are ignored by Vertex, where labels are "
              "specified in the CustomJob as defined in "
              "https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.customJobs#CustomJob."
          )
      job_args = job_args.copy()
      if job_args.get("job_spec"):
          custom_job_spec = job_args["job_spec"]
      else:
          logging.warn(
              "job_spec key was not found. Parsing job_args as CustomJobSpec instead"
          )
          custom_job_spec = job_args
  
      container_command = self.generate_container_command(
          input_dict, output_dict, exec_properties, executor_class_path
      )
  
      if not custom_job_spec.get("worker_pool_specs"):
          custom_job_spec["worker_pool_specs"] = [{}]
  
      for worker_pool_spec in custom_job_spec["worker_pool_specs"]:
          if not worker_pool_spec.get("container_spec"):
              worker_pool_spec["container_spec"] = {
                  "image_uri": _TFX_IMAGE,
              }
  
          # Always use our own entrypoint instead of relying on container default.
          if "command" in worker_pool_spec["container_spec"]:
              logging.warn(
                  "Overriding custom value of container_spec.command"
              )
          worker_pool_spec["container_spec"][
              "command"
          ] = container_command
  
      # 'tfx_YYYYmmddHHMMSS_xxxxxxxx' is the default job display name if not
      # explicitly specified.
      job_id = job_args.get("display_name", job_id)
      job_id = job_id or "tfx_{}_{}".format(
          datetime.datetime.now().strftime("%Y%m%d%H%M%S"),
          "%08x" % random.getrandbits(32),
      )
  
      with telemetry_utils.scoped_labels(
          {telemetry_utils.LABEL_TFX_EXECUTOR: executor_class_path}
      ):
          job_labels = telemetry_utils.make_labels_dict()
      job_labels.update(job_args.get("labels", {}))
  
      encryption_spec = job_args.get("encryption_spec", {})
  
      custom_job = {
          "display_name": job_id,
          "job_spec": custom_job_spec,
          "labels": job_labels,
          "encryption_spec": encryption_spec,
      }
  
      return custom_job
  
imports: import abc
  import datetime
  import json
  import random
  from typing import Any, Dict, List, Optional, Union
  from absl import logging
  from google.api_core import retry
  from google.cloud.aiplatform import gapic
  from google.cloud.aiplatform_v1.types.custom_job import CustomJob
  from google.cloud.aiplatform_v1.types.job_state import JobState
  from googleapiclient import discovery
  from tfx import types
  from tfx.types import artifact_utils
  from tfx.utils import telemetry_utils
  from tfx.utils import version_utils
label_desc: Use image node_id 3 for calling the VertexJobClient obj's underlying member method code with example usage: obj.create_training_job(input_dict, output_dict, exec_properties, executor_class_path, job_args, job_id, job_labels) and returns: custom_job