Skip to main content

Introduction

This guide describes the concept of task templates, providing instructions for how to create and upload your own.

A task template is a pre-defined type of task, which is expected to be used repeatedly across different projects, and may also be executed multiple times by participants in a given project. We currently support two types of task templates, namely image-classification and image-segmentation.

Two YAML configuration files are required to create task templates. One which defines the overall task template (Task Template YAML), and one which defines the actual task to execute (Task YAML).

The Task Template YAML specifies one or more task templates to be uploaded, together with additional information about them to the hub. It is also used to upload custom models and weights files to the hub, as may be required by the tasks defined in the task templates.

The Task YAML specifies how a task is actually executed.

Setting Up Task Templates

Task Templates YAML

Every task template has 5 elements:

  • task-templates:slug: Used for the identifying the task template on the Bitfount Hub. You can find your previously uploaded task templates on the hub: https://hub.bitfount.com/< username >/tasks/< slug >.
  • task-templates:title: The name of the task that will be displayed on the hub.
  • task-templates:type: The type of task, can be either image-classification or image-segmentation.
  • task-templates:description: The description of the task which will be displayed on the hub.
  • task-templates:template: The task YAML file. We go into more detail on how to set this up below.

Additionally, if the task YAML uses pre-trained or custom models, they must be added to the task template as well.

  • models:private : Whether the model is private or public. Use true or false for this attribute to indicate model privacy.
  • models:model_file: The path to the model used.
  • models:weights_file: The path to the model weights file.
task-templates:  - slug: <Enter Slug For Identification of the Task>    title: <Enter Name You'll See in the Hub>    type: image-classification / image-segmentation # delete as appropriate    description: >      <Enter the Task Description>    template: <Task YAML path>models: # can be populated with as many models as needed  - private: true # Can be true or false    model_file: <Enter Path to Model File>    weights_file: <Enter Path to Weights File>

Note that you can add multiple templates or models at the same time.

Task Template YAML Example

task-templates:  - slug: image-classification-custom-model    title: Example image classification task template    type: image-segmentation    description: >      Example image classification description    template: task_templates/task_yaml_example.yamlmodels:  - private: true    model_file: MyCustomModel.py

Setting Up Tasks

Task YAML

Now, let's look at how to set up a task YAML file. This is the file specified under task-templates:template for the task template. There are a few key things to specify:

  • pods:identifiers: The list of pods that hold the data to use. This needs to be part of the task but is ignored when used as a template. This means that once the template is uploaded to the hub, it may be used on other compatible datasets in the project.
  • modeller:identity_verification_method: The authentication method to use. If not provided, the OIDC Device Authorisation Flow will be used. For more details, see our Hub Authentication & Authorisation Options
  • task:protocol: The protocol to use for the task. Read more about Bitfount protocols.
  • task:algorithm: The algorithm or list of algorithms to use for the task. Note that most of our built-in protocols only use one algorithm. Read more about Bitfount algorithms.
  • task:algorithm:model: The model to use in the specified algorithm. Read more about Bitfount models.
  • task:algorithm:model:bitfount_model: If using a custom model, this needs to be specified. The arguments for this include:
  • task:algorithm:model:bitfount_model:model_ref: The reference for the custom model. This can be the path of the model or just the name of the model class. For the purpose of setting up the task request, we suggest using the model class name.
  • task:algorithm:model:bitfount_model:version: The version for the custom model to use. If not provided, the latest version available on the hub will be used.
  • task:algorithm:model:bitfount_model:username: The username of the user that owns the custom model. If the user creating the task template also owns the model, this argument can be skipped. Otherwise, it must be specified in order to ensure the correct model is used.
  • task:model:hyperparameters: The settings used by the model.
  • task:datastructure: The datastructure for the models. This needs to be part of the task but is ignored when the task YAML is used in a task template. Read more about Bitfount datastructures.

For more details on the task elements, please see the Bitfount Task Elements Guide

Task YAML Example

Below we provide an example of a task YAML. For the pod identifier we have provided the pod identifier from Running an Image Pod Tutorial.

pods:  identifiers:    - "mnist-demo-dataset"# Task detailstask:  protocol:    name: bitfount.InferenceAndCSVReport  algorithm:    - name: bitfount.ModelInference      arguments:        class_outputs: ["0", "1"]      model:        bitfount_model:          model_ref: MyCustomModel          model_version: 1          username: bitfount # if the model is used by the user who own it, this can be skipped        hyperparameters:          batch_size: 4          epochs: 1    - name: bitfount.CSVReportAlgorithm      arguments:        save_path: "."  data_structure:    table_config:      table: "mnist-demo-dataset"    assign:      target: "target"      image_cols: ["file"]

Tasks can be tested prior to uploading, using the following snippet of code:

from bitfount.runners.modeller_runner import setup_modeller_from_config_file, run_modellerpath_to_task_yaml = "<path to your task yaml file>"(    modeller,    pod_identifiers,    project_id,    run_on_new_data_only,    batched_execution,) = setup_modeller_from_config_file(path_to_task_yaml) # replace with your task YAMLrun_modeller(    modeller,    pod_identifiers,    project_id=project_id,    run_on_new_data_only=run_on_new_data_only,    batched_execution=batched_execution,)

ℹ️ Make sure the target pod is up and running on the Bitfount Hub prior to testing the task YAML.

Uploading Task Templates to the Bitfount Hub

Once all the task templates required are set up, they can be uploaded to the hub for use within different projects. We provide a script for uploading the task templates with the Bitfount library.

python -m bitfount.runners.upload_task_templates <path-to-task-template-file> -u <username>

In the above command replace path-to-task-template-file with the path to the relevant task template YAML file and the username should be that of the user creating the task template.

Contact our support team at support@bitfount.com if you have any questions.