Ejemplo n.º 1
0
def main():
    dbnd_bootstrap()

    from airflow.models import TaskInstance
    from airflow.utils.log.logging_mixin import redirect_stderr, redirect_stdout
    from airflow.utils.timezone import utcnow

    from dbnd import config
    from dbnd._core.constants import TaskExecutorType
    from dbnd._core.settings import RunConfig
    from dbnd._core.task_run.task_run import TaskRun
    from dbnd.tasks.basics import dbnd_sanity_check
    from dbnd_examples.dbnd_airflow import bash_dag

    airflow_task_log = logging.getLogger("airflow.task")

    task = bash_dag.t3
    execution_date = utcnow()
    ti = TaskInstance(task, execution_date)

    ti.init_run_context(raw=False)
    logger.warning("Running with task_log %s",
                   airflow_task_log.handlers[0].handler.baseFilename)
    with redirect_stdout(airflow_task_log, logging.INFO), redirect_stderr(
            airflow_task_log, logging.WARN):
        logger.warning("from redirect")

        logger.warning("after patch")
        with config({RunConfig.task_executor_type: TaskExecutorType.local}):
            run = dbnd_sanity_check.dbnd_run()
            tr = run.root_task_run  # type: TaskRun

    logger.warning("TR: %s %s %s", tr, tr.task_tracker_url,
                   tr.log.local_log_file)
Ejemplo n.º 2
0
    def test_sanity(self):
        print(sys.stdout)
        dbnd_sanity_check.dbnd_run()

        print(sys.stdout)
        pass
Ejemplo n.º 3
0
from dbnd import config
from dbnd.tasks.basics import dbnd_sanity_check


if __name__ == "__main__":
    config.set("databand", "env", "gcp_k8s")
    dbnd_sanity_check.dbnd_run()