Task Definition
In HQS Tasks, each task is defined by a so-called task definition. This is a JSON representation of
- the name and version (the "identity") of the task
- some description for the user
- the specification of input and output schemas
- information of how the task can be invoked via the CLI (the CLI command line and name of arguments to pass files)
- the default provisioning options
The following is an example of how such a task definition can look like:
{
"name": "hello",
"description": "Some famous hello world example!",
"version": "0.5.0",
"input": {
"file_argument": "--input-file",
"json_schema": {
"type": "string"
}
},
"output": {
"file_argument": "--output-file",
"json_schema": {
"type": "string"
}
},
"error": {
"file_argument": "--error-file"
},
"command": [
"hqs_task_example",
"hello"
],
"provisioning_defaults": {}
}
It originates from the following task code written in Python:
from hqs_task import task
@task
def hello(name: str) -> str:
"""Some famous hello world example!"""
return f"Hello {name}!"
Furthermore, the above definition shows us that the Python code can be invoked by the CLI script name hqs_task_example. That has been configured in the Python project file (pyproject.toml) using the section
[project.scripts]
hqs_task_example = "hqs_task_example:cli"
and by including the following line in the root module's __init__.py file:
from hqs_task import cli