How to use the databand.parameters.DateHourParameter function in databand

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 / 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 / parameters / test_date_parameter.py View on Github external
import datetime

from databand import parameters
from databand.parameters import MonthParameter, TimeDeltaParameter, YearParameter
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()
github databand-ai / dbnd / modules / dbnd / test_dbnd / task / test_task_object.py View on Github external
def test_no_warn_if_param_types_ok(self):
        class DummyTask(TTask):
            param = parameter[str]
            bool_param = parameter[bool]
            int_param = parameter[int]
            float_param = parameter[float]
            date_param = parameter[datetime]
            datehour_param = DateHourParameter()
            timedelta_param = TimeDeltaParameter()
            insignificant_param = parameter(significant=False)[str]

        DUMMY_TASK_OK_PARAMS = dict(
            param="test",
            bool_param=True,
            int_param=666,
            float_param=123.456,
            date_param=datetime(2014, 9, 13).date(),
            datehour_param=datetime(2014, 9, 13, 9, tzinfo=pytz.UTC),
            timedelta_param=timedelta(44),  # doesn't support seconds
            insignificant_param="test",
        )

        with warnings.catch_warnings(record=True) as w:
            DummyTask(**DUMMY_TASK_OK_PARAMS)
github databand-ai / dbnd / modules / dbnd / test_dbnd / parameters / test_date_parameter.py View on Github external
def test_date_to_dh(self):
        date = parameters.DateHourParameter()._p.normalize(datetime.date(2000, 1, 1))
        assert date == datetime.datetime(2000, 1, 1, 0, tzinfo=utc)
github databand-ai / dbnd / modules / dbnd / test_dbnd / parameters / test_date_parameter.py View on Github external
def test_parse(self):
        dh = parameters.DateHourParameter()._p.parse_from_str("2013-02-01T18")
        assert dh == datetime.datetime(2013, 2, 1, 18, 0, 0, tzinfo=utc)
github databand-ai / dbnd / modules / dbnd / test_dbnd / parameters / test_date_parameter.py View on Github external
def testSerialize(self):
        date = datetime.date(2013, 2, 3)
        assert parameter[datetime.date]._p.to_str(date) == "2013-02-03"
        assert YearParameter()._p.to_str(date) == "2013"
        assert MonthParameter()._p.to_str(date) == "2013-02"
        dt = datetime.datetime(2013, 2, 3, 4, 5)
        assert parameters.DateHourParameter()._p.to_str(dt) == "2013-02-03T04"
github databand-ai / dbnd / modules / dbnd / test_dbnd / package / test_import_package.py View on Github external
# 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