def _Run(args, version):
  tensorboard_run_ref = args.CONCEPTS.tensorboard_run.Parse()
  region = tensorboard_run_ref.AsDict()['locationsId']
  with endpoint_util.AiplatformEndpointOverrides(
      version=version, region=region):
    response = client.TensorboardRunsClient(
        version=version).Get(tensorboard_run_ref)
    return response
def _Run(args, version):
    tensorboard_exp_ref = args.CONCEPTS.tensorboard_experiment_id.Parse()
    region = tensorboard_exp_ref.AsDict()['locationsId']
    with endpoint_util.AiplatformEndpointOverrides(version=version,
                                                   region=region):
        return client.TensorboardRunsClient(version=version).List(
            tensorboard_exp_ref=tensorboard_exp_ref,
            limit=args.limit,
            page_size=args.page_size,
            sort_by=args.sort_by)
def _Run(args, version):
    tensorboard_run_ref = args.CONCEPTS.tensorboard_run.Parse()
    region = tensorboard_run_ref.AsDict()['locationsId']
    with endpoint_util.AiplatformEndpointOverrides(version=version,
                                                   region=region):
        operation = client.TensorboardRunsClient(
            version=version).Delete(tensorboard_run_ref)
        return operations_util.WaitForOpMaybe(
            operations_client=operations.OperationsClient(),
            op=operation,
            op_ref=tensorboards_util.ParseTensorboardOperation(operation.name))
def _Run(args, version):
  """Create a new Vertex AI Tensorboard run."""
  tensorboard_exp_ref = args.CONCEPTS.tensorboard_experiment.Parse()
  region = tensorboard_exp_ref.AsDict()['locationsId']
  with endpoint_util.AiplatformEndpointOverrides(version, region=region):
    tensorboard_runs_client = client.TensorboardRunsClient(version=version)
    response = tensorboard_runs_client.Create(tensorboard_exp_ref, args)
    response_msg = encoding.MessageToPyValue(response)
    if 'name' in response_msg:
      log.status.Print(('Created Vertex AI Tensorboard run: {}.').format(
          response_msg['name']))
    return response
def _Run(args, version):
    """Update an existing Vertex AI Tensorboard run."""
    tensorboard_run_ref = args.CONCEPTS.tensorboard_run.Parse()
    args.region = tensorboard_run_ref.AsDict()['locationsId']
    with endpoint_util.AiplatformEndpointOverrides(version,
                                                   region=args.region):
        try:
            op = client.TensorboardRunsClient(version=version).Patch(
                tensorboard_run_ref, args)
        except errors.NoFieldsSpecifiedError:
            available_update_args = [
                'display_name', 'update_labels', 'clear_labels',
                'remove_labels', 'description'
            ]
            if not any(args.IsSpecified(arg) for arg in available_update_args):
                raise
            log.status.Print('No update to perform.')
            return None
        else:
            log.UpdatedResource(op.name, kind='Vertex AI Tensorboard run')
            return op