示例#1
0
 def Run(self, args):
     region_ref = args.CONCEPTS.region.Parse()
     region = region_ref.AsDict()['locationsId']
     with endpoint_util.AiplatformEndpointOverrides(
             version=constants.BETA_VERSION, region=region):
         return client.CustomJobsClient(
             version=constants.BETA_VERSION).List(
                 region=region_ref.RelativeName())
示例#2
0
 def Run(self, args):
     custom_job_ref = args.CONCEPTS.custom_job.Parse()
     region = custom_job_ref.AsDict()['locationsId']
     with endpoint_util.AiplatformEndpointOverrides(
             version=constants.BETA_VERSION, region=region):
         response = client.CustomJobsClient(
             version=constants.BETA_VERSION).Get(
                 custom_job_ref.RelativeName())
         return response
    def Run(self, args):
        custom_job_ref = args.CONCEPTS.custom_job.Parse()
        region = custom_job_ref.AsDict()['locationsId']
        validation.ValidateRegion(region)

        with endpoint_util.AiplatformEndpointOverrides(
                version=self._api_version, region=region):
            response = client.CustomJobsClient(version=self._api_version).Get(
                custom_job_ref.RelativeName())
            return response
示例#4
0
 def Run(self, args):
     custom_job_ref = args.CONCEPTS.custom_job.Parse()
     name = custom_job_ref.Name()
     region = custom_job_ref.AsDict()['locationsId']
     with endpoint_util.AiplatformEndpointOverrides(
             version=constants.BETA_VERSION, region=region):
         response = client.CustomJobsClient(
             version=constants.BETA_VERSION).Cancel(
                 custom_job_ref.RelativeName())
         log.status.Print(
             constants.CUSTOM_JOB_CANCEL_DISPLAY_MESSAGE.format(id=name))
         return response
    def Run(self, args):
        custom_job_ref = args.CONCEPTS.custom_job.Parse()
        region = custom_job_ref.AsDict()['locationsId']
        validation.ValidateRegion(region)

        with endpoint_util.AiplatformEndpointOverrides(
                version=self._api_version, region=region):
            job_name = custom_job_ref.RelativeName()
            response = client.CustomJobsClient(
                version=self._api_version).Cancel(job_name)
            log.status.Print(
                _CUSTOM_JOB_CANCEL_DISPLAY_MESSAGE.format(
                    job_name=job_name, command_prefix=self._CommandPrefix()))
            return response
示例#6
0
 def Run(self, args):
     custom_job_ref = args.CONCEPTS.custom_job.Parse()
     region = custom_job_ref.AsDict()['locationsId']
     with endpoint_util.AiplatformEndpointOverrides(
             version=constants.BETA_VERSION, region=region):
         relative_name = custom_job_ref.RelativeName()
         return log_util.StreamLogs(
             custom_job_ref.AsDict()['customJobsId'],
             continue_function=client.CustomJobsClient(
                 version=constants.BETA_VERSION).CheckJobComplete(
                     relative_name),
             polling_interval=args.polling_interval,
             task_name=args.task_name,
             allow_multiline=args.allow_multiline_logs)
示例#7
0
 def Run(self, args):
     region_ref = args.CONCEPTS.region.Parse()
     region = region_ref.AsDict()['locationsId']
     with endpoint_util.AiplatformEndpointOverrides(
             version=constants.BETA_VERSION, region=region):
         response = client.CustomJobsClient(
             version=constants.BETA_VERSION).Create(
                 region_ref.RelativeName(), args.worker_pool_spec,
                 args.config, args.display_name, args.python_package_uris)
         log.status.Print(
             constants.CUSTOM_JOB_CREATION_DISPLAY_MESSAGE.format(
                 id=custom_jobs_util.ParseJobName(response.name),
                 state=response.state))
         return response
示例#8
0
    def Run(self, args):
        """Executes the list command.

    Args:
      args: an argparse.Namespace, it contains all arguments that this command
        was invoked with.

    Returns:
      The list of resources
    """
        region_ref = args.CONCEPTS.region.Parse()
        region = region_ref.AsDict()['locationsId']
        validation.ValidateRegion(region)

        with endpoint_util.AiplatformEndpointOverrides(
                version=self._api_version, region=region):
            return client.CustomJobsClient(version=self._api_version).List(
                region=region_ref.RelativeName())
  def Run(self, args):
    project = properties.VALUES.core.project.GetOrFail()
    region_ref = args.CONCEPTS.region.Parse()
    region = region_ref.AsDict()['locationsId']
    validation.ValidateRegion(region)

    with endpoint_util.AiplatformEndpointOverrides(
        version=self._version, region=region):
      api_client = client.CustomJobsClient(version=self._version)
      job_spec = self._PrepareJobSpec(args, api_client, project)
      labels = labels_util.ParseCreateArgs(
          args,
          api_client.CustomJobMessage().LabelsValue)

      response = api_client.Create(
          parent=region_ref.RelativeName(),
          display_name=args.display_name,
          job_spec=job_spec,
          kms_key_name=common_validation.GetAndValidateKmsKey(args),
          labels=labels)
      self._DisplayResult(response)
      return response