abacusai.deployment

Module Contents

Classes

Deployment

A model deployment

class abacusai.deployment.Deployment(client, deploymentId=None, name=None, status=None, description=None, deployedAt=None, createdAt=None, projectId=None, modelId=None, modelVersion=None, featureGroupId=None, featureGroupVersion=None, callsPerSecond=None, autoDeploy=None, regions=None, error=None, batchStreamingUpdates=None, refreshSchedules={}, featureGroupExportConfig={})

Bases: abacusai.return_class.AbstractApiClass

A model deployment

Parameters
  • client (ApiClient) – An authenticated API Client instance

  • deploymentId (str) – The unique identifier for the deployment.

  • name (str) – The user-friendly name for the deployment.

  • status (str) – The status of the deployment.

  • description (str) – A description of this deployment.

  • deployedAt (str) – When the deployment last became active.

  • createdAt (str) – When the deployment was created.

  • projectId (str) – The unique identifier of the project this deployment belongs to.

  • modelId (str) – The model that is currently deployed.

  • modelVersion (str) – The model version ID that is currently deployed.

  • featureGroupId (str) – The feature group that is currently deployed.

  • featureGroupVersion (str) – The feature group version ID that is currently deployed.

  • callsPerSecond (int) – The number of calls per second the deployment could handle.

  • autoDeploy (bool) – Flag marking the deployment eligible for auto deployments whenever any model in the project finishes training.

  • regions (list of strings) – List of regions that a deployment has been deployed to

  • error (str) – Relevant error if the status is FAILED

  • batchStreamingUpdates (bool) – Flag marking the feature group deployment as having enabled a background process which caches streamed in rows for quicker lookup

  • refreshSchedules (RefreshSchedule) – List of refresh schedules that indicate when the deployment will be updated to the latest model version

  • featureGroupExportConfig (FeatureGroupExportConfig) – Export config (file connector or database connector information) for feature group deployment exports

__repr__()

Return repr(self).

to_dict()

Get a dict representation of the parameters in this class

Returns

The dict value representation of the class parameters

Return type

dict

refresh()

Calls describe and refreshes the current object’s fields

Returns

The current object

Return type

Deployment

describe()

Retrieves a full description of the specified deployment.

Parameters

deployment_id (str) – The unique ID associated with the deployment.

Returns

The description of the deployment.

Return type

Deployment

update(description=None)

Updates a deployment’s description.

Parameters

description (str) – The new deployment description.

rename(name)

Updates a deployment’s name and/or description.

Parameters

name (str) – The new deployment name.

set_auto(enable=None)

Enable/Disable auto deployment for the specified deployment.

When a model is scheduled to retrain, deployments with this enabled will be marked to automatically promote the new model version. After the newly trained model completes, a check on its metrics in comparison to the currently deployed model version will be performed. If the metrics are comparable or better, the newly trained model version is automatically promoted. If not, it will be marked as a failed model version promotion with an error indicating poor metrics performance.

Parameters

enable (bool) – Enable/disable the autoDeploy property of the Deployment.

set_model_version(model_version)

Promotes a Model Version to be served in the Deployment

Parameters

model_version (str) – The unique ID for the Model Version

set_feature_group_version(feature_group_version)

Promotes a Feature Group Version to be served in the Deployment

Parameters

feature_group_version (str) – The unique ID for the Feature Group Version

start()

Restarts the specified deployment that was previously suspended.

Parameters

deployment_id (str) – The unique ID associated with the deployment.

stop()

Stops the specified deployment.

Parameters

deployment_id (str) – The Deployment ID

delete()

Deletes the specified deployment. The deployment’s models will not be affected. Note that the deployments are not recoverable after they are deleted.

Parameters

deployment_id (str) – The ID of the deployment to delete.

set_feature_group_export_file_connector_output(file_format=None, output_location=None)

Sets the export output for the Feature Group Deployment to be a file connector.

Parameters
  • file_format (str) –

  • output_location (str) – the file connector (cloud) location of where to export

set_feature_group_export_database_connector_output(database_connector_id, object_name, write_mode, database_feature_mapping, id_column=None, additional_id_columns=None)

Sets the export output for the Feature Group Deployment to be a Database connector.

Parameters
  • database_connector_id (str) – The database connector ID used

  • object_name (str) – The database connector’s object to write to

  • write_mode (str) – UPSERT or INSERT for writing to the database connector

  • database_feature_mapping (dict) – The column/feature pairs mapping the features to the database columns

  • id_column (str) – The id column to use as the upsert key

  • additional_id_columns (list) – For database connectors which support it, additional ID columns to use as a complex key for upserting

remove_feature_group_export_output()

Removes the export type that is set for the Feature Group Deployment

Parameters

deployment_id (str) – The deployment for which the export type is set

create_batch_prediction(table_name=None, name=None, global_prediction_args=None, explanations=False, output_format=None, output_location=None, database_connector_id=None, database_output_config=None, refresh_schedule=None, csv_input_prefix=None, csv_prediction_prefix=None, csv_explanations_prefix=None, output_includes_metadata=None, result_input_columns=None)

Creates a batch prediction job description for the given deployment.

Parameters
  • table_name (str) – If specified, the name of the feature group table to write the results of the batch prediction. Can only be specified iff outputLocation and databaseConnectorId are not specified. If tableName is specified, the outputType will be enforced as CSV

  • name (str) – The name of batch prediction job.

  • global_prediction_args (dict) – Argument(s) to pass on every prediction call.

  • explanations (bool) – If true, will provide SHAP Explanations for each prediction, if supported by the use case.

  • output_format (str) – If specified, sets the format of the batch prediction output (CSV or JSON)

  • output_location (str) – If specified, the location to write the prediction results. Otherwise, results will be stored in Abacus.AI.

  • database_connector_id (str) – The unique identifier of an Database Connection to write predictions to. Cannot be specified in conjunction with outputLocation.

  • database_output_config (dict) – A key-value pair of columns/values to write to the database connector. Only available if databaseConnectorId is specified.

  • refresh_schedule (str) – A cron-style string that describes a schedule in UTC to automatically run the batch prediction.

  • csv_input_prefix (str) – A prefix to prepend to the input columns, only applies when output format is CSV

  • csv_prediction_prefix (str) – A prefix to prepend to the prediction columns, only applies when output format is CSV

  • csv_explanations_prefix (str) – A prefix to prepend to the explanation columns, only applies when output format is CSV

  • output_includes_metadata (bool) – If true, output will contain columns including prediction start time, batch prediction version, and model version

  • result_input_columns (list) – If present, will limit result files or feature groups to only include columns present in this list

Returns

The batch prediction description.

Return type

BatchPrediction

wait_for_deployment(wait_states={'PENDING', 'DEPLOYING'}, timeout=480)

A waiting call until deployment is completed.

Parameters

timeout (int, optional) – The waiting time given to the call to finish, if it doesn’t finish by the allocated time, the call is said to be timed out.

get_status()

Gets the status of the deployment.

Returns

A string describing the status of a deploymet (pending, deploying, active, etc.).

Return type

str

create_refresh_policy(cron)

To create a refresh policy for a deployment.

Parameters

cron (str) – A cron style string to set the refresh time.

Returns

The refresh policy object.

Return type

RefreshPolicy

list_refresh_policies()

Gets the refresh policies in a list.

Returns

A list of refresh policy objects.

Return type

List[RefreshPolicy]