Example #1
0
def test_from_grid_resolve_relative_to():
    dag = DAG()
    TaskGroup.from_grid(PythonCallable,
                        File,
                        'file.txt', {
                            'source': touch_a_b,
                        },
                        dag,
                        name='task_group',
                        grid={
                            'a': [1, 2],
                            'b': [3, 4]
                        },
                        resolve_relative_to='')

    assert str(dag['task_group0'].product) == str(Path('file-0.txt').resolve())
    assert str(dag['task_group1'].product) == str(Path('file-1.txt').resolve())
    assert str(dag['task_group2'].product) == str(Path('file-2.txt').resolve())
    assert str(dag['task_group3'].product) == str(Path('file-3.txt').resolve())
Example #2
0
def test_from_grid():
    dag = DAG()
    group = TaskGroup.from_grid(PythonCallable,
                                File,
                                'file.txt', {
                                    'source': touch_a_b,
                                },
                                dag,
                                name='task_group',
                                grid={
                                    'a': [1, 2],
                                    'b': [3, 4]
                                })

    assert len(group) == 4
Example #3
0
def test_from_grid_with_hook(hook_name):
    def my_hook():
        pass

    dag = DAG()
    group = TaskGroup.from_grid(PythonCallable,
                                File,
                                'file.txt', {
                                    'source': touch_a_b,
                                },
                                dag,
                                name='task_group',
                                grid={
                                    'a': [1, 2],
                                    'b': [3, 4]
                                },
                                **{hook_name: my_hook})

    assert len(group) == 4
    assert all(getattr(t, hook_name) is my_hook for t in dag.values())