Skip to content

Commit

Permalink
Modularize starfish.core.experiment.builder (#1738)
Browse files Browse the repository at this point in the history
We need to be able to import modules in starfish.core.experiment.builder without slurping in the whole thing.  As it stands, if I add a dependency from starfish.core.imagestack to any module in  starfish.core.experiment.builder, it creates a circular dependency.  This moves the contents of starfish.core.experiment.builder.__init__.py to a standalone module.

The external api (starfish.experiment.builder) is maintained.

Test plan: `make -j lint mypy fast-test`
  • Loading branch information
Tony Tung authored Jan 22, 2020
1 parent 11cce4e commit 99a7f43
Show file tree
Hide file tree
Showing 17 changed files with 448 additions and 444 deletions.
415 changes: 0 additions & 415 deletions starfish/core/experiment/builder/__init__.py

Large diffs are not rendered by default.

415 changes: 415 additions & 0 deletions starfish/core/experiment/builder/builder.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion starfish/core/experiment/builder/structured_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from slicedimage import ImageFormat, WriterContract

from starfish.core.types import Axes, Coordinates, CoordinateValue, Number
from . import TileIdentifier, write_irregular_experiment_json
from .builder import TileIdentifier, write_irregular_experiment_json
from .inplace import InplaceFetchedTile, InplaceWriterContract
from .providers import FetchedTile, TileFetcher

Expand Down
10 changes: 6 additions & 4 deletions starfish/core/experiment/builder/test/factories/all_purpose.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
import numpy as np
import slicedimage

from starfish.core.experiment.builder import (
from starfish.core.types import Axes, Coordinates, CoordinateValue
from ...builder import (
build_irregular_image,
FetchedTile,
tile_fetcher_factory,
TileFetcher,
TileIdentifier,
)
from starfish.core.types import Axes, Coordinates, CoordinateValue
from ...providers import (
FetchedTile,
TileFetcher,
)


class LocationAwareFetchedTile(FetchedTile, metaclass=ABCMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from starfish.core.types import Axes, Coordinates, CoordinateValue
from .util import (
render_coordinates_to_rows,
UniqueTiles,
write_coordinates_csv,
write_tile_data,
)
from ..factories import unique_data
from ... import (
from ..factories.unique_tiles import UniqueTiles
from ...builder import (
tile_fetcher_factory,
TileFetcher,
TileIdentifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
from starfish.core.types import Axes, Coordinates, CoordinateValue
from .util import (
render_coordinates_to_rows,
UniqueTiles,
write_coordinates_csv,
write_tile_data,
)
from ..factories import unique_data
from ... import (
from ..factories.unique_tiles import UniqueTiles
from ...builder import (
tile_fetcher_factory,
TileFetcher,
TileIdentifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
from starfish.core.types import Axes, Coordinates, CoordinateValue, Number
from .util import (
render_coordinates_to_rows,
UniqueTiles,
write_coordinates_csv,
write_tile_data,
)
from ..factories import unique_data
from ... import (
from ..factories.unique_tiles import UniqueTiles
from ...builder import (
tile_fetcher_factory,
TileFetcher,
TileIdentifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

from starfish.core.types import Axes, Coordinates, CoordinateValue
from ..factories import unique_data
from ... import FetchedTile, TileFetcher, TileIdentifier
from ...builder import TileFetcher, TileIdentifier
from ...providers import FetchedTile
from ...structured_formatter import TILE_COORDINATE_NAMES


Expand Down
9 changes: 5 additions & 4 deletions starfish/core/experiment/builder/test/test_inplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
from skimage.io import imsave
from slicedimage import ImageFormat

from starfish.core.experiment.builder import FetchedTile, TileFetcher, write_experiment_json
from starfish.core.experiment.builder.inplace import (
from starfish.core.types import Axes, Coordinates, CoordinateValue
from ..builder import write_experiment_json
from ..inplace import (
InplaceFetchedTile, InplaceWriterContract,
)
from starfish.core.experiment.experiment import Experiment, FieldOfView
from starfish.core.types import Axes, Coordinates, CoordinateValue
from ..providers import FetchedTile, TileFetcher
from ...experiment import Experiment, FieldOfView


SHAPE = {Axes.Y: 500, Axes.X: 1390}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from starfish.core.experiment.builder.orderediterator import ordered_iterator
from starfish.core.types import Axes
from ..orderediterator import ordered_iterator


def test_round_then_ch():
Expand Down
2 changes: 1 addition & 1 deletion starfish/core/experiment/builder/test/test_small_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from starfish.core.types import Coordinates, CoordinateValue
from .factories.all_purpose import collection_factory
from .factories.unique_tiles import UniqueTiles
from .. import TileIdentifier
from ..builder import TileIdentifier


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion starfish/core/imagestack/test/factories/all_purpose.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Callable, Collection, Mapping, Optional, Sequence, Tuple, Type

from starfish.core.experiment.builder import TileIdentifier
from starfish.core.experiment.builder.builder import TileIdentifier
from starfish.core.experiment.builder.test.factories.all_purpose import (
collection_factory,
LocationAwareFetchedTile,
Expand Down
3 changes: 2 additions & 1 deletion starfish/core/imagestack/test/factories/synthetic_stack.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from starfish.core.experiment.builder import build_image, TileFetcher
from starfish.core.experiment.builder.builder import build_image
from starfish.core.experiment.builder.defaultproviders import OnesTile, tile_fetcher_factory
from starfish.core.experiment.builder.providers import TileFetcher
from starfish.core.imagestack.imagestack import ImageStack
from starfish.core.types import Axes

Expand Down
3 changes: 2 additions & 1 deletion starfish/core/imagestack/test/test_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import numpy as np
from slicedimage import ImageFormat

from starfish.core.experiment.builder import FetchedTile, tile_fetcher_factory
from starfish.core.experiment.builder.builder import tile_fetcher_factory
from starfish.core.experiment.builder.providers import FetchedTile
from starfish.types import Axes, Coordinates, CoordinateValue
from .factories import synthetic_stack
from .imagestack_test_utils import verify_physical_coordinates
Expand Down
2 changes: 1 addition & 1 deletion starfish/core/imagestack/test/test_slicedimage_dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from slicedimage import ImageFormat

from starfish.core.errors import DataFormatWarning
from starfish.core.experiment.builder import FetchedTile, TileFetcher
from starfish.core.experiment.builder.providers import FetchedTile, TileFetcher
from starfish.core.types import Axes, Coordinates, CoordinateValue
from .factories import synthetic_stack

Expand Down
8 changes: 3 additions & 5 deletions starfish/core/test/test_multiprocessing_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

from slicedimage import ImageFormat

from starfish.core.experiment.builder import (
tile_fetcher_factory,
TileFetcher,
TileIdentifier,
)
from starfish.core.experiment.builder.builder import TileIdentifier
from starfish.core.experiment.builder.defaultproviders import tile_fetcher_factory
from starfish.core.experiment.builder.providers import TileFetcher
from starfish.core.experiment.builder.structured_formatter import format_structured_dataset
from starfish.core.experiment.builder.test.structured_formatter.util import (
render_coordinates_to_rows,
Expand Down
4 changes: 2 additions & 2 deletions starfish/experiment/builder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from starfish.core.experiment.builder import ( # noqa: F401
from starfish.core.experiment.builder import inplace # noqa: F401
from starfish.core.experiment.builder.builder import ( # noqa: F401
build_image,
build_irregular_image,
inplace,
TileIdentifier,
write_experiment_json,
write_irregular_experiment_json,
Expand Down

0 comments on commit 99a7f43

Please sign in to comment.