---
updatedAt: 2026-05-04T08:41:37.000Z
agentTools:
  projectIndex: https://documentation.picsellia.com/llms.txt
---

# Deployment

#

# *Properties*

***

***

* `connexion` deprecated

***

***

* `connexion` deprecated

***

* `name` Name of this [Deployment](deployment)

* `type` Type of this [Deployment](deployment)

* `oracle_connexion` deprecated

* `serving_connexion` deprecated

***

# *Methods*

## add\_tags

```python
add_tags(
   tags: (Tag|list[Tag])
)
```

**Description**

Add some tags to an object.
It can be used on Data/MultiData/Asset/MultiAsset/DatasetVersion/Dataset/Model/ModelVersion.

You can give a Tag or a list of [Tag](tag).

**Examples**

```python
tag_bicycle = client.create_tag("bicycle", Target.DATA)
tag_car = client.create_tag("car", Target.DATA)
tag_truck = client.create_tag("truck", Target.DATA)

data.add_tags(tag_bicycle)
data.add_tags([tag_car, tag_truck])
```

***

## remove\_tags

```python
remove_tags(
   tags: (Tag|list[Tag])
)
```

**Description**

Remove some tags from an object (can be used on Data/Asset/DatasetVersion/Dataset/Model/ModelVersion)

You can give a [Tag](tag) or a list of [Tag](tag).

**Examples**

```python
data.remove_tags(tag_bicycle)
data.remove_tags([tag_car, tag_truck])
```

***

## list\_users

```python
list_users()
```

**Description**

List all users of this resource

**Examples**

```python
resource.list_users()
```

**Returns**

list of (User) objects

***

## add\_user

```python
add_user(
   user: User, role: (str|None) = None
)
```

**Description**

Add given user to this resource, with given role.
If user is UNPRIVILEGED on Organization, then its role will be forced to LABELER.
If role is None, user will be assigned configured role on Organization, or if not configured, USER.

:warning: **DANGER ZONE**: This method will create access for a user. Role depends on type of resource you're adding the user.

**Examples**

```python
user = client.find_user("foo")
resource.add_user(user, "ADMIN")
```

***

## get\_tags

```python
get_tags()
```

**Description**

Retrieve the tags of your deployment.

**Examples**

```python
tags = deployment.get_tags()
assert tags[0].name == "cool"
```

**Returns**

A list of [Tag](tag) objects

***

## retrieve\_information

```python
retrieve_information()
```

**Description**

Retrieve some information about this deployment from service.

**Examples**

```python
my_deployment.retrieve_information()
```

**Returns**

A dict with information about this deployment

***

## update

```python
update(
   name: (str|None) = None, target_datalake: (Datalake|None) = None,
   min_threshold: (float|None) = None, sample_rate: (float|None) = None
)
```

**Description**

Update this deployment with a new name, another target datalake or a minimum threshold

**Examples**

```python
a_tag.update(name="new name", min_threshold=0.4)
```

**Arguments**

* *name* (str, optional) : New name of the deployment

* *target\_datalake* (Datalake, optional) : Datalake where data will be uploaded on new prediction

* *min\_threshold* (float, optional) : Minimum confidence threshold.
  Serving will filter detection boxes or masks that have a detection score lower than this threshold

* *sample\_rate* (float, optional) : If less than 1, monitoring service will not send all images to platform,
  but will still compute metrics.

***

## delete

```python
delete(
   force_delete: bool = False
)
```

**Description**

***

## set\_model

```python
set_model(
   model_version: ModelVersion
)
```

**Description**

Set the model version to use for this deployment

**Examples**

```python
model_version = client.get_model("my-model").get_version("latest")
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.set_model(model_version)
```

**Arguments**

* *model\_version* [ModelVersion](modelversion) : a [ModelVersion](modelversion) to use

***

## get\_model\_version

```python
get_model_version()
```

**Description**

Retrieve currently used model version

**Examples**

```python
model_version = deployment.get_model_version()
```

**Returns**

A [ModelVersion](modelversion) object

***

## set\_shadow\_model

```python
set_shadow_model(
   shadow_model_version: ModelVersion
)
```

**Description**

Set the shadow model version to use for this deployment

**Examples**

```python
shadow_model_version = client.get_model("my-model").get_version("latest")
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.set_shadow_model(shadow_model_version)
```

**Arguments**

* *shadow\_model\_version* [ModelVersion](modelversion) : a [ModelVersion](modelversion) to use

***

## get\_shadow\_model

```python
get_shadow_model()
```

**Description**

Retrieve currently used shadow model version

**Examples**

```python
shadow_model = deployment.get_shadow_model()
```

**Returns**

A [ModelVersion](modelversion) object

***

## list\_labels

```python
list_labels()
```

**Description**

Get all labels of a Deployment.

It will retrieve a list of label objects.

Labels are created when [Deployment](deployment) is created, they cannot be updated or deleted.

**Examples**

```python
labels = deployment.list_labels()
assert labels[0].name == "person"
```

**Returns**

List of [Label](label)

***

## predict

```python
predict(
   file_path: (str|Path), tags: (str|Tag|list[Tag|str]|None) = None,
   source: (str|DataSource|None) = None, metadata: (dict|None) = None,
   monitor: bool = True, upload_dir: (str|None) = None,
   custom_metadata: (dict|None) = None, postprocess: bool = True
)
```

**Description**

Run a prediction on our Serving platform

**Examples**

```python
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.predict('image_420.png', tags=["gonna", "give"], source="camera-1")
```

**Arguments**

* *file\_path* (str or Path) : path to the image to predict.

* *tags* (str, [Tag](tag), list\[str | Tag], optional) : a list of tag to add to the data that will be created on the platform.

* *source* (str or DataSource, optional) : a source to attach to the data that will be created on the platform.

* *metadata* (dict, optional) : metadata to attach to the data that will be created on the platform.

* *monitor* (bool, optional) : if True, will send prediction on Picsellia and our monitoring service. Defaults to True.

* *upload\_dir* (str, optional) : This parameter can only be used with private object-storages. Specify this parameter to prefix the object name of the data. Filename will still contain a generated uuid4

* *custom\_metadata* (dict, optional) : custom\_metadata to attach to the data that will be created on the platform.

**Returns**

A (dict) with information of the prediction

***

## predict\_bytes

```python
predict_bytes(
   filename: str, raw_image: bytes, tags: (str|Tag|list[Tag|str]|None) = None,
   source: (str|DataSource|None) = None, metadata: (dict|None) = None,
   monitor: bool = True, upload_dir: (str|None) = None,
   custom_metadata: (dict|None) = None, postprocess: bool = True
)
```

**Description**

Run a prediction on our Serving platform with bytes of an image

**Examples**

```python
deployment = client.get_deployment(
    name="awesome-deploy"
)
filename = "frame.png"
with open(filename, 'rb') as img:
    img_bytes = img.read()
deployment.predict_bytes(filename, img_bytes, tags=["tag1", "tag2"], source="camera-1")
```

**Arguments**

* *filename* (str) : filename of the image.

* *raw\_image* (bytes) : bytes of the image to predict.

* *tags* (str, [Tag](tag), list\[str | Tag], optional) : a list of tag to add to the data that will be created on the platform.

* *source* (str or DataSource, optional) : a source to attach to the data that will be created on the platform.

* *metadata* (dict, optional) : metadata to attach to the data that will be created on the platform.

* *monitor* (bool, optional) : if True, will send prediction on Picsellia and our monitoring service. Defaults to True.

* *upload\_dir* (str, optional) : This parameter can only be used with private object-storages. Specify this parameter to prefix the object name of the data. Filename will still contain a generated uuid4

* *custom\_metadata* (dict, optional) : custom\_metadata to attach to the data that will be created on the platform.

**Returns**

A (dict) with information of the prediction

***

## predict\_cloud\_image

```python
predict_cloud_image(
   object_name: str, tags: (str|Tag|list[Tag|str]|None) = None,
   source: (str|DataSource|None) = None, metadata: (dict|None) = None,
   monitor: bool = True, custom_metadata: (dict|None) = None, postprocess: bool = True
)
```

**Description**

Run a prediction on our Serving platform, using object\_name of a cloud object stored in your object storage.
Your image MUST be stored in the storage used in the datalake linked to this deployment (the target datalake)
If your image is already a data in your target datalake, it MUST NOT have been processed by this deployment,
also, in this case, given source and metadata won't be used.

**Examples**

```python
deployment = client.get_deployment(
    name="awesome-deploy"
)
object_name = "directory/s3/object-name.jpeg"
deployment.predict_cloud_image(object_name, tags=["tag1", "tag2"], source="camera-1")
```

**Arguments**

* *object\_name* (str) : object name of the cloud image.

* *tags* (str, [Tag](tag), list\[str | Tag], optional) : a list of tag to add to the data that will be created on the platform.

* *source* (str or DataSource, optional) : a source to attach to the data that will be created on the platform.

* *metadata* (dict, optional) : metadata to attach to the data that will be created on the platform.

* *monitor* (bool, optional) : if True, will send prediction on Picsellia and our monitoring service. Defaults to True.

* *custom\_metadata* (dict, optional) : custom\_metadata to attach to the data that will be created on the platform.

**Returns**

A (dict) with information of the prediction

***

## predict\_data

```python
predict_data(
   data: Data, tags: (str|Tag|list[Tag|str]|None) = None, monitor: bool = True,
   postprocess: bool = True
)
```

**Description**

Run a prediction on our Serving platform, using data.
Your data must already be stored in the datalake used by the deployment (the target datalake).
If there already is a prediction in this deployment linked to this data, it will be dismissed.

Specified tags will be added to the ones already existing on the Data.

**Examples**

```python
datalake = client.get_datalake(name="target-datalake")
data = datalake.list_data(limit=1)[0]
deployment = client.get_deployment(name="awesome-deploy")
deployment.predict_data(data, tags=["tag1", "tag2"], monitor=False)
```

**Arguments**

* *data* [Data](data) : object that you want to predict on.

* *tags* (str, [Tag](tag), list\[str | Tag], optional) : a list of tag to add to the data

* *monitor* (bool, optional) : if True, will send prediction on Picsellia and our monitoring service. Defaults to True.

**Returns**

A (dict) with information of the prediction

***

## predict\_shadow

```python
predict_shadow(
   predicted_asset: PredictedAsset, monitor: bool = True
)
```

**Description**

Add a shadow prediction on a predicted asset.
It will call our Serving platform, returning predictions coming from shadow model.
If monitor is true, it will go to our monitoring service, then it will be added on the platform.

**Examples**

```python
deployment = client.get_deployment(name="awesome-deploy")
predicted_asset = deployment.list_predicted_assets(limit=1)[0]
deployment.predict_shadow(predicted_asset, monitor=False)
```

**Arguments**

* *predicted\_asset* [PredictedAsset](predictedasset) : shadow model will predict on this asset.

* *monitor* (bool, optional) : if True, will send prediction on Picsellia and our monitoring service. Defaults to True.

**Returns**

A (dict) with prediction shapes

***

## setup\_feedback\_loop

```python
setup_feedback_loop(
   dataset_version: (DatasetVersion|None) = None
)
```

**Description**

Set up the Feedback Loop for a Deployment.
You can specify one Dataset Version to attach to it or use the
attach\_dataset\_to\_feedback\_loop() afterward,so you can add multiple ones.
This is a great option to increase your training set with quality data.

**Examples**

```python
dataset_version = client.get_dataset("my-dataset").get_version("latest")
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.setup_feedback_loop(dataset_version)
```

**Arguments**

* *dataset\_version* (DatasetVersion, optional) : This parameter is deprecated. Use attach\_dataset\_to\_feedback\_loop() instead.

***

## attach\_dataset\_version\_to\_feedback\_loop

```python
attach_dataset_version_to_feedback_loop(
   dataset_version: DatasetVersion
)
```

**Description**

Attach a Dataset Version to a previously configured feedback-loop.

**Examples**

```python
dataset_versions = client.get_dataset("my-dataset").list_versions()
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.setup_feedback_loop()
for dataset_version in dataset_versions:
    deployment.attach_dataset_version_to_feedback_loop(dataset_version)
```

**Arguments**

* *dataset\_version* [DatasetVersion](datasetversion) : a [DatasetVersion](datasetversion) to attach

***

## detach\_dataset\_version\_from\_feedback\_loop

```python
detach_dataset_version_from_feedback_loop(
   dataset_version: DatasetVersion
)
```

**Description**

Detach a Dataset Version from a previously configured feedback-loop.

**Examples**

```python
dataset_versions = client.get_dataset("my-dataset").list_versions()
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.setup_feedback_loop()
for dataset_version in dataset_versions:
    deployment.attach_dataset_version_to_feedback_loop(dataset_version)
deployment.detach_dataset_version_from_feedback_loop(dataset_versions[0])
```

**Arguments**

* *dataset\_version* [DatasetVersion](datasetversion) : a [DatasetVersion](datasetversion) to detach

***

## list\_feedback\_loop\_datasets

```python
list_feedback_loop_datasets()
```

**Description**

List the Dataset Versions attached to the feedback-loop

**Examples**

```python
deployment = client.get_deployment(
    name="awesome-deploy"
)
dataset_versions = deployment.list_feedback_loop_datasets()
```

**Returns**

A list of [DatasetVersion](datasetversion)

***

## toggle\_feedback\_loop

```python
toggle_feedback_loop(
   active: bool
)
```

**Description**

Toggle feedback loop for this deployment

**Examples**

```python
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.toggle_feedback_loop(
    True
)
```

**Arguments**

* *active* (bool) : (des)activate feedback loop

***

## set\_training\_data

```python
set_training_data(
   dataset_version: DatasetVersion
)
```

**Description**

This will give the training data reference to the deployment,
so we can compute metrics based on this training data distribution in our Monitoring service

**Examples**

```python
dataset_version = client.get_dataset("my-dataset").get_version("latest")
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.set_training_data(dataset_version)
```

**Arguments**

* *dataset\_version* [DatasetVersion](datasetversion) : a [DatasetVersion](datasetversion)

***

## check\_training\_data\_metrics\_status

```python
check_training_data_metrics_status()
```

**Description**

Refresh the status of the metrics compute over the training data distribution.
Set up can take some time, so you can check current state with this method.

**Examples**

```python
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.check_training_data_metrics_status()
```

**Returns**

A string with the status of the metrics compute over the training data distribution

***

## disable\_training\_data\_reference

```python
disable_training_data_reference()
```

**Description**

Disable the reference to the training data in this Deployment.
This means that you will not be able to see supervised metrics from the dashboard anymore.

**Examples**

```python
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.disable_training_data_reference()
```

***

## setup\_continuous\_training

```python
setup_continuous_training(
   project: Project, dataset_version: (DatasetVersion|None) = None,
   model_version: (ModelVersion|None) = None,
   trigger: (str|ContinuousTrainingTrigger) = None, threshold: (int|None) = None,
   experiment_parameters: (dict|None) = None, scan_config: (dict|None) = None
)
```

**Description**

Initialize and activate the continuous training features of picsellia. 🥑
A Training will be triggered using the attached dataset versions
whenever your Deployment pipeline hit the trigger.
You can call attach\_dataset\_version\_to\_continuous\_training() method afterward.
You can launch a continuous training via Experiment with parameter `experiment_parameters`
You cannot launch a continuous training via Scan at the moment

**Examples**

We want to set up a continuous training pipeline that will be trigger
every 150 new predictions reviewed by your team.
We will use the same training parameters as those used when building the first model.

```python
deployment = client.get_deployment("awesome-deploy")
project = client.get_project(name="my-project")
dataset_version = project.get_dataset(name="my-dataset").get_version("latest")
model_version = client.get_model(name="my-model").get_version(0)
experiment = model_version.get_source_experiment()
experiment_parameters = experiment.get_log('parameters')
deployment.setup_continuous_training(
    project, threshold=150, experiment_parameters=experiment_parameters
)
deployment.attach_continuous
```

**Arguments**

* *project* [Project](project) : The project that will host your pipeline.

* *dataset\_version* (DatasetVersion, deprecated) : This parameter is deprecated and is not used anymore.

* *model\_version* (ModelVersion, deprecated) : This parameter is deprecated and is not used anymore.

* *threshold* (int) : Number of images that need to be review to trigger the training.

* *trigger* (ContinuousTrainingTrigger) : Type of trigger to use when there is enough reviews.

* *experiment\_parameters* (dict, optional) :  Training parameters. Defaults to None.

***

## attach\_dataset\_version\_to\_continuous\_training

```python
attach_dataset_version_to_continuous_training(
   alias: str, dataset_version: DatasetVersion
)
```

**Description**

Attach a Dataset Version to a previously configured continuous training.

**Examples**

```python
dataset_versions = client.get_dataset("my-dataset").list_versions()
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.setup_continuous_training(...)
aliases = ["train", "test", "eval"]
for i, dataset_version in enumerate(dataset_versions):
    deployment.attach_dataset_version_to_continuous_training(aliases[i], dataset_version)
```

**Arguments**

* *alias* (str) : Alias of attached dataset

* *dataset\_version* [DatasetVersion](datasetversion) : A dataset version to attach to the Continuous Training.

***

## detach\_dataset\_version\_from\_continuous\_training

```python
detach_dataset_version_from_continuous_training(
   dataset_version: DatasetVersion
)
```

**Description**

Detach a Dataset Versions to a previously configured continuous training.

**Examples**

```python
dataset_versions = client.get_dataset("my-dataset").list_versions()
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.setup_continuous_training()
for dataset_version in dataset_versions:
    deployment.attach_dataset_version_to_continuous_training(dataset_version)
deployment.detach_dataset_version_from_continuous_training(dataset_versions[0])
```

**Arguments**

* *dataset\_version* [DatasetVersion](datasetversion) : a [DatasetVersion](datasetversion) to detach from Continuous Training settings

***

## toggle\_continuous\_training

```python
toggle_continuous_training(
   active: bool
)
```

**Description**

Toggle continuous training for this deployment

**Examples**

```python
deployment = client.get_deployment("awesome-deploy")
deployment.toggle_continuous_training(active=False)
```

**Arguments**

* *active* (bool) : (des)activate continuous training

***

## setup\_continuous\_deployment

```python
setup_continuous_deployment(
   policy: (ContinuousDeploymentPolicy|str)
)
```

**Description**

Set up the continuous deployment for this pipeline

**Examples**

```python
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.setup_continuous_deployment(ContinuousDeploymentPolicy.DEPLOY_MANUAL)
```

**Arguments**

* *policy* (ContinuousDeploymentPolicy) : policy to use

***

## toggle\_continuous\_deployment

```python
toggle_continuous_deployment(
   active: bool
)
```

**Description**

Toggle continuous deployment for this deployment

**Examples**

```python
deployment = client.get_deployment(
    name="awesome-deploy"
)
deployment.toggle_continuous_deployment(
    dataset
)
```

**Arguments**

* *active* (bool) : (des)activate continuous deployment

***

## get\_stats

```python
get_stats(
   service: ServiceMetrics, model_version: (ModelVersion|None) = None,
   from_timestamp: (float|None) = None, to_timestamp: (float|None) = None,
   since: (int|None) = None, includes: (list[str]|None) = None,
   excludes: (list[str]|None) = None, tags: (list[str]|None) = None
)
```

**Description**

Retrieve stats of this deployment stored in Picsellia environment.

Mandatory param is "service" an enum of type ServiceMetrics. Values possibles are :
PREDICTIONS\_OUTLYING\_SCORE
PREDICTIONS\_DATA
REVIEWS\_OBJECT\_DETECTION\_STATS
REVIEWS\_CLASSIFICATION\_STATS
REVIEWS\_LABEL\_DISTRIBUTION\_STATS

AGGREGATED\_LABEL\_DISTRIBUTION
AGGREGATED\_OBJECT\_DETECTION\_STATS
AGGREGATED\_PREDICTIONS\_DATA
AGGREGATED\_DRIFTING\_PREDICTIONS

For aggregation, computation may not have been done by the past.
You will need to force computation of these aggregations and retrieve them again.

**Examples**

```python
my_deployment.get_stats(ServiceMetrics.PREDICTIONS_DATA)
my_deployment.get_stats(ServiceMetrics.AGGREGATED_DRIFTING_PREDICTIONS, since=3600)
my_deployment.get_stats(ServiceMetrics.AGGREGATED_LABEL_DISTRIBUTION, model_version=my_model)
```

**Arguments**

* *service* (str) : service queried

* *model\_version* (ModelVersion, optional) : Model that shall be used when retrieving data.
  Defaults to None.

* *from\_timestamp* (float, optional) : System will only retrieve prediction data after this timestamp.
  Defaults to None.

* *to\_timestamp* (float, optional) : System will only retrieve prediction data before this timestamp.
  Defaults to None.

* *since* (int, optional) : System will only retrieve prediction data that are in the last seconds.
  Defaults to None.

* *includes* (list\[str], optional) : Research will include these ids and excludes others.
  Defaults to None.

* *excludes* (list\[str], optional) : Research will exclude these ids.
  Defaults to None.

* *tags* (list\[str], optional) : Research will be done filtering by tags.
  Defaults to None.

**Returns**

A dict with queried statistics about the service you asked

***

## monitor

```python
monitor(
   image_path: (str|Path), latency: float, height: int, width: int,
   prediction: PredictionFormat, source: (str|None) = None,
   tags: (list[str]|None) = None, timestamp: (float|None) = None,
   model_version: (ModelVersion|None) = None,
   shadow_model_version: (ModelVersion|None) = None,
   shadow_latency: (float|None) = None,
   shadow_raw_predictions: (PredictionFormat|None) = None,
   shadow_prediction: (PredictionFormat|None) = None,
   content_type: (SupportedContentType|str|None) = None, metadata: (dict|None) = None,
   upload_dir: (str|None) = None, custom_metadata: (dict|None) = None,
   sample: (bool|None) = None, custom_metrics: (dict|None) = None
)
```

**Description**

Send a prediction for this deployment on our monitoring service.

:warning: Signature of this method has been recently changed and can break some methods :

* model\_version and shadow\_model\_version are not used anymore : system will use what's currently being monitored in this deployment
* shadow\_raw\_predictions has been renamed to shadow\_prediction

**Arguments**

* *image\_path* (str or Path) : image path

* *latency* (float) : latency used by model to compute your prediction

* *height* (int) : height of image

* *width* (int) : width of image

* *prediction* (PredictionFormat) : data of your prediction, can be a Classification, a Segmentation or an ObjectDetection Format.
  DetectionPredictionFormat, ClassificationPredictionFormat and SegmentationPredictionFormat:
  detection\_classes (list\[int]): list of classes
  detection\_scores (list\[float]): list of scores of predictions
  DetectionPredictionFormat and SegmentationPredictionFormat:
  detection\_boxes (list\[list\[int]]): list of bboxes representing rectangles of your shapes. bboxes are formatted as
  \[top, left, bottom, right]
  SegmentationPredictionFormat:
  detection\_masks  list\[list\[list\[int]]]): list of polygon shapes, each element corresponds to a distinct shape and is a list of the coordinates
  one polygon will look like \[\[x1, y1], \[x2, y2], \[x3, y3], \[x4, y4], ...]
  LinePredictionFormat:
  lines (list\[list\[int]]): list of line shapes, each element corresponds to a distinct shape and is a list of the coordinates
  one line will look like \[\[x1, y1], \[x2, y2], \[x3, y3], \[x4, y4], ...]
  PointPredictionFormat:
  points (list\[list\[int]]): list of point shapes, each element corresponds to a distinct point and is the coordinates
  a point will look like \[x, y]

* *source* (str, optional) : [Data](data) will have this source in Picsellia. Defaults to None.

* *tags* (list\[str], optional) : tags that can give some metadata to your prediction. Defaults to None.

* *timestamp* (float, optional) : timestamp of your prediction. Defaults to timestamp of monitoring service on reception.

* *shadow\_latency* (float, optional) : latency used by shadow model to compute prediction

* *shadow\_prediction* (PredictionFormat, optional) : data of your prediction made by shadow model.

* *content\_type* (str, optional) : if given, we won't try to infer content type with mimetype library

* *metadata* (dict, optional) : [Data](data) will have this metadata in Picsellia. Defaults to None.

* *upload\_dir* (str, optional) : This parameter can only be used with private object-storages. Specify this parameter to prefix the object name of the data. Filename will still contain a generated uuid4

* *custom\_metadata* (dict, optional) : [Data](data) will have this custom\_metadata in Picsellia. Defaults to None.

* *sample* (bool, optional) : control sample policy by using this field.
  If True, the Data and the Prediction will be stored under the Deployment (no matter the sample\_rate).
  If False, the Data and the Prediction won't be stored, monitoring metrics WILL still be computed.
  If unset, we will store the Data and Prediction according to the sample\_rate (if existing).

* *custom\_metrics* (dict, optional) : [PredictedAsset](predictedasset) will have this custom\_metrics in Picsellia. Defaults to None.

**Returns**

a dict of data returned by our monitoring service

***

## monitor\_bytes

```python
monitor_bytes(
   raw_image: bytes, content_type: (SupportedContentType|str), filename: str,
   latency: float, height: int, width: int, prediction: PredictionFormat,
   source: (str|None) = None, tags: (list[str]|None) = None,
   timestamp: (float|None) = None, shadow_latency: (float|None) = None,
   shadow_prediction: (PredictionFormat|None) = None, metadata: (dict|None) = None,
   upload_dir: (str|None) = None, custom_metadata: (dict|None) = None,
   sample: (bool|None) = None, custom_metrics: (dict|None) = None
)
```

**Description**

Send a prediction for this deployment on our monitoring service.
You can use this method instead of monitor() if you have a bytes image and not an image file.
We will convert it into base 64 as utf8 string and send it to the monitoring service.

**Arguments**

* *raw\_image* (bytes) : raw image in bytes

* *content\_type* (SupportedContentType or str) : content type of image, only 'image/jpeg' or 'image/png' currently supported

* *filename* (str) : filename of image

* *latency* (float) : latency used by model to compute your prediction

* *height* (int) : height of image

* *width* (int) : width of image

* *prediction* (PredictionFormat) : data of your prediction, can be a Classification, a Segmentation or an ObjectDetection Format.
  DetectionPredictionFormat, ClassificationPredictionFormat and SegmentationPredictionFormat:
  detection\_classes (list\[int]): list of classes
  detection\_scores (list\[float]): list of scores of predictions
  DetectionPredictionFormat:
  detection\_boxes (list\[list\[int]]): list of bboxes representing rectangles of your shapes. bboxes are formatted as
  \[top, left, bottom, right]
  SegmentationPredictionFormat:
  detection\_masks (list\[list\[int]]): list of polygons of your shapes. each polygon is a list of points with coordinates flattened
  \[x1, y1, x2, y2, x3, y3, x4, y4, ..]

* *source* (str, optional) : source that can give some metadata to your prediction. Defaults to None.

* *tags* (list\[str], optional) : tags that can give some metadata to your prediction. Defaults to None.

* *timestamp* (float, optional) : timestamp of your prediction. Defaults to timestamp of monitoring service on reception.

* *shadow\_latency* (float, optional) : latency used by shadow model to compute prediction

* *shadow\_prediction* (PredictionFormat, optional) : data of your prediction made by shadow model.

* *metadata* (dict, optional) : [Data](data) will have this metadata in Picsellia. Defaults to None.

* *upload\_dir* (str, optional) : This parameter can only be used with private object-storages. Specify this parameter to prefix the object name of the data. Filename will still contain a generated uuid4

* *custom\_metadata* (dict, optional) : [Data](data) will have this custom\_metadata in Picsellia. Defaults to None.

* *sample* (bool, optional) : control sample policy by using this field.
  If True, the Data and the Prediction will be stored under the Deployment (no matter the sample\_rate).
  If False, the Data and the Prediction won't be stored, monitoring metrics WILL still be computed.
  If unset, we will store the Data and Prediction according to the sample\_rate (if existing).

* *custom\_metrics* (dict, optional) : [PredictedAsset](predictedasset) will have this custom\_metrics in Picsellia. Defaults to None.

**Returns**

a dict of data returned by our monitoring service

***

## monitor\_cloud\_image

```python
monitor_cloud_image(
   object_name: str, latency: float, height: int, width: int,
   prediction: PredictionFormat, content_type: (SupportedContentType|str),
   source: (str|None) = None, tags: (list[str]|None) = None,
   timestamp: (float|None) = None, shadow_latency: (float|None) = None,
   shadow_prediction: (PredictionFormat|None) = None, metadata: (dict|None) = None,
   custom_metadata: (dict|None) = None, sample: (bool|None) = None,
   custom_metrics: (dict|None) = None
)
```

**Description**

Monitor an image on our monitoring platform, using object\_name of a cloud object stored in your object storage.

**Arguments**

* *object\_name* (str) : object name of the cloud image.

* *latency* (float) : latency used by model to compute your prediction

* *height* (int) : height of image

* *width* (int) : width of image

* *prediction* (PredictionFormat) : data of your prediction, can be a Classification, a Segmentation or an ObjectDetection Format.
  DetectionPredictionFormat, ClassificationPredictionFormat and SegmentationPredictionFormat:
  detection\_classes (list\[int]): list of classes
  detection\_scores (list\[float]): list of scores of predictions
  DetectionPredictionFormat and SegmentationPredictionFormat:
  detection\_boxes (list\[list\[int]]): list of bboxes representing rectangles of your shapes. bboxes are formatted as
  \[top, left, bottom, right]
  SegmentationPredictionFormat:
  detection\_masks (list\[list\[int]]): list of polygons of your shapes. each polygon is a list of points with coordinates flattened
  \[x1, y1, x2, y2, x3, y3, x4, y4, ..]

* *source* (str, optional) : [Data](data) will have this source in Picsellia. Defaults to None.

* *tags* (list\[str], optional) : tags that can give some metadata to your prediction. Defaults to None.

* *timestamp* (float, optional) : timestamp of your prediction. Defaults to timestamp of monitoring service on reception.

* *shadow\_latency* (float, optional) : latency used by shadow model to compute prediction

* *shadow\_prediction* (PredictionFormat, optional) : data of your prediction made by shadow model.

* *content\_type* (str, optional) : if given, we won't try to infer content type with mimetype library

* *metadata* (dict, optional) : [Data](data) will have this metadata in Picsellia. Defaults to None.

* *custom\_metadata* (dict, optional) : [Data](data) will have this custom\_metadata in Picsellia. Defaults to None.

* *sample* (bool, optional) : control sample policy by using this field.
  If True, the Data and the Prediction will be stored under the Deployment (no matter the sample\_rate).
  If False, the Data and the Prediction won't be stored, monitoring metrics WILL still be computed.
  If unset, we will store the Data and Prediction according to the sample\_rate (if existing).

* *custom\_metrics* (dict, optional) : [PredictedAsset](predictedasset) will have this custom\_metrics in Picsellia. Defaults to None.

**Returns**

a dict of data returned by our monitoring service

***

## monitor\_data

```python
monitor_data(
   data: Data, latency: float, height: int, width: int, prediction: PredictionFormat,
   tags: (list[str]|None) = None, timestamp: (float|None) = None,
   shadow_latency: (float|None) = None,
   shadow_prediction: (PredictionFormat|None) = None, sample: (bool|None) = None,
   custom_metrics: (dict|None) = None
)
```

**Description**

Monitor an image on our monitoring platform
Your data must already be stored in the datalake used by the deployment (the target datalake).
If there already is a prediction in this deployment linked to this data, it will be dismissed.

**Arguments**

* *data* [Data](data) : data to monitor

* *latency* (float) : latency used by model to compute your prediction

* *height* (int) : height of image

* *width* (int) : width of image

* *prediction* (PredictionFormat) : data of your prediction, can be a Classification, a Segmentation or an ObjectDetection Format.
  DetectionPredictionFormat, ClassificationPredictionFormat and SegmentationPredictionFormat:
  detection\_classes (list\[int]): list of classes
  detection\_scores (list\[float]): list of scores of predictions
  DetectionPredictionFormat and SegmentationPredictionFormat:
  detection\_boxes (list\[list\[int]]): list of bboxes representing rectangles of your shapes. bboxes are formatted as
  \[top, left, bottom, right]
  SegmentationPredictionFormat:
  detection\_masks (list\[list\[int]]): list of polygons of your shapes. each polygon is a list of points with coordinates flattened
  \[x1, y1, x2, y2, x3, y3, x4, y4, ..]

* *tags* (list\[str], optional) : tags that can give some metadata to your prediction. Defaults to None.

* *timestamp* (float, optional) : timestamp of your prediction. Defaults to timestamp of monitoring service on reception.

* *shadow\_latency* (float, optional) : latency used by shadow model to compute prediction

* *shadow\_prediction* (PredictionFormat, optional) : data of your prediction made by shadow model.

* *sample* (bool, optional) : control sample policy by using this field.
  If True, the Data and the Prediction will be stored under the Deployment (no matter the sample\_rate).
  If False, the Data and the Prediction won't be stored, monitoring metrics WILL still be computed.
  If unset, we will store the Data and Prediction according to the sample\_rate (if existing).

* *custom\_metrics* (dict, optional) : [PredictedAsset](predictedasset) will have this custom\_metrics in Picsellia. Defaults to None.

**Returns**

a dict of data returned by our monitoring service

***

## monitor\_shadow

```python
monitor_shadow(
   predicted_asset: PredictedAsset, shadow_latency: float,
   shadow_prediction: PredictionFormat
)
```

**Description**

Add a shadow prediction on an existing PredictedAsset.
You can call monitor\_shadow\_from\_oracle\_prediction\_id() if you only have oracle\_prediction\_id

**Arguments**

* *predicted\_asset* [PredictedAsset](predictedasset) : asset already processed on which to add shadow\_prediction

* *shadow\_latency* (float) : latency used by shadow model to compute prediction

* *shadow\_prediction* (PredictionFormat) : data of your prediction made by shadow model

***

## monitor\_shadow\_from\_oracle\_prediction\_id

```python
monitor_shadow_from_oracle_prediction_id(
   oracle_prediction_id: (str|UUID), shadow_latency: float,
   shadow_prediction: PredictionFormat
)
```

**Description**

Add a shadow prediction on an existing PredictedAsset, from the oracle\_prediction\_id

**Arguments**

* *oracle\_prediction\_id* (str or UUID) : oracle\_prediction\_id that was returned on monitor()

* *shadow\_latency* (float) : latency used by shadow model to compute prediction

* *shadow\_prediction* (PredictionFormat) : data of your prediction made by shadow model

***

## find\_predicted\_asset

```python
find_predicted_asset(
   id: (str|UUID|None) = None, oracle_prediction_id: (str|UUID|None) = None,
   object_name: (str|None) = None, filename: (str|None) = None,
   data_id: (str|UUID|None) = None
)
```

**Description**

Find a PredictedAsset of this deployment.

**Examples**

```python
oracle_prediction_id = deployment.monitor(path, latency, height, width, prediction_data)["id"]
predicted_asset = deployment.find_predicted_asset(oracle_prediction_id=oracle_prediction_id)
deployment.monitor_shadow(predicted_asset, shadow_latency, shadow_prediction_data)
```

**Arguments**

* *id* (UUID, optional) : id of PredictedAsset to fetch. Defaults to None.

* *oracle\_prediction\_id* (UUID, optional) : id of the prediction in our monitoring system. Defaults to None.

* *filename* (str, optional) : filename of the data. Defaults to None.

* *object\_name* (str, optional) : object\_name of the data. Defaults to None.

* *data\_id* (UUID, optional) : id of the data related to this PredictedAsset. Defaults to None.

**Raises**

If no asset match the query, it will raise a NotFoundError.
In some case, it can raise an InvalidQueryError,
it might be because the platform stores 2 assets matching this query (for example if filename is duplicated)

**Returns**

The [PredictedAsset](predictedasset) found

***

## list\_predicted\_assets

```python
list_predicted_assets(
   limit: (int|None) = None, offset: (int|None) = None, page_size: (int|None) = None,
   order_by: (list[str]|None) = None, q: (str|None) = None,
   assignment_status: (str|None) = None, assignment_step_id: (UUID|None) = None,
   assignment_user_id: (str|UUID|None) = None, custom_metadata: (dict|None) = None
)
```

**Description**

List [PredictedAsset](predictedasset) of this [Deployment](deployment)

**Examples**

```python
assets = deployment.list_predicted_assets()
```

**Arguments**

* *limit* (int, optional) : the number of assets that will be retrieved

* *offset* (int, optional) : from where to start accessing the assets. you will retrieve offset:offset+limit assets from the whole list.

* *page\_size* (int, optional) : deprecated.

* *order\_by* (str, optional) : what property to sort on. Defaults to descending created\_at.

* *q* (str, optional) : a query using the Picsellia Query Language. Defaults to None

* *assignment\_status* (str, optional) : only with campaigns. It's the desired status for the last assignments linked to your [PredictedAsset](predictedasset).

* *assignment\_step\_id* (UUID, optional) : only with campaigns. It's the desired step of the assignment you want to retrieve.

* *assignment\_user\_id* (UUID, optional) : only with Campaigns. It's the desired user assigned to the assignments you want to retrieve.

* *custom\_metadata*  : (dict, optional): filter based on the custom\_metadata linked to the asset's Data. Defaults to None

**Returns**

A [MultiAsset](asset#MultiAsset) object that wraps some [Asset](asset) that you can manipulate.

***

## list\_workers

```python
list_workers()
```

**Description**

List all workers of this deployment

**Examples**

```python
deployment.list_workers()
```

**Returns**

List of [Worker](worker) objects

***

## create\_campaign

```python
create_campaign(
   description: (str|None) = None, instructions_file_path: (str|None) = None,
   instructions_text: (str|None) = None, end_date: (date|None) = None,
   auto_add_new_assets: (bool|None) = False,
   auto_close_on_completion: (bool|None) = False
)
```

**Description**

Create campaign on a deployment.

**Examples**

```python
foo_deployment.create_campaign()
```

**Arguments**

* *description* (str, optional) : Description of the campaign. Defaults to None.

* *instructions\_file\_path* (str, optional) : Instructions file path. Defaults to None.

* *instructions\_text* (str, optional) : Instructions text. Defaults to None.

* *end\_date* (date, optional) : End date of the campaign. Defaults to None.

* *auto\_add\_new\_assets* (bool, optional) : If true, new assets of this deployment will be added as a task
  in the campaign. Defaults to False.

* *auto\_close\_on\_completion* (bool, optional) : If true, campaign will be close when all tasks will be done.
  Defaults to False.

**Returns**

A (ReviewCampaign) object

***

## get\_campaign

```python
get_campaign()
```

**Description**

Get campaign of a dataset version.

**Examples**

```python
foo_deployment.get_campaign()
```

**Returns**

A (ReviewCampaign) object

***