# 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="/files/pCXXsRI4jv889wnxfKnD" 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
}
```

{% columns %}
{% column %}
**Before Execution:**

```
external_id_1 → N/A
external_id_2 → N/A
external_id_3 → N/A
external_id_4 → N/A
...
external_id_20 → N/A
```

{% endcolumn %}

{% column %}
**After Execution:**

```
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
```

{% endcolumn %}
{% endcolumns %}

***Configuration-2: Sequential Assignment with a Different Batch Size***

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

{% columns %}
{% column %}
**Before Execution:**

```
external_id_1 → N/A
external_id_2 → N/A
external_id_3 → N/A
external_id_4 → N/A
external_id_5 → N/A
external_id_6 → N/A
external_id_7 → N/A
...
external_id_20 → N/A
```

{% endcolumn %}

{% column %}
**After Execution:**

```
external_id_1 → Batch-01
external_id_2 → Batch-01
external_id_3 → Batch-01
external_id_4 → Batch-02
external_id_5 → Batch-02
external_id_6 → Batch-02
external_id_7 → Batch-03
...
external_id_20 → Batch-07
```

{% endcolumn %}
{% endcolumns %}

***Configuration-3: Keep Existing 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
}
```

{% columns %}
{% column %}
**Before Execution:**

```
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
```

{% endcolumn %}

{% column %}
**After Execution:**

```
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
```

{% endcolumn %}
{% endcolumns %}

***Configuration-4: 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
}
```

{% columns %}
{% column %}
**Before Execution:**

```
external_id_1 → N/A
external_id_2 → N/A
external_id_3 → N/A
external_id_4 → N/A
...
external_id_20 → N/A
```

{% endcolumn %}

{% column %}
**After Execution:**

```
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
```

{% endcolumn %}
{% endcolumns %}

***Configuration-5: 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
}
```

{% columns %}
{% column width="50%" %}
**Before Execution:**

```
external_id_1 → Batch-1
external_id_2 → Batch-1
external_id_3 → Batch-1
external_id_4 → Batch-1
...
external_id_20 → Batch-1
```

{% endcolumn %}

{% column width="50%" %}
**After Execution:**

```
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
```

{% endcolumn %}
{% endcolumns %}

### 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>

* **"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:
    * <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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.imerit.net/plugins/first-party-ango-plugins/batch-assignment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
