Usecase Deployment

class previsionio.usecase_deployment.UsecaseDeployment(_id: str, name: str, usecase_id, current_version, versions, deploy_state, access_type, project_id, training_type, models, url=None, **kwargs)

UsecaseDeployment objects represent usecase deployment resource that will be explored by Prevision.io platform.

create_api_key()

Create an api key of the usecase deployment from the actual [client] workspace.

Raises:
  • PrevisionException – If the dataset does not exist
  • requests.exceptions.ConnectionError – Error processing the request
delete()

Delete a usecase deployment from the actual [client] workspace.

Raises:
  • PrevisionException – If the usecase deployment does not exist
  • requests.exceptions.ConnectionError – Error processing the request
classmethod from_id(_id: str)

Get a deployed usecase from the platform by its unique id.

Parameters:_id (str) – Unique id of the usecase version to retrieve
Returns:Fetched deployed usecase
Return type:UsecaseDeployment
Raises:PrevisionException – Any error while fetching data from the platform or parsing result
get_api_keys()

Fetch the api keys client id and cient secret of the usecase deployment from the actual [client] workspace.

Raises:
  • PrevisionException – If the dataset does not exist
  • requests.exceptions.ConnectionError – Error processing the request
classmethod list(project_id: str, all: bool = True) → List[previsionio.usecase_deployment.UsecaseDeployment]

List all the available usecase in the current active [client] workspace.

Warning

Contrary to the parent list() function, this method returns actual UsecaseDeployment objects rather than plain dictionaries with the corresponding data.

Parameters:
  • project_id (str) – project id
  • all (boolean, optional) – Whether to force the SDK to load all items of the given type (by calling the paginated API several times). Else, the query will only return the first page of result.
Returns:

Fetched dataset objects

Return type:

list(UsecaseDeployment)

list_predictions() → List[previsionio.prediction.DeploymentPrediction]

List all the available predictions in the current active [client] workspace.

Returns:Fetched deployed predictions objects
Return type:list(DeploymentPrediction)
new_version(name: str, main_model, challenger_model=None)

Create a new usecase deployment version.

Parameters:
  • name (str) – usecase deployment name
  • main_model – main model
  • challenger_model (optional) – challenger model. main and challenger models should be in the same usecase
Returns:

The registered usecase deployment object in the current project

Return type:

UsecaseDeployment

Raises:
  • PrevisionException – Any error while creating usecase deployment to the platform or parsing the result
  • Exception – For any other unknown error
predict_from_dataset(dataset: previsionio.dataset.Dataset) → previsionio.prediction.DeploymentPrediction

Make a prediction for a dataset stored in the current active [client] workspace (using the current SDK dataset object).

Parameters:dataset (Dataset) – Dataset resource to make a prediction for
Returns:The registered prediction object in the current workspace
Return type:DeploymentPrediction
wait_until(condition, timeout: float = 3600.0)

Wait until condition is fulfilled, then break.

Parameters:
  • (func (condition) – (BaseUsecaseVersion) -> bool.): Function to use to check the break condition
  • raise_on_error (bool, optional) – If true then the function will stop on error, otherwise it will continue waiting (default: True)
  • timeout (float, optional) – Maximal amount of time to wait before forcing exit

Example:

usecase.wait_until(lambda usecasev: len(usecasev.models) > 3)
Raises:PrevisionException – If the resource could not be fetched or there was a timeout.