# Deployment management
URL: https://docs.datarobot.com/en/docs/api/reference/sdk/deployment-management.html

# Deployment Management

# Deployments

### class datarobot.models.Deployment

A deployment created from a DataRobot model.

- Variables:

#### classmethod create_from_learning_model(cls, model_id, label, description=None, default_prediction_server_id=None, importance=None, prediction_threshold=None, status=None, max_wait=600)

Create a deployment from a DataRobot model.

Added in version v2.17.

- Parameters:
- Returns: deployment – The created deployment
- Return type: Deployment

> [!NOTE] Examples
> ```
> from datarobot import Project, Deployment
> project = Project.get('5506fcd38bd88f5953219da0')
> model = project.get_models()[0]
> deployment = Deployment.create_from_learning_model(model.id, 'New Deployment')
> deployment
> >>> Deployment('New Deployment')
> ```

#### classmethod create_from_leaderboard(model_id, label, description=None, default_prediction_server_id=None, importance=None, prediction_threshold=None, status=None, max_wait=600)

Create a deployment from a Leaderboard.

Added in version v2.17.

- Parameters:
- Returns: deployment – The created deployment
- Return type: Deployment

> [!NOTE] Examples
> ```
> from datarobot import Project, Deployment
> project = Project.get('5506fcd38bd88f5953219da0')
> model = project.get_models()[0]
> deployment = Deployment.create_from_leaderboard(model.id, 'New Deployment')
> deployment
> >>> Deployment('New Deployment')
> ```

#### classmethod create_from_custom_model_version(custom_model_version_id, label, description=None, default_prediction_server_id=None, max_wait=600, importance=None)

Create a deployment from a DataRobot custom model image.

- Parameters:
- Returns: deployment – The created deployment
- Return type: Deployment

#### classmethod create_from_registered_model_version(model_package_id, label, description=None, default_prediction_server_id=None, prediction_environment_id=None, importance=None, user_provided_id=None, additional_metadata=None, max_wait=600)

Create a deployment from a DataRobot model package (version).

- Parameters:
- Returns: deployment – The created deployment
- Return type: Deployment

#### classmethod list(order_by=None, search=None, filters=None, offset=0, limit=0)

List all deployments a user can view.

Added in version v2.17.

- Parameters:

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployments = Deployment.list()
> deployments
> >>> [Deployment('New Deployment'), Deployment('Previous Deployment')]
> ```
> 
> ```
> from datarobot import Deployment
> from datarobot.enums import DEPLOYMENT_SERVICE_HEALTH_STATUS
> filters = DeploymentListFilters(
>     role='OWNER',
>     service_health=[DEPLOYMENT_SERVICE_HEALTH.FAILING]
> )
> filtered_deployments = Deployment.list(filters=filters)
> filtered_deployments
> >>> [Deployment('Deployment I Own w/ Failing Service Health')]
> ```

#### classmethod get(deployment_id)

Get information about a deployment.

Added in version v2.17.

- Parameters: deployment_id ( str ) – the ID of the deployment
- Returns: deployment – the queried deployment
- Return type: Deployment

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> deployment.id
> >>>'5c939e08962d741e34f609f0'
> deployment.label
> >>>'New Deployment'
> ```

#### predict_batch(source, passthrough_columns=None, download_timeout=None, download_read_timeout=None, upload_read_timeout=None)

A convenience method for making predictions with csv file or pandas DataFrame
using a batch prediction job.

For advanced usage, use [datarobot.models.BatchPredictionJob](https://docs.datarobot.com/en/docs/api/reference/sdk/batch-predictions.html#datarobot.models.BatchPredictionJob) directly.

Added in version v3.0.

- Parameters:
- Returns: Prediction results in a pandas DataFrame.
- Return type: pd.DataFrame
- Raises: InvalidUsageError – If the source parameter cannot be determined to be a filepath, file, or DataFrame.

> [!NOTE] Examples
> ```
> from datarobot.models.deployment import Deployment
> 
> deployment = Deployment.get("<MY_DEPLOYMENT_ID>")
> prediction_results_as_dataframe = deployment.predict_batch(
>     source="./my_local_file.csv",
> )
> ```

#### get_uri()

- Returns: url – Deployment’s overview URI
- Return type: str

#### update(label=None, description=None, importance=None)

Update the label and description of this deployment.

Added in version v2.19.

- Return type: None

#### delete()

Delete this deployment.

Added in version v2.17.

- Return type: None

#### activate(max_wait=600)

Activates this deployment. When succeeded, deployment status become active.

Added in version v2.29.

- Parameters: max_wait ( Optional[int] ) – The maximum time to wait for deployment activation to complete before erroring
- Return type: None

#### deactivate(max_wait=600)

Deactivates this deployment. When succeeded, deployment status become inactive.

Added in version v2.29.

- Parameters: max_wait ( Optional[int] ) – The maximum time to wait for deployment deactivation to complete before erroring
- Return type: None

#### replace_model(new_model_id, reason, max_wait=600, new_registered_model_version_id=None)

Replace the model used in this deployment. To confirm model replacement eligibility, use
: [validate_replacement_model()](https://docs.datarobot.com/en/docs/api/reference/sdk/deployment-management.html#datarobot.models.Deployment.validate_replacement_model) beforehand.

Added in version v2.17.

Model replacement is an asynchronous process, which means some preparatory work may
be performed after the initial request is completed. This function will not return until all
preparatory work is fully finished.

Predictions made against this deployment will start using the new model as soon as the
request is completed. There will be no interruption for predictions throughout
the process.

- Parameters:
- Return type: None

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> from datarobot.enums import MODEL_REPLACEMENT_REASON
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> deployment.model['id'], deployment.model['type']
> >>>('5c0a979859b00004ba52e431', 'Decision Tree Classifier (Gini)')
> 
> deployment.replace_model('5c0a969859b00004ba52e41b', MODEL_REPLACEMENT_REASON.ACCURACY)
> deployment.model['id'], deployment.model['type']
> >>>('5c0a969859b00004ba52e41b', 'Support Vector Classifier (Linear Kernel)')
> ```

#### perform_model_replace(new_registered_model_version_id, reason, max_wait=600)

Replace the model used in this deployment. To confirm model replacement eligibility, use
: [validate_replacement_model()](https://docs.datarobot.com/en/docs/api/reference/sdk/deployment-management.html#datarobot.models.Deployment.validate_replacement_model) beforehand.

Added in version v3.4.

Model replacement is an asynchronous process, which means some preparatory work may
be performed after the initial request is completed. This function will not return until all
preparatory work is fully finished.

Predictions made against this deployment will start using the new model as soon as the
request is completed. There will be no interruption for predictions throughout
the process.

- Parameters:
- Return type: None

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> from datarobot.enums import MODEL_REPLACEMENT_REASON
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> deployment.model_package['id']
> >>>'5c0a979859b00004ba52e431'
> 
> deployment.perform_model_replace('5c0a969859b00004ba52e41b', MODEL_REPLACEMENT_REASON.ACCURACY)
> deployment.model_package['id']
> >>>'5c0a969859b00004ba52e41b'
> ```

#### validate_replacement_model(new_model_id=None, new_registered_model_version_id=None)

Validate a model can be used as the replacement model of the deployment.

Added in version v2.17.

- Parameters:
- Return type: Tuple [ str , str , Dict [ str , Any ]]
- Returns:

#### get_features()

Retrieve the list of features needed to make predictions on this deployment.

> [!NOTE] Notes
> Each feature dict contains the following structure:
> 
> name
> : str, feature name
> feature_type
> : str, feature type
> importance
> : float, numeric measure of the relationship strength between
>   the feature and target (independent of model or other features)
> date_format
> : str or None, the date format string for how this feature was
>   interpreted, null if not a date feature, compatible with
> https://docs.python.org/2/library/time.html#time.strftime
> .
> known_in_advance
> : bool, whether the feature was selected as known in advance in
>   a time series model, false for non-time series models.

- Returns: features – a list of feature dict
- Return type: list

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> features = deployment.get_features()
> features[0]['feature_type']
> >>>'Categorical'
> features[0]['importance']
> >>>0.133
> ```

#### submit_actuals(data, batch_size=10000)

Submit actuals for processing.
The actuals submitted will be used to calculate accuracy metrics.

- Parameters:
- Raises: ValueError – if input data is not a list of dict-like objects or a pandas.DataFrame
      if input data is empty
- Return type: None

> [!NOTE] Examples
> ```
> from datarobot import Deployment, AccuracyOverTime
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> data = [{
>     'association_id': '439917',
>     'actual_value': 'True',
>     'was_acted_on': True
> }]
> deployment.submit_actuals(data)
> ```

#### submit_actuals_from_catalog_async(dataset_id, actual_value_column, association_id_column, dataset_version_id=None, timestamp_column=None, was_acted_on_column=None)

Submit actuals from AI Catalog for processing.
The actuals submitted will be used to calculate accuracy metrics.

- Parameters:
- Returns: status_check_job – Object contains all needed logic for a periodical status check of an async job.
- Return type: StatusCheckJob
- Raises: ValueError – if dataset_id not provided
      if actual_value_column not provided
      if association_id_column not provided

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> status_check_job = deployment.submit_actuals_from_catalog_async(data)
> ```

#### get_predictions_by_forecast_date_settings()

Retrieve predictions by forecast date settings of this deployment.

Added in version v2.27.

For time series deployments using the date/time format %Y-%m-%d %H:%M:%S.%f,
DataRobot automatically populates a v2 in front of the timestamp format
(forecast_date_format). Date/time values submitted in prediction data
should not include this v2 prefix. Other timestamp formats are not affected.

- Returns: settings – Predictions by forecast date settings of the deployment.
- Return type: ForecastDateSettings

#### update_predictions_by_forecast_date_settings(enable_predictions_by_forecast_date, forecast_date_column_name=None, forecast_date_format=None, max_wait=600)

Update predictions by forecast date settings of this deployment.

Added in version v2.27.

Updating predictions by forecast date setting is an asynchronous process,
which means some preparatory work may be performed after the initial request is completed.
This function will not return until all preparatory work is fully finished.

For time series deployments using the date/time format %Y-%m-%d %H:%M:%S.%f,
DataRobot automatically populates a v2 in front of the timestamp format
(forecast_date_format). If you are updating predictions by forecast date
settings for a Time Series deployment with date/time format
%Y-%m-%d %H:%M:%S.%f, you must add the v2 prefix to your submitted
forecast_date_format parameter. Date/time values submitted in prediction data
should not include this v2 prefix. Other timestamp formats are not affected.

> [!NOTE] Examples
> ```
> # To set predictions by forecast date settings to the same default settings you see when using
> # the DataRobot web application, you use your 'Deployment' object like this:
> deployment.update_predictions_by_forecast_date_settings(
>    enable_predictions_by_forecast_date=True,
>    forecast_date_column_name="date (actual)",
>    forecast_date_format="%Y-%m-%d",
> )
> ```

- Parameters:
- Return type: None

#### get_challenger_models_settings()

Retrieve challenger models settings of this deployment.

Added in version v2.27.

- Returns: settings
- Return type: ChallengerModelsSettings

#### update_challenger_models_settings(challenger_models_enabled, max_wait=600)

Update challenger models settings of this deployment.

Added in version v2.27.

Updating challenger models setting is an asynchronous process, which means some preparatory
work may be performed after the initial request is completed. This function will not return
until all preparatory work is fully finished.

- Parameters:
- Return type: None

#### get_segment_analysis_settings()

Retrieve segment analysis settings of this deployment.

Added in version v2.27.

- Returns: settings
- Return type: SegmentAnalysisSettings

#### update_segment_analysis_settings(segment_analysis_enabled, segment_analysis_attributes=None, max_wait=600)

Update segment analysis settings of this deployment.

Added in version v2.27.

Updating segment analysis setting is an asynchronous process, which means some preparatory
work may be performed after the initial request is completed. This function will not return
until all preparatory work is fully finished.

- Parameters:
- Return type: None

#### get_bias_and_fairness_settings()

Retrieve bias and fairness settings of this deployment.

..versionadded:: v3.2.0

- Returns: settings
- Return type: BiasAndFairnessSettings

#### update_bias_and_fairness_settings(protected_features, fairness_metric_set, fairness_threshold, preferable_target_value, max_wait=600)

Update bias and fairness settings of this deployment.

..versionadded:: v3.2.0

Updating bias and fairness setting is an asynchronous process, which means some preparatory
work may be performed after the initial request is completed. This function will not return
until all preparatory work is fully finished.

- Parameters:
- Return type: None

#### get_challenger_replay_settings()

Retrieve challenger replay settings of this deployment.

Added in version v3.4.

- Returns: settings
- Return type: ChallengerReplaySettings

#### update_challenger_replay_settings(enabled, schedule=None)

Update challenger replay settings of this deployment.

Added in version v3.4.

- Parameters:
- Return type: None

#### get_drift_tracking_settings()

Retrieve drift tracking settings of this deployment.

Added in version v2.17.

- Returns: settings
- Return type: DriftTrackingSettings

#### update_drift_tracking_settings(target_drift_enabled=None, feature_drift_enabled=None, max_wait=600)

Update drift tracking settings of this deployment.

Added in version v2.17.

Updating drift tracking setting is an asynchronous process, which means some preparatory
work may be performed after the initial request is completed. This function will not return
until all preparatory work is fully finished.

- Parameters:
- Return type: None

#### get_association_id_settings()

Retrieve association ID setting for this deployment.

Added in version v2.19.

- Returns: association_id_settings
- Return type: str

#### update_association_id_settings(column_names=None, required_in_prediction_requests=None, max_wait=600)

Update association ID setting for this deployment.

Added in version v2.19.

- Parameters:
- Return type: None

#### get_predictions_data_collection_settings()

Retrieve predictions data collection settings of this deployment.

Added in version v2.21.

- Returns: predictions_data_collection_settings –
- Return type: dict in the following format:

#### SEE ALSO

[datarobot.models.Deployment.update_predictions_data_collection_settings](https://docs.datarobot.com/en/docs/api/reference/sdk/deployment-management.html#datarobot.models.Deployment.update_predictions_data_collection_settings): Method to update existing predictions data collection settings.

#### update_predictions_data_collection_settings(enabled, max_wait=600)

Update predictions data collection settings of this deployment.

Added in version v2.21.

Updating predictions data collection setting is an asynchronous process, which means some
preparatory work may be performed after the initial request is completed.
This function will not return until all preparatory work is fully finished.

- Parameters:
- Return type: None

#### get_prediction_warning_settings()

Retrieve prediction warning settings of this deployment.

Added in version v2.19.

- Returns: settings
- Return type: PredictionWarningSettings

#### update_prediction_warning_settings(prediction_warning_enabled, use_default_boundaries=None, lower_boundary=None, upper_boundary=None, max_wait=600)

Update prediction warning settings of this deployment.

Added in version v2.19.

- Parameters:
- Return type: None

#### get_prediction_intervals_settings()

Retrieve prediction intervals settings for this deployment.

Added in version v2.19.

> [!NOTE] Notes
> Note that prediction intervals are only supported for time series deployments.

- Returns: settings
- Return type: PredictionIntervalsSettings

#### update_prediction_intervals_settings(percentiles, enabled=True, max_wait=600)

Update prediction intervals settings for this deployment.

Added in version v2.19.

> [!NOTE] Notes
> Updating prediction intervals settings is an asynchronous process, which means some
> preparatory work may be performed before the settings request is completed. This function
> will not return until all work is fully finished.
> 
> Note that prediction intervals are only supported for time series deployments.

- Parameters:
- Raises:
- Return type: None

#### get_health_settings()

Retrieve health settings of this deployment.

Added in version v3.4.

- Returns: settings
- Return type: HealthSettings

#### update_health_settings(service=None, data_drift=None, accuracy=None, fairness=None, custom_metrics=None, predictions_timeliness=None, actuals_timeliness=None)

Update health settings of this deployment.

Added in version v3.4.

- Parameters:
- Return type: HealthSettings

#### get_default_health_settings()

Retrieve default health settings of this deployment.

Added in version v3.4.

- Returns: settings
- Return type: HealthSettings

#### get_service_stats(model_id=None, start_time=None, end_time=None, execution_time_quantile=None, response_time_quantile=None, slow_requests_threshold=None, segment_attribute=None, segment_value=None)

Retrieves values of many service stat metrics aggregated over a time period.

Added in version v2.18.

- Parameters:
- Returns: service_stats – the queried service stats metrics information
- Return type: ServiceStats

#### get_service_stats_over_time(metric=None, model_id=None, start_time=None, end_time=None, bucket_size=None, quantile=None, threshold=None, segment_attribute=None, segment_value=None)

Retrieves values of a single service stat metric over a time period.

Added in version v2.18.

- Parameters:
- Returns: service_stats_over_time – the queried service stats metric over time information
- Return type: ServiceStatsOverTime

#### get_target_drift(model_id=None, start_time=None, end_time=None, metric=None, segment_attribute=None, segment_value=None)

Retrieve target drift information over a certain time period.

Added in version v2.21.

- Parameters:
- Returns: target_drift – the queried target drift information
- Return type: TargetDrift

#### get_feature_drift(model_id=None, start_time=None, end_time=None, metric=None, segment_attribute=None, segment_value=None)

Retrieve drift information for deployment’s features over a certain time period.

Added in version v2.21.

- Parameters:
- Returns: feature_drift_data – the queried feature drift information
- Return type: [FeatureDrift]

#### get_predictions_over_time(model_ids=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, include_percentiles=False, segment_attribute=None, segment_value=None)

Retrieve stats of deployment’s prediction response over a certain time period.

Added in version v3.2.

- Parameters:
- Returns: predictions_over_time – the queried predictions over time information
- Return type: PredictionsOverTime

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> predictions_over_time = deployment.get_predictions_over_time()
> predictions_over_time.buckets[0]['mean_predicted_value']
> >>>0.3772
> predictions_over_time.buckets[0]['row_count']
> >>>2000
> ```

#### get_accuracy(model_id=None, start_time=None, end_time=None, start=None, end=None, target_classes=None, segment_attribute=None, segment_value=None, metric=None, baseline_model_id=None)

Retrieves values of many accuracy metrics aggregated over a time period.

Added in version v2.18.

- Parameters:
- Returns: accuracy – the queried accuracy metrics information
- Return type: Accuracy

#### get_accuracy_over_time(metric=None, model_id=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, segment_attribute=None, segment_value=None)

Retrieves values of a single accuracy metric over a time period.

Added in version v2.18.

- Parameters:
- Returns: accuracy_over_time – the queried accuracy metric over time information
- Return type: AccuracyOverTime

#### get_predictions_vs_actuals_over_time(model_ids=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, segment_attribute=None, segment_value=None)

Retrieve information for deployment’s predictions vs actuals over a certain time period.

Added in version v3.3.

- Parameters:
- Returns: predictions_vs_actuals_over_time – The queried predictions vs actuals over time information.
- Return type: PredictionsVsActualsOverTime

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> predictions_over_time = deployment.get_predictions_vs_actuals_over_time()
> predictions_over_time.buckets[0]['mean_actual_value']
> >>>0.6673
> predictions_over_time.buckets[0]['row_count_with_actual']
> >>>500
> ```

#### get_fairness_scores_over_time(start_time=None, end_time=None, bucket_size=None, model_id=None, protected_feature=None, fairness_metric=None)

Retrieves values of a single fairness score over a time period.

Added in version v3.2.

- Parameters:
- Returns: fairness_scores_over_time – the queried fairness score over time information
- Return type: FairnessScoresOverTime

#### update_secondary_dataset_config(secondary_dataset_config_id, credential_ids=None)

Update the secondary dataset config used by Feature discovery model for a
given deployment.

Added in version v2.23.

- Parameters:
- Return type: str

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment(deployment_id='5c939e08962d741e34f609f0')
> config = deployment.update_secondary_dataset_config('5df109112ca582033ff44084')
> config
> >>> '5df109112ca582033ff44084'
> ```

#### get_secondary_dataset_config()

Get the secondary dataset config used by Feature discovery model for a
given deployment.

Added in version v2.23.

- Returns: secondary_dataset_config – Id of the secondary dataset config
- Return type: SecondaryDatasetConfigurations

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment(deployment_id='5c939e08962d741e34f609f0')
> deployment.update_secondary_dataset_config('5df109112ca582033ff44084')
> config = deployment.get_secondary_dataset_config()
> config
> >>> '5df109112ca582033ff44084'
> ```

#### get_prediction_results(model_id=None, start_time=None, end_time=None, actuals_present=None, offset=None, limit=None)

Retrieve a list of prediction results of the deployment.

Added in version v2.24.

- Parameters:
- Returns: prediction_results – a list of prediction results
- Return type: list[dict]

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> results = deployment.get_prediction_results()
> ```

#### download_prediction_results(filepath, model_id=None, start_time=None, end_time=None, actuals_present=None, offset=None, limit=None)

Download prediction results of the deployment as a CSV file.

Added in version v2.24.

- Parameters:
- Return type: None

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> results = deployment.download_prediction_results('path_to_prediction_results.csv')
> ```

#### download_scoring_code(filepath, source_code=False, include_agent=False, include_prediction_explanations=False, include_prediction_intervals=False, max_wait=600)

Retrieve scoring code of the current deployed model.

Added in version v2.24.

> [!NOTE] Notes
> When setting include_agent or include_predictions_explanations or
> include_prediction_intervals to True,
> it can take a considerably longer time to download the scoring code.

- Parameters:
- Return type: None

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> results = deployment.download_scoring_code('path_to_scoring_code.jar')
> ```

#### download_model_package_file(filepath, compute_all_ts_intervals=False)

Retrieve model package file (mlpkg) of the current deployed model.

Added in version v3.3.

- Parameters:
- Return type: None

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> deployment.download_model_package_file('path_to_model_package.mlpkg')
> ```

#### delete_monitoring_data(model_id, start_time=None, end_time=None, max_wait=600)

Delete deployment monitoring data.

- Parameters:
- Return type: None

#### list_shared_roles(id=None, name=None, share_recipient_type=None, limit=100, offset=0)

Get a list of users, groups and organizations that have an access to this user blueprint

- Parameters:
- Return type: List[DeploymentSharedRole]

#### update_shared_roles(roles)

Share a deployment with a user, group, or organization

- Parameters: roles ( list(or(GrantAccessControlWithUsernameValidator , GrantAccessControlWithIdValidator , SharingRole)) ) – Array of GrantAccessControl objects, up to maximum 100 objects.
- Return type: None

#### share(roles)

Share a deployment with a user, group, or organization

- Parameters: roles ( list(SharingRole) ) – Array of SharingRole objects.
- Return type: None

#### list_challengers()

Get a list of challengers for this deployment.

Added in version v3.4.

- Return type: list(Challenger)

#### get_agent_card()

Retrieve the agent card for this deployment.

- Returns: agent_card – The agent card associated with this deployment.
- Return type: dict

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> agent_card = deployment.get_agent_card()
> ```

#### upload_agent_card(agent_card)

Upload or replace the agent card for this deployment.

This is only available for external deployments.

- Parameters: agent_card ( dict ) – The agent card to upload for this deployment.
- Returns: agent_card – The uploaded agent card.
- Return type: dict

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> agent_card = deployment.upload_agent_card({"name": "My Agent", "version": "1.0.0"})
> ```

#### delete_agent_card()

Delete the agent card for this deployment.

This is only available for external deployments.
This operation is idempotent — returns successfully even if no agent card exists.

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> deployment.delete_agent_card()
> ```

- Return type: None

#### get_champion_model_package()

Get a champion model package for this deployment.

- Returns: champion_model_package – A champion model package object.
- Return type: ChampionModelPackage

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> champion_model_package = deployment.get_champion_model_package()
> ```

#### list_prediction_data_exports(model_id=None, status=None, batch=None, offset=0, limit=100)

Retrieve a list of asynchronous prediction data exports.

- Parameters:
- Returns: prediction_data_exports – A list of prediction data exports.
- Return type: List[PredictionDataExport]

#### list_actuals_data_exports(status=None, offset=0, limit=100)

Retrieve a list of asynchronous actuals data exports.

- Parameters:
- Returns: actuals_data_exports – A list of actuals data exports.
- Return type: List[ActualsDataExport]

#### list_training_data_exports()

Retrieve a list of successful training data exports.

- Returns: training_data_export – A list of training data exports.
- Return type: List[TrainingDataExport]

#### list_data_quality_exports(start, end, model_id=None, prediction_pattern=None, prompt_pattern=None, actual_pattern=None, order_by=None, order_metric=None, filter_metric=None, filter_value=None, offset=0, limit=100)

Retrieve a list of data-quality export records for a given deployment.

Added in version v3.6.

- Parameters:
- Returns: data_quality_exports – A list of DataQualityExport objects.
- Return type: list

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> 
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> data_quality_exports = deployment.list_data_quality_exports(start_time='2024-07-01', end_time='2024-08-01')
> ```

#### get_capabilities()

Get a list capabilities for this deployment.

Added in version v3.5.

- Return type: list(Capability)

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> capabilities = deployment.get_capabilities()
> ```

#### get_segment_attributes(monitoringType='serviceHealth')

Get a list of segment attributes for this deployment.

Added in version v3.6.

- Parameters: monitoringType ( Optional[str] ) – The monitoring type for which segment attributes are being retrieved.
- Return type: list(str)

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> segment_attributes = deployment.get_segment_attributes(DEPLOYMENT_MONITORING_TYPE.SERVICE_HEALTH)
> ```

#### get_segment_values(segment_attribute=None, limit=100, offset=0, search=None)

Get a list of segment values for this deployment.

Added in version v3.6.

- Parameters:
- Return type: list(str)

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> segment_values = deployment.get_segment_values(segment_attribute=ReservedSegmentAttributes.CONSUMER)
> ```

#### get_moderation_events(limit=100, offset=0)

Get a list of moderation events for this deployment

- Parameters:
- Returns: events
- Return type: List[MLOpsEvent]

#### get_accuracy_metrics_settings()

Get accuracy metrics settings for this deployment.

- Returns: accuracy_metrics – A list of deployment accuracy metric names.
- Return type: list(str)

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> 
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> accuracy_metrics = deployment.get_accuracy_metrics_settings()
> ```

#### update_accuracy_metrics_settings(accuracy_metrics)

Update accuracy metrics settings for this deployment.

- Parameters: accuracy_metrics ( list(str) ) – A list of accuracy metric names.
- Returns: accuracy_metrics – A list of deployment accuracy metric names.
- Return type: list(str)

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> from datarobot.enums import ACCURACY_METRIC
> 
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> payload = [ACCURACY_METRIC.AUC, ACCURACY_METRIC.LOGLOSS]
> accuracy_metrics = deployment.update_accuracy_metrics_settings(payload)
> ```

#### get_retraining_settings()

Retrieve retraining settings of this deployment.

Added in version v2.29.

- Returns: settings
- Return type: RetrainingSettings

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> 
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> retraining_settings = deployment.get_retraining_settings()
> ```

#### update_retraining_settings(retraining_user_id=, dataset_id=, prediction_environment_id=)

Update retraining settings of this deployment.

Added in version v2.29.

- Parameters:
- Return type: None

> [!NOTE] Examples
> ```
> from datarobot import Deployment
> 
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> deployment.update_retraining_settings(retaining_user_id='5c939e08962d741e34f609f0')
> ```

#### create_tag(name, value)

Create a new deployment tag.

- Parameters:
- Return type: dict [ str , str ]

#### update_tag(id, name, value)

Update an existing deployment tag.

- Parameters:
- Return type: dict [ str , str ]

#### delete_tag(id)

Deletes the deployment tag specified by ID.

- Parameters: id ( str ) – The ID of the deployment tag to delete.
- Return type: None

#### classmethod from_data(data)

Instantiate an object of this class using a dict.

- Parameters: data ( dict ) – Correctly snake_cased keys and their values.
- Return type: TypeVar ( T , bound= APIObject)

#### classmethod from_server_data(data, keep_attrs=None)

Instantiate an object of this class using the data directly from the server,
meaning that the keys may have the wrong camel casing

- Parameters:
- Return type: TypeVar ( T , bound= APIObject)

#### open_in_browser()

Opens class’ relevant web browser location.
If default browser is not available the URL is logged.

Note:
If text-mode browsers are used, the calling process will block
until the user exits the browser.

- Return type: None

### class datarobot.models.deployment.DeploymentListFilters

Construct a set of filters to pass to `Deployment.list()`

Added in version v2.20.

- Parameters:

> [!NOTE] Examples
> Multiple filters can be combined in interesting ways to return very specific subsets of
> deployments.
> 
> Performing AND logic
> 
> Providing multiple different parameters will result in AND logic between them.
> For example, the following will return all deployments that I own whose service health
> status is failing.
> from
> datarobot
> import
> Deployment
> from
> datarobot.models.deployment
> import
> DeploymentListFilters
> from
> datarobot.enums
> import
> DEPLOYMENT_SERVICE_HEALTH_STATUS
> filters
> =
> DeploymentListFilters
> (
> role
> =
> 'OWNER'
> ,
> service_health
> =
> [
> DEPLOYMENT_SERVICE_HEALTH
> .
> FAILING
> ]
> )
> deployments
> =
> Deployment
> .
> list
> (
> filters
> =
> filters
> )
> 
> Performing OR logic
> 
> Some filters support comma-separated lists (and will say so if they do). Providing a
> comma-separated list of values to a single filter performs OR logic between those
> values. For example, the following will return all deployments whose service health
> is either
> warning
> OR
> failing
> .
> from
> datarobot
> import
> Deployment
> from
> datarobot.models.deployment
> import
> DeploymentListFilters
> from
> datarobot.enums
> import
> DEPLOYMENT_SERVICE_HEALTH_STATUS
> filters
> =
> DeploymentListFilters
> (
> service_health
> =
> [
> DEPLOYMENT_SERVICE_HEALTH
> .
> WARNING
> ,
> DEPLOYMENT_SERVICE_HEALTH
> .
> FAILING
> ,
> ]
> )
> deployments
> =
> Deployment
> .
> list
> (
> filters
> =
> filters
> )
> 
> Performing OR logic across different filter types is not supported.

> [!NOTE] Notes
> In all cases, you may only retrieve deployments for which you have at least
> the USER role for. Deployments for which you are a CONSUMER of will not be returned,
> regardless of the filters applied.

### class datarobot.models.deployment.ServiceStats

Deployment service stats information.

- Variables:

#### classmethod get(deployment_id, model_id=None, start_time=None, end_time=None, execution_time_quantile=None, response_time_quantile=None, segment_attribute=None, segment_value=None, slow_requests_threshold=None)

Retrieve value of service stat metrics over a certain time period.

Added in version v2.18.

- Parameters:
- Returns: service_stats – the queried service stats metrics
- Return type: ServiceStats

### class datarobot.models.deployment.ServiceStatsOverTime

Deployment service stats over time information.

- Variables:

#### classmethod get(deployment_id, metric=None, model_id=None, start_time=None, end_time=None, bucket_size=None, quantile=None, threshold=None, segment_attribute=None, segment_value=None)

Retrieve information about how a service stat metric changes over a certain time period.

Added in version v2.18.

- Parameters:
- Returns: service_stats_over_time – the queried service stat over time information
- Return type: ServiceStatsOverTime

#### property bucket_values : OrderedDict[str, int | float | None]

The metric value for all time buckets, keyed by start time of the bucket.

- Returns: bucket_values
- Return type: OrderedDict

### class datarobot.models.deployment.TargetDrift

Deployment target drift information.

- Variables:

#### classmethod get(deployment_id, model_id=None, start_time=None, end_time=None, metric=None, segment_attribute=None, segment_value=None)

Retrieve target drift information over a certain time period.

Added in version v2.21.

- Parameters:
- Returns: target_drift – the queried target drift information
- Return type: TargetDrift

> [!NOTE] Examples
> ```
> from datarobot import Deployment, TargetDrift
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> target_drift = TargetDrift.get(deployment.id)
> target_drift.period['end']
> >>>'2019-08-01 00:00:00+00:00'
> target_drift.drift_score
> >>>0.03423
> accuracy.target_name
> >>>'readmitted'
> ```

### class datarobot.models.deployment.FeatureDrift

Deployment feature drift information.

- Variables:

#### classmethod list(deployment_id, model_id=None, start_time=None, end_time=None, metric=None, segment_attribute=None, segment_value=None)

Retrieve drift information for deployment’s features over a certain time period.

Added in version v2.21.

- Parameters:
- Returns: feature_drift_data – the queried feature drift information
- Return type: [FeatureDrift]

> [!NOTE] Examples
> ```
> from datarobot import Deployment, TargetDrift
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> feature_drift = FeatureDrift.list(deployment.id)[0]
> feature_drift.period
> >>>'2019-08-01 00:00:00+00:00'
> feature_drift.drift_score
> >>>0.252
> feature_drift.name
> >>>'age'
> ```

### class datarobot.models.deployment.PredictionsOverTime

Deployment predictions over time information.

- Variables:

#### classmethod get(deployment_id, model_ids=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, include_percentiles=False, segment_attribute=None, segment_value=None)

Retrieve information for deployment’s prediction response over a certain time period.

Added in version v3.2.

- Parameters:
- Returns: predictions_over_time – the queried predictions over time information
- Return type: PredictionsOverTime

### class datarobot.models.deployment.Accuracy

Deployment accuracy information.

- Variables:

#### classmethod get(deployment_id, model_id=None, start_time=None, end_time=None, target_classes=None, segment_attribute=None, segment_value=None, metric=None, baseline_model_id=None)

Retrieve values of accuracy metrics over a certain time period.

Added in version v2.18.

- Parameters:
- Returns: accuracy – the queried accuracy metrics information
- Return type: Accuracy

> [!NOTE] Examples
> ```
> from datarobot import Deployment, Accuracy
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> accuracy = Accuracy.get(deployment.id)
> accuracy.period['end']
> >>>'2019-08-01 00:00:00+00:00'
> accuracy.metric['LogLoss']['value']
> >>>0.7533
> accuracy.metric_values['LogLoss']
> >>>0.7533
> ```

#### property metric_values : Dict[str, int | None]

The value for all metrics, keyed by metric name.

- Returns: metric_values
- Return type: Dict

#### property metric_baselines : Dict[str, int | None]

The baseline value for all metrics, keyed by metric name.

- Returns: metric_baselines
- Return type: Dict

#### property percent_changes : Dict[str, int | None]

The percent change of value over baseline for all metrics, keyed by metric name.

- Returns: percent_changes
- Return type: Dict

### class datarobot.models.deployment.AccuracyOverTime

Deployment accuracy over time information.

- Variables:

#### classmethod get(deployment_id, metric=None, model_id=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, segment_attribute=None, segment_value=None)

Retrieve information about how an accuracy metric changes over a certain time period.

Added in version v2.18.

- Parameters:
- Returns: accuracy_over_time – the queried accuracy metric over time information
- Return type: AccuracyOverTime

> [!NOTE] Examples
> ```
> from datarobot import Deployment, AccuracyOverTime
> from datarobot.enums import ACCURACY_METRICS
> deployment = Deployment.get(deployment_id='5c939e08962d741e34f609f0')
> accuracy_over_time = AccuracyOverTime.get(deployment.id, metric=ACCURACY_METRIC.LOGLOSS)
> accuracy_over_time.metric
> >>>'LogLoss'
> accuracy_over_time.metric_values
> >>>{datetime.datetime(2019, 8, 1): 0.73, datetime.datetime(2019, 8, 2): 0.55}
> ```

#### classmethod get_as_dataframe(deployment_id, metrics=None, model_id=None, start_time=None, end_time=None, bucket_size=None)

Retrieve information about how a list of accuracy metrics change over
a certain time period as pandas DataFrame.

In the returned DataFrame, the columns corresponds to the metrics being retrieved;
the rows are labeled with the start time of each bucket.

- Parameters:
- Returns: accuracy_over_time
- Return type: pd.DataFrame

#### property bucket_values : Dict[datetime, int]

The metric value for all time buckets, keyed by start time of the bucket.

- Returns: bucket_values
- Return type: Dict

#### property bucket_sample_sizes : Dict[datetime, int]

The sample size for all time buckets, keyed by start time of the bucket.

- Returns: bucket_sample_sizes
- Return type: Dict

### class datarobot.models.deployment.PredictionsVsActualsOverTime

Deployment predictions vs actuals over time information.

- Variables:

#### classmethod get(deployment_id, model_ids=None, start_time=None, end_time=None, bucket_size=None, target_classes=None, segment_attribute=None, segment_value=None)

Retrieve information for deployment’s predictions vs actuals over a certain time period.

Added in version v3.3.

- Parameters:
- Returns: predictions_vs_actuals_over_time – the queried predictions vs actuals over time information
- Return type: PredictionsVsActualsOverTime

### class datarobot.models.deployment.bias_and_fairness.FairnessScoresOverTime

Deployment fairness over time information.

- Variables:

#### classmethod get(deployment_id, model_id=None, start_time=None, end_time=None, bucket_size=None, fairness_metric=None, protected_feature=None)

Retrieve information for deployment’s fairness score response over a certain time period.

Added in version FUTURE.

- Parameters:
- Returns: fairness_scores_over_time – the queried fairness score over time information
- Return type: FairnessScoresOverTime

### class datarobot.models.deployment.DeploymentSharedRole

- Parameters:

### class datarobot.models.deployment.DeploymentGrantSharedRoleWithId

- Parameters:

### class datarobot.models.deployment.DeploymentGrantSharedRoleWithUsername

- Parameters:

### class datarobot.models.deployment.deployment.FeatureDict

### class datarobot.models.deployment.deployment.ForecastDateSettings

Forecast date settings of the deployment

- Variables:

### class datarobot.models.deployment.deployment.ChallengerModelsSettings

Challenger models settings of the deployment is a dict with the following format:

- Variables: enabled ( bool ) – Is True if challenger models is enabled for this deployment. To update
  existing ‘’challenger_models’’ settings, see update_challenger_models_settings()

### class datarobot.models.deployment.deployment.SegmentAnalysisSettings

Segment analysis settings of the deployment containing two items with keys
: `enabled` and `attributes`, which are further described below.

- Variables:

### class datarobot.models.deployment.deployment.BiasAndFairnessSettings

Bias and fairness settings of this deployment

- Variables:

### class datarobot.models.deployment.deployment.ChallengerReplaySettings

Challenger replay settings of the deployment is a dict with the following format:

- Variables:

### class datarobot.models.deployment.deployment.HealthSettings

Health settings of the deployment containing seven nested dicts with keys

- Variables:

### class datarobot.models.deployment.deployment.DriftTrackingSettings

Drift tracking settings of the deployment containing two nested dicts with key
: `target_drift` and `feature_drift`, which are further described below.

- Variables:

### class datarobot.models.deployment.deployment.PredictionWarningSettings

Prediction warning settings of the deployment

- Variables:

### class datarobot.models.deployment.deployment.PredictionIntervalsSettings

Prediction intervals settings of the deployment is a dict with the following format:

- Variables:

### class datarobot.models.deployment.deployment.Capability

### class datarobot.enums.ACCURACY_METRIC

## Predictions

### class datarobot.models.Predictions

Represents predictions metadata and provides access to prediction results.

- Variables:

> [!NOTE] Examples
> List all predictions for a project
> 
> ```
> import datarobot as dr
> 
> # Fetch all predictions for a project
> all_predictions = dr.Predictions.list(project_id)
> 
> # Inspect all calculated predictions
> for predictions in all_predictions:
>     print(predictions)  # repr includes project_id, model_id, and dataset_id
> ```
> 
> Retrieve predictions by id
> 
> ```
> import datarobot as dr
> 
> # Getting predictions by id
> predictions = dr.Predictions.get(project_id, prediction_id)
> 
> # Dump actual predictions
> df = predictions.get_all_as_dataframe()
> print(df)
> ```

#### classmethod list(project_id, model_id=None, dataset_id=None)

Fetch all the computed predictions metadata for a project.

- Parameters:
- Return type: A list of Predictions objects

#### classmethod get(project_id, prediction_id)

Retrieve the specific predictions metadata

- Parameters:
- Return type: Predictions
- Returns:

#### get_all_as_dataframe(class_prefix='class_', serializer='json')

Retrieve all prediction rows and return them as a pandas.DataFrame.

- Parameters:
- Returns: dataframe
- Return type: pandas.DataFrame
- Raises:

#### download_to_csv(filename, encoding='utf-8', serializer='json')

Save prediction rows into CSV file.

- Parameters:
- Return type: None

## PredictionServer

### class datarobot.PredictionServer

A prediction server can be used to make predictions.

- Variables:

#### classmethod list()

Returns a list of prediction servers a user can use to make predictions.

Added in version v2.17.

- Returns: prediction_servers – Contains a list of prediction servers that can be used to make predictions.
- Return type: list of PredictionServer instances

> [!NOTE] Examples
> ```
> prediction_servers = PredictionServer.list()
> prediction_servers
> >>> [PredictionServer('https://example.com')]
> ```

## Prediction environment

### class datarobot.models.PredictionEnvironment

A prediction environment entity.

Added in version v3.3.0.

- Variables:

#### classmethod list()

Returns list of available external prediction environments.

- Returns: prediction_environments – contains a list of available prediction environments.
- Return type: list of PredictionEnvironment instances

> [!NOTE] Examples
> ```
> >>> import datarobot as dr
> >>> prediction_environments = dr.PredictionEnvironment.list()
> >>> prediction_environments
> [
>     PredictionEnvironment('5e429d6ecf8a5f36c5693e03', 'demo_pe', 'aws', 'env for demo testing'),
>     PredictionEnvironment('5e42cc4dcf8a5f3256865840', 'azure_pe', 'azure', 'env for azure demo testing'),
> ]
> ```

#### classmethod get(pe_id)

Gets the PredictionEnvironment by id.

- Parameters: pe_id ( str ) – the identifier of the PredictionEnvironment.
- Returns: prediction_environment – the requested prediction environment object.
- Return type: PredictionEnvironment

> [!NOTE] Examples
> ```
> >>> import datarobot as dr
> >>> pe = dr.PredictionEnvironment.get('5a8ac9ab07a57a1231be501f')
> >>> pe
> PredictionEnvironment('5a8ac9ab07a57a1231be501f', 'my_predict_env', 'aws', 'demo env'),
> ```

#### delete()

Deletes the prediction environment.

> [!NOTE] Examples
> ```
> >>> import datarobot as dr
> >>> pe = dr.PredictionEnvironment.get('5a8ac9ab07a57a1231be501f')
> >>> pe.delete()
> ```

- Return type: None

#### classmethod create(name, platform, description=None, plugin=None, supported_model_formats=None, is_managed_by_management_agent=False, datastore=None, credential=None)

Create a prediction environment.

- Parameters:
- Returns: prediction_environment – the prediction environment was created
- Return type: PredictionEnvironment
- Raises:

> [!NOTE] Examples
> ```
> >>> import datarobot as dr
> >>> pe = dr.PredictionEnvironment.create(
> ...     name='my_predict_env',
> ...     platform=PredictionEnvironmentPlatform.AWS,
> ...     description='demo prediction env',
> ... )
> >>> pe
> PredictionEnvironment('5e429d6ecf8a5f36c5693e99', 'my_predict_env', 'aws', 'demo prediction env'),
> ```

---
