# Batch Assignment

## Overview

The Batch Assignment Plugin automatically assigns assets to batches based on configurable rules such as batch size, assignment strategy, and naming conventions. It enables users to efficiently organize large datasets into manageable groups, streamlining workflows for labeling, review, and processing stages.

<table data-card-size="large" data-view="cards" data-full-width="false"><thead><tr><th align="center"></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td align="center">Batch Assignment</td><td data-object-fit="contain"><a href="https://angohub-docs-assets.s3.eu-central-1.amazonaws.com/plugin-icons-banners/batch-assignment.png">https://angohub-docs-assets.s3.eu-central-1.amazonaws.com/plugin-icons-banners/batch-assignment.png</a></td></tr><tr><td align="center">Custom Batch Assignment</td><td data-object-fit="contain"><a href="https://angohub-docs-assets.s3.eu-central-1.amazonaws.com/plugin-icons-banners/batch-assignment.png">https://angohub-docs-assets.s3.eu-central-1.amazonaws.com/plugin-icons-banners/batch-assignment.png</a></td></tr></tbody></table>

## Plugin Functionality

The Batch Assignment Plugin processes project assets and assigns them to batches according to the provided configuration.

* Creates batches and assigns assets to batches automatically based on the provided configuration.
* Sorts assets using the specified field before assignment to ensure deterministic and reproducible batch structures across multiple runs.
* Generates batch names dynamically using the configured prefix, separator, and indexing logic, allowing flexible and standardized naming conventions.
* Preserves existing batch assignments and appends newly generated batch names when enabled, allowing incremental updates without losing prior groupings.
* Enables efficient organization and management of large datasets by structuring assets into clearly defined and scalable batches.

{% hint style="info" %}
The plugin will process all assets in your project.

Currently, there is no way to only select specific assets as targets for the plugin.
{% endhint %}

This functionality helps maintain structured and scalable batch organization, especially for large annotation projects.

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FsCMP1AGEnH76YPoi8Fzo%2Fimage.png?alt=media&#x26;token=880d9d2d-9ef9-4bbe-8b44-493dccea2728" alt=""><figcaption></figcaption></figure>

### Example Configurations <a href="#supported-data-types" id="supported-data-types"></a>

***Configuration-1: Sequential Assignment***

```json
{
  "keep_existing_batches": false,
  "assignment_type": "sequential",
  "batch_size": 2,
  "sort_assets": "external_id",
  "batch_name_prefix": "Batch",
  "batch_name_seperator": "-",
  "batch_name_add_zeros": true
}
```

Output:

```
external_id_1 → Batch-01
external_id_2 → Batch-01
external_id_3 → Batch-02
external_id_4 → Batch-02
...
external_id_20 → Batch-10
```

***Configuration-2: Keep Available Batches***

```json
{
  "keep_existing_batches": true,
  "assignment_type": "sequential",
  "batch_size": 1,
  "sort_assets": "external_id",
  "batch_name_prefix": "Batch",
  "batch_name_seperator": "-",
  "batch_name_add_zeros": true
}
```

Output:

```
external_id_1 → Batch-01|Batch-01
external_id_2 → Batch-01|Batch-02
external_id_3 → Batch-02|Batch-03
external_id_4 → Batch-02|Batch-04
...
external_id_20 → Batch-10|Batch-20
```

***Configuration-3: Random Assignment***

```json
{
  "keep_existing_batches": false,
  "assignment_type": "random",
  "batch_size": 2,
  "sort_assets": "external_id",
  "batch_name_prefix": "Batch",
  "batch_name_seperator": "-",
  "batch_name_add_zeros": true
}
```

Output:

```
external_id_1 → Batch-06
external_id_2 → Batch-04
external_id_3 → Batch-08
external_id_4 → Batch-05
...
external_id_20 → Batch-04
```

***Configuration-4: Divide batches into sub-batches***

```json
{
  "keep_existing_batches": true,
  "assignment_type": "sequential",
  "batch_size": 2,
  "sort_assets": "batch",
  "batch_name_prefix": "Sub-Batch",
  "batch_name_seperator": "-",
  "batch_name_add_zeros": true
}
```

Output:

```
external_id_1 → Batch-1|Sub-Batch-01
external_id_2 → Batch-1|Sub-Batch-01
external_id_3 → Batch-1|Sub-Batch-02
external_id_4 → Batch-1|Sub-Batch-02
...
external_id_20 → Batch-1|Sub-Batch-10
```

### Supported Data Types <a href="#supported-data-types" id="supported-data-types"></a>

* Compatible with all data types available in AngoHub.

### Supported Annotation Tools <a href="#supported-annotation-tools" id="supported-annotation-tools"></a>

* Compatible with all annotation tools available in AngoHub.

## Plugin Configuration <a href="#plugin-configuration" id="plugin-configuration"></a>

You may vary a number of settings related to your export from the **Config JSON** field. Each option is detailed below:

```json
{
  "keep_existing_batches": true,
  "assignment_type": "sequential",
  "batch_size": 100,
  "sort_assets": "external_id",
  "batch_name_prefix": "Batch",
  "batch_name_seperator": "-",
  "batch_name_add_zeros": true
}
```

* **"keep\_existing\_batches":** Determines whether existing batch assignments are preserved when assigning new batches. When set to **true**, the new batch is appended to the asset’s current batch list. When set to **false**, the existing batch assignment is overwritten and only the new batch is kept.
  * Example:
    * <kbd>"keep\_existing\_batches": true</kbd>
    * <kbd>"keep\_existing\_batches": false</kbd>

* **"assignment\_type":** Determines how assets are distributed into batches.
  * Options:
    * <kbd>"sequential"</kbd>
    * <kbd>"random"</kbd>
  * Example:
    * <kbd>"assignment\_type": "sequential"</kbd>

* **"batch\_size":** Specifies the number of assets to include in each batch.
  * Example:
    * <kbd>"batch\_size": 100</kbd>&#x20;

* **"sort\_assets":** Defines the sorting method to apply before batching.
  * Options:
    * <kbd>"default"</kbd>
    * <kbd>"external\_id"</kbd>
    * <kbd>"asset\_id"</kbd>
    * <kbd>"batch"</kbd>
  * Example:&#x20;
    * <kbd>"sort\_assets": "external\_id"</kbd>

* **"batch\_name\_prefix":** Sets a prefix to include at the beginning of each batch name.
  * Example:
    * <kbd>"batch\_name\_prefix": "Batch"</kbd>

* **"batch\_name\_separator":** Defines the character or symbol used to separate the batch name prefix and number.
  * Example:
    * <kbd>"batch\_name\_separator": "-"</kbd>

* **"batch\_name\_add\_zeros":** Determines whether batch numbers should include leading zeros for consistent naming.
  * Example:
    * <kbd>"batch\_name\_add\_zeros": true</kbd>
    * <kbd>"batch\_name\_add\_zeros": false</kbd>
