Tutorials¶
Creating a task¶
This tutorial shows how to add a new task into the Task Library so that it can be executed as part of a workflow vi :doc:`tools/run or as a stand-alone task via run-task
To put it quite simply, a task is a wrapper class around a command
line statement. There are two types of tasks within the task library
that have slightly different signatures. The simplest is a
metric that takes one input file and outputs one output file
in tsv format. To add a task, simply create a new file called
MyTask.py
inside the TaskLibrary
directory within the
repository:
import daisy.Pipeline as P
from .MetricRunner import MetricRunner
class run_metric_filestat(MetricRunner):
name = "filestat"
path = "stat"
def run(self, infile, outfile, params):
return P.run("{params.path} --printf='filename\\tsize\\n%%n\\t%%s\\n' "
"{infile} > {outfile}".format(**locals()))
The metric will be auto-discovered.