:py:mod:`abacusai.deployment`
=============================

.. py:module:: abacusai.deployment


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   abacusai.deployment.Deployment




.. py:class:: 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, algoName=None, regions=None, error=None, batchStreamingUpdates=None, algorithm=None, pendingModelVersion=None, modelDeploymentConfig=None, refreshSchedules={}, featureGroupExportConfig={})

   Bases: :py:obj:`abacusai.return_class.AbstractApiClass`

   A model deployment

   :param client: An authenticated API Client instance
   :type client: ApiClient
   :param deploymentId: The unique identifier for the deployment.
   :type deploymentId: str
   :param name: The user-friendly name for the deployment.
   :type name: str
   :param status: The status of the deployment.
   :type status: str
   :param description: A description of this deployment.
   :type description: str
   :param deployedAt: When the deployment last became active.
   :type deployedAt: str
   :param createdAt: When the deployment was created.
   :type createdAt: str
   :param projectId: The unique identifier of the project this deployment belongs to.
   :type projectId: str
   :param modelId: The model that is currently deployed.
   :type modelId: str
   :param modelVersion: The model version ID that is currently deployed.
   :type modelVersion: str
   :param featureGroupId: The feature group that is currently deployed.
   :type featureGroupId: str
   :param featureGroupVersion: The feature group version ID that is currently deployed.
   :type featureGroupVersion: str
   :param callsPerSecond: The number of calls per second the deployment could handle.
   :type callsPerSecond: int
   :param autoDeploy: Flag marking the deployment eligible for auto deployments whenever any model in the project finishes training.
   :type autoDeploy: bool
   :param algoName: The name of the algorithm that is currently deployed
   :type algoName: str
   :param regions: List of regions that a deployment has been deployed to
   :type regions: list of strings
   :param error: Relevant error if the status is FAILED
   :type error: str
   :param batchStreamingUpdates: Flag marking the feature group deployment as having enabled a background process which caches streamed in rows for quicker lookup
   :type batchStreamingUpdates: bool
   :param algorithm: The algorithm that is currently deployed.
   :type algorithm: str
   :param pendingModelVersion: The model that the deployment is switching to.
   :type pendingModelVersion: dict
   :param modelDeploymentConfig: The config for what model to be deployed
   :type modelDeploymentConfig: dict
   :param refreshSchedules: List of refresh schedules that indicate when the deployment will be updated to the latest model version
   :type refreshSchedules: RefreshSchedule
   :param featureGroupExportConfig: Export config (file connector or database connector information) for feature group deployment exports
   :type featureGroupExportConfig: FeatureGroupExportConfig

   .. py:method:: __repr__()

      Return repr(self).


   .. py:method:: to_dict()

      Get a dict representation of the parameters in this class

      :returns: The dict value representation of the class parameters
      :rtype: dict


   .. py:method:: create_webhook(endpoint, webhook_event_type, payload_template = None)

      Create a webhook attached to a given deployment id.

      :param endpoint: URI that the webhook will send HTTP POST requests to.
      :type endpoint: str
      :param webhook_event_type: One of 'DEPLOYMENT_START', 'DEPLOYMENT_SUCCESS', 'DEPLOYMENT_FAILED'
      :type webhook_event_type: str
      :param payload_template: Template for the body of the HTTP POST requests. Defaults to {}.
      :type payload_template: dict

      :returns: The Webhook attached to the deployment
      :rtype: Webhook


   .. py:method:: list_webhooks()

      List and describe all the webhooks attached to a given deployment ID.

      :param deployment_id: ID of target deployment.
      :type deployment_id: str

      :returns: The webhooks attached to the given deployment id.
      :rtype: Webhook


   .. py:method:: refresh()

      Calls describe and refreshes the current object's fields

      :returns: The current object
      :rtype: Deployment


   .. py:method:: describe()

      Retrieves a full description of the specified deployment.

      :param deployment_id: The unique ID associated with the deployment.
      :type deployment_id: str

      :returns: The description of the deployment.
      :rtype: Deployment


   .. py:method:: update(description = None)

      Updates a deployment's description.

      :param description: The new deployment description.
      :type description: str


   .. py:method:: rename(name)

      Updates a deployment's name and/or description.

      :param name: The new deployment name.
      :type name: str


   .. py:method:: 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.


      :param enable: Enable/disable the autoDeploy property of the Deployment.
      :type enable: bool


   .. py:method:: set_model_version(model_version, algorithm = None, model_deployment_config = None)

      Promotes a model version to be served in a deployment by providing the deployment ID, model version ID, algorithm (optional), and model deployment config.

      :param model_version: The unique ID for the model version
      :type model_version: str
      :param algorithm: The algorithm to use for the model version. If not specified, the algorithm will be inferred from the model version.
      :type algorithm: str
      :param model_deployment_config: The deployment config for model to deploy
      :type model_deployment_config: dict


   .. py:method:: set_feature_group_version(feature_group_version)

      Promotes a Feature Group Version to be served in the Deployment

      :param feature_group_version: The unique ID for the Feature Group Version
      :type feature_group_version: str


   .. py:method:: start()

      Restarts the specified deployment that was previously suspended.

      :param deployment_id: The unique ID associated with the deployment.
      :type deployment_id: str


   .. py:method:: stop()

      Stops the specified deployment.

      :param deployment_id: The Deployment ID
      :type deployment_id: str


   .. py:method:: delete()

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

      :param deployment_id: The ID of the deployment to delete.
      :type deployment_id: str


   .. py:method:: 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.

      :param file_format:
      :type file_format: str
      :param output_location: the file connector (cloud) location of where to export
      :type output_location: str


   .. py:method:: 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.

      :param database_connector_id: The database connector ID used
      :type database_connector_id: str
      :param object_name: The database connector's object to write to
      :type object_name: str
      :param write_mode: UPSERT or INSERT for writing to the database connector
      :type write_mode: str
      :param database_feature_mapping: The column/feature pairs mapping the features to the database columns
      :type database_feature_mapping: dict
      :param id_column: The id column to use as the upsert key
      :type id_column: str
      :param additional_id_columns: For database connectors which support it, additional ID columns to use as a complex key for upserting
      :type additional_id_columns: list


   .. py:method:: remove_feature_group_export_output()

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

      :param deployment_id: The deployment for which the export type is set
      :type deployment_id: str


   .. py:method:: 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.

      :param table_name: 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
      :type table_name: str
      :param name: The name of batch prediction job.
      :type name: str
      :param global_prediction_args: Argument(s) to pass on every prediction call.
      :type global_prediction_args: dict
      :param explanations: If true, will provide SHAP Explanations for each prediction, if supported by the use case.
      :type explanations: bool
      :param output_format: If specified, sets the format of the batch prediction output (CSV or JSON)
      :type output_format: str
      :param output_location: If specified, the location to write the prediction results. Otherwise, results will be stored in Abacus.AI.
      :type output_location: str
      :param database_connector_id: The unique identifier of an Database Connection to write predictions to. Cannot be specified in conjunction with outputLocation.
      :type database_connector_id: str
      :param database_output_config: A key-value pair of columns/values to write to the database connector. Only available if databaseConnectorId is specified.
      :type database_output_config: dict
      :param refresh_schedule: A cron-style string that describes a schedule in UTC to automatically run the batch prediction.
      :type refresh_schedule: str
      :param csv_input_prefix: A prefix to prepend to the input columns, only applies when output format is CSV
      :type csv_input_prefix: str
      :param csv_prediction_prefix: A prefix to prepend to the prediction columns, only applies when output format is CSV
      :type csv_prediction_prefix: str
      :param csv_explanations_prefix: A prefix to prepend to the explanation columns, only applies when output format is CSV
      :type csv_explanations_prefix: str
      :param output_includes_metadata: If true, output will contain columns including prediction start time, batch prediction version, and model version
      :type output_includes_metadata: bool
      :param result_input_columns: If present, will limit result files or feature groups to only include columns present in this list
      :type result_input_columns: list

      :returns: The batch prediction description.
      :rtype: BatchPrediction


   .. py:method:: wait_for_deployment(wait_states={'PENDING', 'DEPLOYING'}, timeout=480)

      A waiting call until deployment is completed.

      :param timeout: 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.
      :type timeout: int, optional


   .. py:method:: wait_for_pending_deployment_update(timeout=600)

      A waiting call until pending model switch is completed.

      :param timeout: 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.
      :type timeout: int, optional

      :returns: the latest deployment object.
      :rtype: Deployment


   .. py:method:: get_status()

      Gets the status of the deployment.

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


   .. py:method:: create_refresh_policy(cron)

      To create a refresh policy for a deployment.

      :param cron: A cron style string to set the refresh time.
      :type cron: str

      :returns: The refresh policy object.
      :rtype: RefreshPolicy


   .. py:method:: list_refresh_policies()

      Gets the refresh policies in a list.

      :returns: A list of refresh policy objects.
      :rtype: List[RefreshPolicy]



