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)
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." )
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)
def _check_deploying(args): return UCAIPService.get().get_deploying_endpoints( model_name=args["modelName"], endpoint_id=args["endpointId"])
def _get_all_endpoints(args): return UCAIPService.get().get_all_endpoints()
def _get_pipelines(_): return UCAIPService.get().get_training_pipelines()
def _get_endpoints(args): return UCAIPService.get().get_endpoints(model_id=args["modelId"])
def _list_model_evaluations(args): return UCAIPService.get().get_model_evaluation(args["modelId"])
def _get_pipeline(args): return UCAIPService.get().get_training_pipeline(args["pipelineId"])
def _deploy_model(args): UCAIPService.get().deploy_model(model_id=args["modelId"]) return {"success": True}
def _undeploy_model(args): UCAIPService.get().undeploy_model( deployed_model_id=args["deployedModelId"], endpoint_id=args["endpointId"]) return {"success": True}
def _delete_endpoint(args): UCAIPService.get().delete_endpoint(endpoint_id=args["endpointId"]) return {"success": True}
def _list_datasets(_): return UCAIPService.get().get_datasets()
def _delete_model(args): UCAIPService.get().model_client.delete_model(name=args["modelId"]) return {"success": True}
def _delete_dataset(args): UCAIPService.get().dataset_client.delete_dataset(name=args["datasetId"]) return {"success": True}
def _predict_tables(args): return UCAIPService.get().predict_tables(endpoint_id=args["endpointId"], instance=args["inputs"])
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)
def _check_deploying(args): return UCAIPService.get().check_deploying(model_name=args["modelName"])
def _get_dataset_details(args): return UCAIPService.get().get_dataset_details(args["datasetId"])
def _deploy_model(args): UCAIPService.get().deploy_model(model_id=args["modelId"], machine_type=args["machineType"], endpoint_id=args["endpointId"]) return {"success": True}
def _list_models(_): return UCAIPService.get().get_models()
def _table_info(args): return UCAIPService.get().get_table_specs(args["datasetId"])