Exemple #1
0
def chained_task(tmpdir):
    # block ids:
    # 4,  7,  11, 16
    # 8,  12, 17, 23
    # 13, 18, 24, 31
    # 19, 25, 32, 40
    first_task = Task(
        task_id="first",
        total_roi=Roi((0, 0), (6, 6)),
        read_roi=Roi((0, 0), (3, 3)),
        write_roi=Roi((1, 1), (1, 1)),
        process_function=process_block,
        check_function=None,
    )

    # block ids:
    # 4,  7
    # 8,  12
    return first_task, Task(
        task_id="second",
        total_roi=Roi((1, 1), (4, 4)),
        read_roi=Roi((0, 0), (3, 3)),
        write_roi=Roi((1, 1), (1, 1)),
        process_function=process_block,
        check_function=None,
        upstream_tasks=[first_task],
    )
Exemple #2
0
def overlapping_tasks():
    task_1 = Task(
        "task1",
        total_roi=Roi((0, ), (100, )),
        read_roi=Roi((0, ), (10, )),
        write_roi=Roi((1, ), (8, )),
        process_function=process_block,
        check_function=None,
        read_write_conflict=True,
        fit="valid",
        num_workers=1,
        max_retries=2,
        timeout=None,
    )
    task_2 = Task(
        "task2",
        total_roi=Roi((0, ), (100, )),
        read_roi=Roi((0, ), (10, )),
        write_roi=Roi((1, ), (8, )),
        process_function=process_block,
        check_function=None,
        read_write_conflict=True,
        fit="valid",
        num_workers=1,
        max_retries=2,
        timeout=None,
        upstream_tasks=[task_1],
    )
    return task_1, task_2
Exemple #3
0
def task_no_conflicts(tmpdir):
    # block ids:
    # 1, 2

    # 1, 2  ->  Level 1
    return Task(
        task_id="test_1d",
        total_roi=Roi((0, ), (4, )),
        read_roi=Roi((0, ), (3, )),
        write_roi=Roi((1, ), (1, )),
        read_write_conflict=False,
        process_function=process_block,
        check_function=None,
    )
Exemple #4
0
def task_1d(tmpdir):
    # block ids:
    # 1, 2

    # 2  ->  Level 1
    # 1  ->  Level 2
    return Task(
        task_id="test_1d",
        total_roi=Roi((0, ), (4, )),
        read_roi=Roi((0, ), (3, )),
        write_roi=Roi((1, ), (1, )),
        process_function=process_block,
        check_function=None,
    )
Exemple #5
0
def task_zero_levels(tmpdir):
    """
    Because the minimum stride for independent write blocks
    is larger than the total_read_roi, there are multiple
    levels that would not have any blocks in them.
    """
    total_read_roi = Roi((0, 0), (10, 10))
    read_roi = Roi((0, 0), (9, 9))
    write_roi = Roi((4, 4), (1, 1))

    return Task(
        task_id="test_zero_levels",
        total_roi=total_read_roi,
        read_roi=read_roi,
        write_roi=write_roi,
        process_function=process_block,
        check_function=None,
        fit="overhang",
        max_retries=0,
    )
Exemple #6
0
def task_2d(tmpdir):
    # block ids:
    # 4,  7,  11, 16
    # 8,  12, 17, 23
    # 13, 18, 24, 31
    # 19, 25, 32, 40

    # if every block depends on its neighbors then there are 4 sets
    # of 4 blocks that are safe to run in parallel in the order (1,1), (0,1), (1,0), (0,0)
    # 12, 23, 25, 40  ->  Level 1
    # 8,  17, 19, 32  ->  Level 2
    # 7,  16, 18, 31  ->  Level 3
    # 4,  11, 13, 24  ->  Level 4
    return Task(
        task_id="test_2d",
        total_roi=Roi((0, 0), (6, 6)),
        read_roi=Roi((0, 0), (3, 3)),
        write_roi=Roi((1, 1), (1, 1)),
        process_function=process_block,
        check_function=None,
    )
Exemple #7
0
from daisy import Roi, Task, Scheduler, BlockStatus

import pytest

read_roi = Roi((0, 0, 0), (4, 4, 4))
write_roi = Roi((1, 1, 1), (2, 2, 2))
total_rois = [
    Roi((10, 10, 10), (10, 10, 10)),  # small roi (4x4x4) 64 write rois
    Roi((5, 5, 5), (20, 20, 20)),  # medium roi (9x9x9) 729 write rois
    Roi((0, 0, 0), (30, 30, 30)),  # large roi (14x14x14) 2,744 write rois
]

small_task = Task(
    task_id="small",
    total_roi=total_rois[0],
    read_roi=read_roi,
    write_roi=write_roi,
    process_function=lambda: None,
    check_function=None,
)

medium_task = Task(
    task_id="medium",
    total_roi=total_rois[1],
    read_roi=read_roi,
    write_roi=write_roi,
    process_function=lambda: None,
    check_function=None,
)

large_task = Task(
    task_id="large",
    write_roi_small,
    write_roi_medium,
    write_roi_small,
    write_roi_medium,
    write_roi_small,
    write_roi_medium,
]
fits = ["valid", "valid", "overhang", "overhang", "shrink", "shrink"]
conflicts = [True, False]

tasks = [
    Task(
        name,
        total_roi,
        read_roi,
        write_roi,
        process_function=lambda b: None,
        read_write_conflict=True,
        fit=fit,
    )
    for name, write_roi, fit in zip(names, write_rois, fits)
]

num_blocks = [
    8,  # small_valid       write roi should cover [2:10)
    3,  # medium_valid      write roi should cover [1:10)
    8,  # small_overhang    write roi should cover [2:10)
    4,  # medium_overhang   write roi should cover [1:12)
    8,  # small_shrink      write roi should cover [2:10)
    4,  # medium_shrink     write roi should cover [1:11)
]