Custom Target

Extending the DBND SDK (Databand) functionality to create custom targets.

The goal of this example is to show how users can extend DBND and create custom targets. This example creates a target which is a directory with two files.

Define a custom target:

from dbnd import parameter
from targets import DirTarget
from targets.values import TargetValueType

class MyCustomFolder(DirTarget):
    def __init__(self, *args, **kwargs):
        super(MyCustomFolder, self).__init__(*args, **kwargs)
        self.scores = self.partition("scores", config=file.csv)
        self.reports = self.partition("reports", config=file.csv)

my_custom_target = parameter.type(TargetValueType).custom_target(
    MyCustomFolder, folder=True

A pipeline to demonstrate how we read and write such targets

from dbnd import PythonTask, output, PipelineTask

class TaskWithCustomOutput(PythonTask):
    custom = my_custom_target.output

    def run(self):

class TaskWithCustomInput(PythonTask):
    custom = my_custom_target
    t_output =

    def run(self):
        assert == "1"
        assert == "2"

class CustomIOPipeline(PipelineTask):
    t_output =

    def band(self):
        custom = TaskWithCustomOutput().custom
        self.t_output = TaskWithCustomInput(custom=custom).t_output

What’s Next
Did this page help you?