예제 #1
0
def test__Composer_get_schedules():
    A = Task("A.py", "test-exe")
    B = Task("B.py", "test-exe")
    C = Task("C.py", "test-exe")
    Z = Task("Z.py", "test-exe")
    dag = DAG()
    dag.add_tasks({A, B, C, Z})
    dag.add_dependencies({B: A, C: B})
    dq = Composer(dag)

    priorities = dq.get_schedules()
    testable = {}

    # build a testable result dict
    for k, v in priorities.items():
        new_set = set()
        if isinstance(v, Task):
            testable[k] = set(v)
            continue

        for vi in v:
            new_set.add(hash(vi))
        testable[k] = new_set

    assert testable == {1: {hash(A), hash(Z)}, 2: {hash(B)}, 3: {hash(C)}}
예제 #2
0
def test__readme_example():

    ## define tasks and environments
    pour_water = Task("./tea-tasks/pour_water.py")
    boil_water = Task("./tea-tasks/boil_water.py")
    prep_infuser = Task("./tea-tasks/prep_infuser.py")
    steep_tea = Task("./tea-tasks/steep_tea.py")

    ## define runtime dependencies
    make_tea = DAG(upstream_dependencies={
        boil_water: {pour_water},
        steep_tea: {boil_water, prep_infuser},
    })

    ## run tasks
    dq = Composer(make_tea)
    dq.get_schedules()