> For the complete documentation index, see [llms.txt](https://docs.deepomatic.com/platform-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.deepomatic.com/platform-documentation/deepomatic-drive/configuring-visual-automation-applications/assembling-workflows/workflow-implementation/write-the-task-group-implementation/how-to-control-the-execution-of-tasks.md).

# How to control the execution of tasks

## Task dependency using \`assert like\` helpers

If a task depends on another task value, or state value, or metadata value you can use [assert like helpers](https://github.com/Deepomatic/deepomatic-workflows/blob/v2/deepomatic/workflows/v2/core.py#L83-L188). Execution will be stopped if such assert are triggered. Instead of a value, a message of why the task didn't return a value will be present in the task result:

```python
@task(name="task-a")
def task_a(image_input: Image) -> bool:
    return True
    
@task(name="task-b")
def task_b(image_input: Image) -> bool:
    # If task-a not True, won't process further
    self.assert_task_is("task-a", True)
    # We can add custom message. Otherwise, a generic slug is sent
    self.assert_task_is_not("task-a", False, "Oh nooooo, task-a is False"
    return True
```

Available helpers are:

```python
# Asserts based on the value of a task from a previous analysis
self.assert_state_is("task_group_name", "task_name", value)
self.assert_state_is_not("task_group_name", "task_name", value)

# Asserts based on the value of the work order metadata
self.assert_wo_metadata_is("key", value)
self.assert_wo_metadata_is_not("key", value)

# Asserts based on the value of the analysis metadata
self.assert_analysis_metadata_is("key", value)
self.assert_analysis_metadata_is_not("key", value)

# Assert checking if a task has a value and was therefore correctly executed
self.assert_task_has_value("task_name")

# Asserts based on the value of a task from that current analysis
self.assert_task_is("task_name", value)
self.assert_task_is_not("task_name", value)

# Asserts based on the key in the workspace
self.assert_workspace_key_is("key", value)
self.assert_workspace_key_is_not("key", value)

```

{% hint style="info" %}
When an assert fails, it actually raises a TaskConformityError.
{% endhint %}

## Exceptions

You can manually control the execution of task by raising workflow specific exceptions:

#### TaskConformityError <a href="#taskconformityerror" id="taskconformityerror"></a>

To prevent a task from returning a value, a `TaskConformityError` with an error message can be raised. This is used to notify a reason of why a task couldn't be analysed properly.

#### DataConformityError <a href="#dataconformityerror" id="dataconformityerror"></a>

To prevent a task from returning a value, a `DataConformityError` with an error message can be raised. This is used to notify there is Data Conformity related error. \ <mark style="color:red;">**WIP, don't use this for now. Or warn us if you would want to.**</mark>
