Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions benchmarks/bench_dependency_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
volume chunked into ~1M blocks. Compares daisy (Python) vs daisy (Rust).
"""

import time
import json
import time

# --- Daisy ---
from daisy import BlockwiseDependencyGraph as DaisyGraph
from daisy import Roi as DaisyRoi

# --- Daisy ---
from daisy import BlockwiseDependencyGraph as DaisyGraph
from daisy import Roi as DaisyRoi


def bench_daisy(total_shape, block_shape, context, read_write_conflict):
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/bench_worker_scaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
via `daisy.Client`)
"""

import time
import json
import time

# Ensure both packages are importable
import daisy
import daisy


# --- Daisy benchmark ---
Expand Down
1 change: 1 addition & 0 deletions build_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import shutil
import sys

from maturin import * # Forward everything from maturin


Expand Down
9 changes: 3 additions & 6 deletions daisy-py/python/daisy/_daisy.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ pyright) read this `.pyi` instead of trying to introspect the
compiled `.so`.
"""

from collections.abc import Iterable, Iterator
from collections.abc import Callable, Iterable, Iterator
from pathlib import Path
from typing import Any, Callable
from typing import Any

# -- Geometry primitives ------------------------------------------------

Expand Down Expand Up @@ -49,7 +49,6 @@ class Roi:
def translate(self, by: Coordinate | Iterable[int]) -> Roi: ...
def __eq__(self, other: object) -> bool: ...
def __hash__(self) -> int: ...
def __repr__(self) -> str: ...


# -- Blocks -------------------------------------------------------------
Expand Down Expand Up @@ -149,7 +148,7 @@ class Task:
fit: str = ...,
max_workers: int = ...,
max_retries: int = ...,
timeout: float | int | object | None = ...,
timeout: float | object | None = ...,
done_marker_path: str | bool | None = ...,
requires: dict[str, int] | None = ...,
max_worker_restarts: int = ...,
Expand Down Expand Up @@ -226,7 +225,6 @@ class Pipeline:
def __or__(self, other: Task | Pipeline) -> Pipeline: ...
def __radd__(self, other: Task | Pipeline) -> Pipeline: ...
def __ror__(self, other: Task | Pipeline) -> Pipeline: ...
def __repr__(self) -> str: ...


# -- Dependency graph ---------------------------------------------------
Expand Down Expand Up @@ -290,7 +288,6 @@ class Context:
def to_env(self) -> str: ...
@staticmethod
def from_env() -> Context: ...
def __repr__(self) -> str: ...

class SyncClient:
def __init__(
Expand Down
1 change: 0 additions & 1 deletion daisy-py/python/daisy/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import daisy._daisy as _rs
from daisy import logging as _worker_log

from daisy._progress import _log_resume_summary
from daisy._task import (
_to_pipeline,
Expand Down
2 changes: 1 addition & 1 deletion daisy-py/python/daisy/_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
`daisy.v1_compat`, not here.
"""

from contextlib import contextmanager
import copy
import inspect
import logging
import warnings
from contextlib import contextmanager
from pathlib import Path

import daisy._daisy as _rs
Expand Down
2 changes: 1 addition & 1 deletion daisy-py/python/daisy/_worker_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import pickle
import struct
import subprocess
import tempfile
import sys
import tempfile
import types

#: exit code the worker child uses when it self-terminates because a block
Expand Down
5 changes: 3 additions & 2 deletions daisy-py/python/daisy/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@

from __future__ import annotations

import typing
import logging as _py_logging
import re
import sys
import threading
import traceback as _py_traceback
import typing
from pathlib import Path


# --- Public knobs ------------------------------------------------------------

LOG_BASEDIR: Path | None = Path("./daisy_logs")
Expand Down Expand Up @@ -300,6 +299,7 @@ def __exit__(self, exc_type, exc, tb):
# Path of this package, used to strip daisy-internal frames from
# tracebacks before rendering.
import os as _os

_DAISY_PKG_DIR = _os.path.abspath(_os.path.dirname(__file__))


Expand Down Expand Up @@ -410,6 +410,7 @@ def format_traceback(exc_type, exc, tb) -> str:
if _TRACEBACK_STYLE == "rich":
try:
import io

from rich.console import Console
from rich.traceback import Traceback
tb_obj = Traceback.from_exception(
Expand Down
3 changes: 2 additions & 1 deletion daisy-py/python/daisy/v1_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from daisy import v2 as _v2
from daisy._runner import _run_serial
from daisy._task import _record_task_upstream
from daisy.v2 import ( # noqa: F401 — re-exported compat surface
from daisy.v2 import (
BlockStatus,
BlockwiseDependencyGraph,
Client,
Expand Down Expand Up @@ -133,6 +133,7 @@ def _install_compat_block_boundary():
wire block so daisy's bookkeeping (auto-SUCCESS, failure reporting)
is unaffected."""
from contextlib import contextmanager

from daisy._task import Client

_orig_acquire = Client.acquire_block
Expand Down
3 changes: 2 additions & 1 deletion daisy-py/python/daisy/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
daisy.run_blockwise([task])
"""

from importlib.metadata import PackageNotFoundError, version as _version
from importlib.metadata import PackageNotFoundError
from importlib.metadata import version as _version

import daisy._daisy as _rs
from daisy._progress import JsonProgressObserver
Expand Down
5 changes: 2 additions & 3 deletions examples/astronaut_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@
import time
from pathlib import Path

import daisy.logging as gl
import daisy.v2 as daisy
import matplotlib.pyplot as plt
import numpy as np
from scipy.ndimage import label as scipy_label
from skimage.data import astronaut
from skimage.filters import sobel
from skimage.segmentation import watershed

import daisy.v2 as daisy
import daisy.logging as gl

_TMP = Path(tempfile.mkdtemp(prefix="daisy_astronaut_pipeline_"))
gl.set_log_basedir(_TMP / "logs")
print(f"output paths under: {_TMP}")
Expand Down
6 changes: 2 additions & 4 deletions examples/mws.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,18 @@

# %%
import tempfile
import threading
import time
from pathlib import Path

import daisy.logging as gl
import daisy.v2 as daisy
import lsd_lite
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import mwatershed
import numpy as np
import zarr

import daisy.v2 as daisy
import daisy.logging as gl

_TMP = Path(tempfile.mkdtemp(prefix="daisy_mws_"))
gl.set_log_basedir(_TMP / "logs")
# Tee worker stdout/stderr to both file and terminal so the run-3
Expand Down
2 changes: 1 addition & 1 deletion examples/stress_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import time
from pathlib import Path

import daisy.v2 as daisy
import daisy.logging as gl
import daisy.v2 as daisy

_TMP = Path(tempfile.mkdtemp(prefix="daisy_stress_"))
gl.set_log_basedir(_TMP / "logs")
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
is idempotent.
"""

import pytest

import daisy.logging as gl
import pytest


@pytest.fixture(autouse=True)
Expand Down
5 changes: 2 additions & 3 deletions tests/daisy_compat/process_block.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import daisy as daisy

import time
import random
import sys
import time

import daisy as daisy
from filelock import FileLock

tmp_path = sys.argv[1]
Expand Down
4 changes: 2 additions & 2 deletions tests/daisy_compat/process_block_or_die.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
workers see the marker and process blocks normally.
"""

import daisy as daisy

import os
import sys

import daisy as daisy

tmp_path = sys.argv[1]
marker = os.path.join(tmp_path, "worker_crashed")

Expand Down
3 changes: 1 addition & 2 deletions tests/daisy_compat/test_client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import multiprocessing as mp

import pytest

import daisy
import pytest

# `daisy.messages` and `daisy.tcp` were daisy 1.x's internal protocol modules
# (pickle-over-tornado). daisy v2's wire protocol is bincode over tokio TCP,
Expand Down
4 changes: 1 addition & 3 deletions tests/daisy_compat/test_clients_close.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
import subprocess
import sys

import pytest
from filelock import FileLock

import daisy
from daisy.logging import set_log_basedir
from filelock import FileLock

logging.basicConfig(level=logging.DEBUG)

Expand Down
2 changes: 0 additions & 2 deletions tests/daisy_compat/test_dead_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import subprocess
import sys

import pytest

import daisy
from daisy.logging import set_log_basedir

Expand Down
8 changes: 2 additions & 6 deletions tests/daisy_compat/test_dependency_graph.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from daisy import BlockwiseDependencyGraph
from daisy import Task
from daisy import Block
from daisy import Roi
import logging

import pytest

import logging
from daisy import Block, BlockwiseDependencyGraph, Roi, Task

logger = logging.getLogger(__name__)

Expand Down
8 changes: 2 additions & 6 deletions tests/daisy_compat/test_scheduler.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from daisy import Scheduler
from daisy import Task
from daisy import Block, BlockStatus
from daisy import Roi
import logging

import pytest

import logging
from daisy import Block, BlockStatus, Roi, Scheduler, Task

logger = logging.getLogger(__name__)

Expand Down
3 changes: 1 addition & 2 deletions tests/daisy_compat/test_server.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import logging

import pytest

import daisy
import pytest

logging.basicConfig(level=logging.DEBUG)

Expand Down
3 changes: 1 addition & 2 deletions tests/test_block_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
ROIs — v1 parity for code that constructs blocks directly, e.g.
"process this one ROI without a blockwise job" helpers."""

import daisy
import funlib.geometry as fg
import pytest

import daisy


def test_block_constructs_from_funlib_rois():
b = daisy.Block(fg.Roi((0,), (40,)), fg.Roi((0,), (10,)), fg.Roi((5,), (5,)))
Expand Down
3 changes: 1 addition & 2 deletions tests/test_check_function_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

import warnings

import pytest

import daisy
import pytest


def _mk(**kw):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_client_graceful.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
import subprocess
import sys

import pytest

import daisy
import pytest


def _dead_port() -> int:
Expand Down
5 changes: 1 addition & 4 deletions tests/test_context_passing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@
"""

import os
import subprocess
import sys
import time

import pytest

import daisy
import pytest


def _mk_task(spawn_fn, n_blocks=16, max_workers=8, **kw):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_default_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import os
import time

import pytest

import daisy
import pytest


def _task(fn, **kw):
Expand Down
Loading
Loading