def Run(self, args):
        hptuning_job_ref = args.CONCEPTS.hptuning_job.Parse()
        region = hptuning_job_ref.AsDict()['locationsId']
        validation.ValidateRegion(
            region, available_regions=constants.SUPPORTED_TRAINING_REGIONS)

        version = constants.GA_VERSION if self.ReleaseTrack(
        ) == base.ReleaseTrack.GA else constants.BETA_VERSION
        with endpoint_util.AiplatformEndpointOverrides(version=version,
                                                       region=region):
            response = client.HpTuningJobsClient(version=version).Get(
                hptuning_job_ref.RelativeName())
            return response
    def Run(self, args):
        hptuning_job_ref = args.CONCEPTS.hptuning_job.Parse()
        region = hptuning_job_ref.AsDict()['locationsId']
        validation.ValidateRegion(
            region, available_regions=constants.SUPPORTED_TRAINING_REGIONS)

        version = constants.GA_VERSION if self.ReleaseTrack(
        ) == base.ReleaseTrack.GA else constants.BETA_VERSION
        with endpoint_util.AiplatformEndpointOverrides(version=version,
                                                       region=region):
            relative_name = hptuning_job_ref.RelativeName()
            return log_util.StreamLogs(
                hptuning_job_ref.AsDict()['hyperparameterTuningJobsId'],
                continue_function=client.HpTuningJobsClient(
                    version=version).CheckJobComplete(relative_name),
                polling_interval=args.polling_interval,
                task_name=args.task_name,
                allow_multiline=args.allow_multiline_logs)
예제 #3
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, available_regions=constants.SUPPORTED_TRAINING_REGIONS)

        with endpoint_util.AiplatformEndpointOverrides(version=self._version,
                                                       region=region):
            return client.HpTuningJobsClient(version=self._version).List(
                region=region_ref.RelativeName())
    def Run(self, args):
        hptuning_job_ref = args.CONCEPTS.hptuning_job.Parse()
        region = hptuning_job_ref.AsDict()['locationsId']
        validation.ValidateRegion(
            region, available_regions=constants.SUPPORTED_TRAINING_REGIONS)

        version = constants.GA_VERSION if self.ReleaseTrack(
        ) == base.ReleaseTrack.GA else constants.BETA_VERSION
        with endpoint_util.AiplatformEndpointOverrides(version=version,
                                                       region=region):
            response = client.HpTuningJobsClient(version=version).Cancel(
                hptuning_job_ref.RelativeName())

            log.status.Print(
                _HPTUNING_JOB_CANCEL_DISPLAY_MESSAGE.format(
                    id=hptuning_job_ref.Name(),
                    command_version=hp_tuning_jobs_util.OutputCommandVersion(
                        self.ReleaseTrack()),
                    region=region))
            return response
def ValidateRegion(region):
    """Validate whether the given region is allowed for specifically custom job."""
    validation.ValidateRegion(
        region, available_regions=constants.SUPPORTED_TRAINING_REGIONS)