예제 #1
0
    def test_task_ref_execution_delta_validation(self):
        with pytest.raises(ValueError):
            TaskRef(dag_name="test_dag",
                    task_id="task",
                    execution_delta="invalid")

        assert TaskRef(dag_name="test_dag",
                       task_id="task",
                       execution_delta="1h15m")
예제 #2
0
    def test_task_ref(self):
        task_ref = TaskRef(dag_name="test_dag", task_id="task")

        assert task_ref.dag_name == "test_dag"
        assert task_ref.task_id == "task"
        assert task_ref.execution_delta is None

        task_ref = TaskRef(dag_name="test_dag", task_id="task", execution_delta="15m")

        assert task_ref.execution_delta == "15m"
예제 #3
0
파일: dag.py 프로젝트: Iinh/bigquery-etl
    def _create_export_task(self, task, dag_collection):
        if not task.public_json:
            raise ValueError(
                f"Task {task.task_name} not marked as public JSON.")

        converter = cattr.Converter()
        task_dict = converter.unstructure(task)

        del task_dict["dataset"]
        del task_dict["table"]
        del task_dict["version"]
        del task_dict["project"]

        export_task = converter.structure(task_dict, Task)
        export_task.dag_name = self.name
        export_task.task_name = f"export_public_data_json_{export_task.task_name}"

        task_schedule_interval = dag_collection.dag_by_name(
            task.dag_name).schedule_interval

        execution_delta = schedule_interval_delta(task_schedule_interval,
                                                  self.schedule_interval)

        if execution_delta == "0s":
            execution_delta = None

        export_task.dependencies = [
            TaskRef(
                dag_name=task.dag_name,
                task_id=task.task_name,
                execution_delta=execution_delta,
            )
        ]

        return export_task