# Write the task-group implementation

Each task group are implemented in their own python file under `task-groups/<task_group_name>.py` and each task-group herits from a TaskGroup class, with multiple methods to be implemented:

### Context Validation method

The `context_validation` method, if it exists for this task-group, is executed first.\
It is passed all the entries. It can only return a boolean which will be set as the value of the task associated to context\_validation in the specs.yaml file. If True is not returned, the execution will stop.

### Main method

The `main` method is executed first or right after the context\_validation if it exists.\
It should be used to do common inferences that will be used by different tasks.

### Task methods

Tasks are implemented as methods, decorated using the `@task` decorator. They are also passed all the entries, and are executed after the `main` function, in the order they are listed in the `specs.yaml` file.

{% hint style="info" %}
Every task declared in the `specs.yaml` file must be implemented.
{% endhint %}

Tasks can either return a value of the correct type, or raise a `TaskConformityError` with an error message that will be provided as an "hint" to the user. All the other exceptions are considered implementation errors and will be forwarded to the user as an "error".

{% hint style="info" %}
For now the TaskConformityError are not at all forwarded to the client, they are filtered by the CustomerAPI and replaced by a "None" task (as it is at first initialisation).\
This part is still no completely finished, but for now please raise a TaskConformityError when you don't want to output a value for a specific task.&#x20;
{% endhint %}
