Exemplo n.º 1
0
def predict(endpoint_id: str, instance: object) -> object:
  """Send a prediction request to a uCAIP model endpoint

  Args:
      endpoint_id (str): ID of the uCAIP endpoint
      instance (object): The prediction instance, should match the input format that the endpoint expects

  Returns:
      object: Prediction results from the model
  """
  return UCAIPService.get().predict_tables(endpoint_id, instance)
Exemplo n.º 2
0
def create_dataset(display_name: str,
                   dataframe: pandas.DataFrame = None,
                   file_path: str = None,
                   gcs_uri: str = None,
                   bigquery_uri: str = None) -> aiplatform_v1alpha1.Dataset:
    """Create a tabular dataset in uCAIP from a given source.
  One of dataframe, file_path, gcs_uri or bigquery_uri must be provided.

  Args:
      display_name (str): The user-defined name of the dataset
      dataframe (pandas.DataFrame, optional): Pandas DataFrame to import data from. Defaults to None.
      file_path (str, optional): Local file path to import data from. Defaults to None.
      gcs_uri (str, optional): URI of csv in GCS to import data from. Defaults to None.
      bigquery_uri (str, optional): URI of bigquery table to import data from. Defaults to None.

  Raises:
      APIError: Raised if no valid source is provided

  Returns:
      aiplatform_v1alpha1.Dataset: The newly created dataset
  """
    if dataframe is not None:
        return UCAIPService.get().create_dataset_from_dataframe(
            display_name, dataframe)
    elif file_path is not None:
        file_name = os.path.basename(file_path)
        if not os.path.exists(file_path):
            raise APIError("File path " + file_path + " not found.")
        with open(file_path, "rb") as f:
            return UCAIPService.get().create_dataset_from_file(
                display_name, file_name, f.read())
    elif gcs_uri is not None:
        return UCAIPService.get().create_dataset(display_name=display_name,
                                                 gcs_uri=gcs_uri)
    elif bigquery_uri is not None:
        return UCAIPService.get().create_dataset(display_name=display_name,
                                                 bigquery_uri=bigquery_uri)
    else:
        raise APIError(
            "One of { dataframe, file_path, gcs_uri, bigquery_uri } must be provided."
        )
Exemplo n.º 3
0
def export_saved_model(display_name: str, model_path: str,
                       framework: ModelFramework) -> aiplatform_v1alpha1.Model:
    """Export a custom pretrained model to uCAIP from a folder containing the saved model

  Args:
      display_name (str): The user-defined name of the model
      model_path (str): Local path to the folder containing saved model artifacts (e.g saved_model.pb)
      framework (jupyterlab_ucaip.types.ModelFramework): The framework used to train the model

  Returns:
      aiplatform_v1alpha1.Model: The newly created model
  """
    return UCAIPService.get().export_saved_model(display_name, model_path,
                                                 framework)
Exemplo n.º 4
0
def _check_deploying(args):
    return UCAIPService.get().get_deploying_endpoints(
        model_name=args["modelName"], endpoint_id=args["endpointId"])
Exemplo n.º 5
0
def _get_all_endpoints(args):
    return UCAIPService.get().get_all_endpoints()
Exemplo n.º 6
0
def _get_pipelines(_):
    return UCAIPService.get().get_training_pipelines()
Exemplo n.º 7
0
def _get_endpoints(args):
    return UCAIPService.get().get_endpoints(model_id=args["modelId"])
Exemplo n.º 8
0
def _list_model_evaluations(args):
    return UCAIPService.get().get_model_evaluation(args["modelId"])
Exemplo n.º 9
0
def _get_pipeline(args):
    return UCAIPService.get().get_training_pipeline(args["pipelineId"])
Exemplo n.º 10
0
def _deploy_model(args):
    UCAIPService.get().deploy_model(model_id=args["modelId"])
    return {"success": True}
Exemplo n.º 11
0
def _undeploy_model(args):
    UCAIPService.get().undeploy_model(
        deployed_model_id=args["deployedModelId"],
        endpoint_id=args["endpointId"])
    return {"success": True}
Exemplo n.º 12
0
def _delete_endpoint(args):
    UCAIPService.get().delete_endpoint(endpoint_id=args["endpointId"])
    return {"success": True}
Exemplo n.º 13
0
def _list_datasets(_):
    return UCAIPService.get().get_datasets()
Exemplo n.º 14
0
def _delete_model(args):
    UCAIPService.get().model_client.delete_model(name=args["modelId"])
    return {"success": True}
Exemplo n.º 15
0
def _delete_dataset(args):
    UCAIPService.get().dataset_client.delete_dataset(name=args["datasetId"])
    return {"success": True}
Exemplo n.º 16
0
def _predict_tables(args):
    return UCAIPService.get().predict_tables(endpoint_id=args["endpointId"],
                                             instance=args["inputs"])
Exemplo n.º 17
0
def deploy_model(model_id: str,
                 machine_type: str,
                 min_replicas: int = 1,
                 endpoint_id: str = None):
  return UCAIPService.get().deploy_model(model_id, machine_type, min_replicas,
                                         endpoint_id)
Exemplo n.º 18
0
def _check_deploying(args):
    return UCAIPService.get().check_deploying(model_name=args["modelName"])
Exemplo n.º 19
0
def _get_dataset_details(args):
    return UCAIPService.get().get_dataset_details(args["datasetId"])
Exemplo n.º 20
0
def _deploy_model(args):
    UCAIPService.get().deploy_model(model_id=args["modelId"],
                                    machine_type=args["machineType"],
                                    endpoint_id=args["endpointId"])
    return {"success": True}
Exemplo n.º 21
0
def _list_models(_):
    return UCAIPService.get().get_models()
Exemplo n.º 22
0
def _table_info(args):
    return UCAIPService.get().get_table_specs(args["datasetId"])