コード例 #1
0
def _GetModelDeploymentResourceType(model_ref, client):
    """Gets the deployment resource type of a model.

  Each model resource belongs to exactly one supported deployment resource type.
  The value is the first item in the list, the length of which must be one.

  Args:
    model_ref: a model resource object.
    client: an apis.GetClientInstance object.

  Returns:
    A string which value must be 'DEDICATED_RESOURCES' or 'AUTOMATIC_RESOURCES'.

  Raises:
    ArgumentError: if the model resource object is not found.
  """
    try:
        model_msg = model_client.ModelsClient(client=client).Get(model_ref)
    except apitools_exceptions.HttpError:
        raise errors.ArgumentError(
            ('There is an error while getting the model information. '
             'Please make sure the model %r exists.' %
             model_ref.RelativeName()))
    model_resource = encoding.MessageToPyValue(model_msg)
    return model_resource['supportedDeploymentResourcesTypes'][0]
コード例 #2
0
 def Run(self, args):
   region_ref = args.CONCEPTS.region.Parse()
   region = region_ref.AsDict()['locationsId']
   with endpoint_util.AiplatformEndpointOverrides(
       version=constants.GA_VERSION, region=region):
     client_instance = apis.GetClientInstance(
         constants.AI_PLATFORM_API_NAME,
         constants.AI_PLATFORM_API_VERSION[constants.GA_VERSION])
     operation = client.ModelsClient(
         client=client_instance,
         messages=client_instance.MESSAGES_MODULE).UploadV1(
             region_ref,
             args.display_name,
             args.description,
             args.artifact_uri,
             args.container_image_uri,
             args.container_command,
             args.container_args,
             args.container_env_vars,
             args.container_ports,
             args.container_predict_route,
             args.container_health_route,
             explanation_spec=self._BuildExplanationSpec(args))
     return operations_util.WaitForOpMaybe(
         operations_client=operations.OperationsClient(
             client=client_instance, messages=client_instance.MESSAGES_MODULE),
         op=operation,
         op_ref=models_util.ParseModelOperation(operation.name))
コード例 #3
0
ファイル: describe.py プロジェクト: saranraju90/multik8s
 def _Run(self, args):
   model_ref = args.CONCEPTS.model.Parse()
   region = model_ref.AsDict()['locationsId']
   with endpoint_util.AiplatformEndpointOverrides(
       version=constants.BETA_VERSION, region=region):
     response = client.ModelsClient().Get(model_ref)
     return response
コード例 #4
0
 def __init__(self, *args, **kwargs):
   super(UploadV1, self).__init__(*args, **kwargs)
   client_instance = apis.GetClientInstance(
       constants.AI_PLATFORM_API_NAME,
       constants.AI_PLATFORM_API_VERSION[constants.GA_VERSION])
   self.messages = client.ModelsClient(
       client=client_instance,
       messages=client_instance.MESSAGES_MODULE).messages
コード例 #5
0
 def _Run(self, args, model_ref, region):
     with endpoint_util.AiplatformEndpointOverrides(
             version=constants.BETA_VERSION, region=region):
         operation = client.ModelsClient().Delete(model_ref)
         return operations_util.WaitForOpMaybe(
             operations_client=operations.OperationsClient(),
             op=operation,
             op_ref=models_util.ParseModelOperation(operation.name))
コード例 #6
0
 def _Run(self, args, model_ref, region):
     with endpoint_util.AiplatformEndpointOverrides(
             version=constants.GA_VERSION, region=region):
         client_instance = apis.GetClientInstance(
             constants.AI_PLATFORM_API_NAME,
             constants.AI_PLATFORM_API_VERSION[constants.GA_VERSION])
         return client.ModelsClient(
             client=client_instance,
             messages=client_instance.MESSAGES_MODULE).Delete(model_ref)
コード例 #7
0
 def _Run(self, args):
     model_ref = args.CONCEPTS.model.Parse()
     region = model_ref.AsDict()['locationsId']
     with endpoint_util.AiplatformEndpointOverrides(
             version=constants.BETA_VERSION, region=region):
         operation = client.ModelsClient().Delete(model_ref)
         return operations_util.WaitForOpMaybe(
             operations_client=operations.OperationsClient(),
             op=operation,
             op_ref=models_util.ParseModelOperation(operation.name))
コード例 #8
0
ファイル: upload.py プロジェクト: piotradamczyk5/gcloud_cli
 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):
         operation = client.ModelsClient().UploadV1Beta1(
             region_ref, args.display_name, args.description,
             args.artifact_uri, args.container_image_uri,
             args.container_command, args.container_args,
             args.container_env_vars, args.container_ports,
             args.container_predict_route, args.container_health_route)
         return operations_util.WaitForOpMaybe(
             operations_client=operations.OperationsClient(),
             op=operation,
             op_ref=models_util.ParseModelOperation(operation.name))
コード例 #9
0
 def __init__(self, *args, **kwargs):
   super(UploadV1Beta1, self).__init__(*args, **kwargs)
   self.messages = client.ModelsClient().messages
コード例 #10
0
 def _Run(self, args, region_ref, region):
     with endpoint_util.AiplatformEndpointOverrides(
             version=constants.BETA_VERSION, region=region):
         return client.ModelsClient().List(region_ref=region_ref)
コード例 #11
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.ModelsClient().List(region_ref=region_ref)
コード例 #12
0
 def _Run(self, args, model_ref, region):
   with endpoint_util.AiplatformEndpointOverrides(
       version=constants.BETA_VERSION, region=region):
     response = client.ModelsClient().Get(model_ref)
     return response