Example #1
0
def print_tasks_tree(root_task, task_runs, describe_format=DescribeFormat.short):
    from dbnd._core.task_ctrl.task_dag_describe import DescribeDagCtrl

    completed = {tr.task.task_id: tr.is_reused for tr in task_runs}
    run_describe_dag = DescribeDagCtrl(
        root_task, describe_format, complete_status=completed
    )
    run_describe_dag.tree_view(describe_format=describe_format)
Example #2
0
    def run(self):
        driver_task_run = current_task_run()
        run = driver_task_run.run  # type: DatabandRun
        task_runs = self.build_root_task_runs(run)

        hearbeat = None

        # right now we run describe in local controller only, but we should do that for more
        if self.is_driver:
            if run.context.settings.system.describe:
                run.describe_dag.describe_dag()
                logger.info(run.describe.run_banner("Described!",
                                                    color="blue"))
                return

            root_task_run = run.root_task_run
            run.root_task.ctrl.banner(
                "Main task '%s' has been created!" % root_task_run.task_af_id,
                color="cyan",
                task_run=root_task_run,
            )
            from dbnd._core.task_ctrl.task_dag_describe import DescribeDagCtrl

            completed = {tr.task.task_id: tr.is_reused for tr in task_runs}
            run_describe_dag = DescribeDagCtrl(root_task_run.task,
                                               DescribeFormat.short,
                                               complete_status=completed)
            run_describe_dag.tree_view(describe_format=DescribeFormat.short)

            if self.is_save_run(run, task_runs):
                run.save_run()

            if self.sends_heartbeat:
                hearbeat = start_heartbeat_sender(driver_task_run)

        # create executor without driver task!
        task_executor = get_task_executor(
            run,
            task_executor_type=self.task_executor_type,
            host_engine=self.host_engine,
            target_engine=run.root_task_run.task_engine,
            task_runs=task_runs,
        )

        with nested(hearbeat):
            task_executor.do_run()

        if self.is_driver:
            # This is great success!
            run.set_run_state(RunState.SUCCESS)
            logger.info(run.describe.run_banner_for_finished())
            return run
        else:
            logger.info(run.describe.run_banner_for_submitted())
Example #3
0
    def __init__(self, task):
        super(TaskCtrl, self).__init__(task)

        from dbnd._core.task.task import Task

        assert isinstance(task, Task)
        from dbnd._core.task_ctrl.task_relations import TaskRelations  # noqa: F811
        from dbnd._core.task_ctrl.task_dag import _TaskDagNode  # noqa: F811
        from dbnd._core.task_ctrl.task_visualiser import TaskVisualiser  # noqa: F811
        from dbnd._core.task_ctrl.task_output_builder import TaskOutputBuilder
        from dbnd._core.task_ctrl.task_dag_describe import DescribeDagCtrl
        from dbnd._core.task_ctrl.task_validator import TaskValidator

        self._relations = TaskRelations(task)
        self.task_validator = TaskValidator(task)
        self._task_dag = _TaskDagNode(task)

        self.outputs = TaskOutputBuilder(task)  # type: TaskOutputBuilder

        self._visualiser = TaskVisualiser(task)
        self.describe_dag = DescribeDagCtrl(task)

        self._should_run = self.task_meta.task_enabled and self.task._should_run(
        )

        # will be assigned by the latest Run
        self.last_task_run = None  # type: Optional[TaskRun]
        self.force_task_run_uid = None  # force task run uid
Example #4
0
    def __init__(self, task):
        super(_BaseTaskCtrl, self).__init__(task)

        from dbnd._core.task_ctrl.task_dag import _TaskDagNode  # noqa: F811
        from dbnd._core.task_ctrl.task_dag_describe import DescribeDagCtrl
        from dbnd._core.task_ctrl.task_descendant import (
            TaskDescendants as _TaskDescendants, )
        from dbnd._core.task_ctrl.task_repr import TaskRepr
        from dbnd._core.task_ctrl.task_visualiser import TaskVisualiser  # noqa: F811

        self._task_dag = _TaskDagNode(task)
        self.descendants = _TaskDescendants(task)

        self._visualiser = TaskVisualiser(task)
        self.describe_dag = DescribeDagCtrl(task)

        self.task_repr = TaskRepr(self.task)

        # will be assigned by the latest Run
        self.last_task_run = None  # type: Optional[TaskRun]
        self.force_task_run_uid = None  # force task run uid