How to use databand - 10 common examples

To help you get started, we’ve selected a few databand examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github databand-ai / dbnd / modules / dbnd / test_dbnd / task / test_task_inline_parsing.py View on Github external
def test_params_parse(self):
        class TParseTask(TTask):
            bool_param = parameter[bool]
            int_param = parameter[int]
            float_param = parameters.FloatParameter()
            date_param = parameter[date]
            timedelta_param = parameters.TimeDeltaParameter()

            def run(self):
                assert isinstance(self.float_param, float)
                super(TParseTask, self).run()

        target = TParseTask(
            bool_param="yes",
            int_param="666",
            float_param="123.456",
            date_param="2018-11-10",
            timedelta_param="44d",
        )
        assert_run_task(target)
github databand-ai / dbnd / modules / dbnd / test_dbnd / package / test_import_package.py View on Github external
dbnd.parameter,
            dbnd.data,
            databand.task,
            tasks.DataSourceTask,
            tasks.PipelineTask,
            targets.Target,
            targets.DataTarget,
            dbnd._core.task_build.task_namespace.namespace,
            parameters.Parameter,
            parameters.DateHourParameter,
            parameters.DateMinuteParameter,
            parameters.DateSecondParameter,
            parameters.DateParameter,
            parameters.MonthParameter,
            parameters.YearParameter,
            parameters.DateIntervalParameter,
            parameters.TimeDeltaParameter,
            parameters.IntParameter,
            parameters.FloatParameter,
            parameters.BoolParameter,
        ]
        assert len(expected) > 0
github databand-ai / dbnd / modules / dbnd / test_dbnd / parameters / test_date_parameter.py View on Github external
def test_parse(self):
        ds = parameters.DateSecondParameter()._p.parse_from_str("2013-02-01T184227")
        assert ds == datetime.datetime(2013, 2, 1, 18, 42, 27, tzinfo=utc)
github databand-ai / dbnd / modules / dbnd / test_dbnd / task / test_task_inline_parsing.py View on Github external
import logging

from datetime import date, timedelta
from typing import Dict

import pandas as pd

from databand import parameters
from dbnd import PipelineTask, output, parameter, task
from dbnd.testing.helpers_pytest import assert_run_task
from dbnd_test_scenarios.test_common.task.factories import TTask


class DummyTask(TTask):
    float_param = parameters.FloatParameter()
    expected_param = parameters.FloatParameter()

    timedelta_param = parameters.TimeDeltaParameter()
    expected_timedelta_param = parameters.TimeDeltaParameter()

    def run(self):
        assert isinstance(self.float_param, float)
        assert isinstance(self.timedelta_param, timedelta)
        assert self.float_param == self.expected_param
        assert self.timedelta_param == self.expected_timedelta_param
        super(DummyTask, self).run()


class DummyWrapper(PipelineTask):
    defaults = {DummyTask.float_param: "0.1", DummyTask.timedelta_param: "4d"}
    output = output
github databand-ai / dbnd / modules / dbnd / test_dbnd / parameters / test_dict_parameter.py View on Github external
def test_parse(self):
        d = parameters.DictParameter()._p.parse_from_str(
            json.dumps(TestDictParameter._dict)
        )
        assert d == TestDictParameter._dict
github databand-ai / dbnd / modules / dbnd / test_dbnd / parameters / test_date_parameter.py View on Github external
def test_serialize(self):
        dh = parameters.DateHourParameter()._p.to_str(
            datetime.datetime(2013, 2, 1, 18, 0, 0)
        )
        assert dh == "2013-02-01T18"
github databand-ai / dbnd / modules / dbnd / test_dbnd / task / test_task_inline_parsing.py View on Github external
def test_params_parse(self):
        class TParseTask(TTask):
            bool_param = parameter[bool]
            int_param = parameter[int]
            float_param = parameters.FloatParameter()
            date_param = parameter[date]
            timedelta_param = parameters.TimeDeltaParameter()

            def run(self):
                assert isinstance(self.float_param, float)
                super(TParseTask, self).run()

        target = TParseTask(
            bool_param="yes",
            int_param="666",
            float_param="123.456",
            date_param="2018-11-10",
            timedelta_param="44d",
        )
        assert_run_task(target)
github databand-ai / dbnd / modules / dbnd / test_dbnd / parameters / test_date_parameter.py View on Github external
from dbnd import parameter
from dbnd._core.utils.timezone import utc
from dbnd.testing.helpers import build_task
from dbnd_test_scenarios.test_common.task.factories import TTask


class DateTask(TTask):
    day = parameter[datetime.date]


class DateHourTask(TTask):
    dh = parameters.DateHourParameter()


class DateMinuteTask(TTask):
    dm = parameters.DateMinuteParameter()


class DateSecondTask(TTask):
    ds = parameters.DateSecondParameter()


class MonthTask(TTask):
    month = MonthParameter()


class YearTask(TTask):
    year = YearParameter()


class TestDateParameter(object):
    def test_parse(self):
github databand-ai / dbnd / modules / dbnd / test_dbnd / task / test_task_inline_parsing.py View on Github external
from typing import Dict

import pandas as pd

from databand import parameters
from dbnd import PipelineTask, output, parameter, task
from dbnd.testing.helpers_pytest import assert_run_task
from dbnd_test_scenarios.test_common.task.factories import TTask


class DummyTask(TTask):
    float_param = parameters.FloatParameter()
    expected_param = parameters.FloatParameter()

    timedelta_param = parameters.TimeDeltaParameter()
    expected_timedelta_param = parameters.TimeDeltaParameter()

    def run(self):
        assert isinstance(self.float_param, float)
        assert isinstance(self.timedelta_param, timedelta)
        assert self.float_param == self.expected_param
        assert self.timedelta_param == self.expected_timedelta_param
        super(DummyTask, self).run()


class DummyWrapper(PipelineTask):
    defaults = {DummyTask.float_param: "0.1", DummyTask.timedelta_param: "4d"}
    output = output

    def band(self):
        self.output = DummyTask().t_output
github databand-ai / dbnd / modules / dbnd / test_dbnd / package / test_import_package.py View on Github external
import targets

        # These should exist (if not, this will cause AttributeErrors)
        expected = [
            dbnd.Config,
            dbnd.Task,
            dbnd.output,
            dbnd.parameter,
            dbnd.data,
            databand.task,
            tasks.DataSourceTask,
            tasks.PipelineTask,
            targets.Target,
            targets.DataTarget,
            dbnd._core.task_build.task_namespace.namespace,
            parameters.Parameter,
            parameters.DateHourParameter,
            parameters.DateMinuteParameter,
            parameters.DateSecondParameter,
            parameters.DateParameter,
            parameters.MonthParameter,
            parameters.YearParameter,
            parameters.DateIntervalParameter,
            parameters.TimeDeltaParameter,
            parameters.IntParameter,
            parameters.FloatParameter,
            parameters.BoolParameter,
        ]
        assert len(expected) > 0