Skip to content

Commit

Permalink
click: implement option subclass (see #808) (#809)
Browse files Browse the repository at this point in the history
* click: implement option subclass (see #808)

* Fix rebase conflicted import

* cli: add explicit tests

Note: BlobDetector is not being printed due to the new decorator.

* click: add workaround for explicit help

* click: properly dispatch to deepest subcommand

* ws: unwrap doc to ~100

* Minor test adjustments

* click: move all to `starfish.util.click`

* click: handle parse_results bottom-out

* Update help text test for origin/master

* Simplify help tests
  • Loading branch information
joshmoore committed Dec 20, 2018
1 parent 27b3700 commit 7034bc5
Show file tree
Hide file tree
Showing 33 changed files with 167 additions and 48 deletions.
2 changes: 1 addition & 1 deletion examples/format_osmfish.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import re
from typing import Mapping, Tuple, Union

import click
import numpy as np
from slicedimage import ImageFormat

import starfish.util.try_import
from starfish.experiment.builder import FetchedTile, TileFetcher, write_experiment_json
from starfish.types import Coordinates, Features, Indices, Number
from starfish.util import click


# We use this to cache images across tiles. In the case of the osmFISH data set, volumes are saved
Expand Down
2 changes: 1 addition & 1 deletion examples/get_imc_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import os
from typing import List, Mapping, Tuple, Union

import click
import numpy as np
from skimage.io import imread
from slicedimage import ImageFormat

from starfish.experiment.builder import FetchedTile, TileFetcher, write_experiment_json
from starfish.types import Coordinates, Features, Indices, Number
from starfish.util import click


class ImagingMassCytometryTile(FetchedTile):
Expand Down
3 changes: 1 addition & 2 deletions sptx_format/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import click

from sptx_format import validate_sptx
from starfish.util import click


@click.command()
Expand Down
2 changes: 1 addition & 1 deletion sptx_format/validate_sptx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import sys
from typing import Dict

import click
from pkg_resources import resource_filename
from slicedimage.io import resolve_path_or_url

from starfish.config import StarfishConfig
from starfish.util import click
from .util import SpaceTxValidator


Expand Down
2 changes: 1 addition & 1 deletion starfish/experiment/builder/cli.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import json

import click
from slicedimage import ImageFormat

from starfish.types import Indices
from starfish.util import click
from . import AUX_IMAGE_NAMES, write_experiment_json


Expand Down
3 changes: 1 addition & 2 deletions starfish/image/_filter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Type

import click

from starfish.imagestack.imagestack import ImageStack
from starfish.pipeline import AlgorithmBase, import_all_submodules, PipelineComponent
from starfish.util import click
from . import _base
import_all_submodules(__file__, __package__)

Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_filter/bandpass.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from functools import partial
from typing import Optional

import click
import numpy as np
from trackpy import bandpass

from starfish.imagestack.imagestack import ImageStack
from starfish.types import Number
from starfish.util import click
from ._base import FilterAlgorithmBase
from .util import determine_axes_to_group_by, preserve_float_range

Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_filter/clip.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from functools import partial
from typing import Optional

import click
import numpy as np

from starfish.imagestack.imagestack import ImageStack
from starfish.util import click
from ._base import FilterAlgorithmBase
from .util import determine_axes_to_group_by

Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_filter/gaussian_high_pass.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from functools import partial
from typing import Callable, Optional, Tuple, Union

import click
import numpy as np
import xarray as xr

from starfish.image._filter.gaussian_low_pass import GaussianLowPass
from starfish.imagestack.imagestack import ImageStack
from starfish.types import Number
from starfish.util import click
from ._base import FilterAlgorithmBase
from .util import (
determine_axes_to_group_by,
Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_filter/gaussian_low_pass.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from functools import partial
from typing import Callable, Optional, Tuple, Union

import click
import numpy as np
from skimage.filters import gaussian

from starfish.imagestack.imagestack import ImageStack
from starfish.types import Number
from starfish.util import click
from ._base import FilterAlgorithmBase
from .util import (
determine_axes_to_group_by,
Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_filter/laplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from functools import partial
from typing import Callable, Optional, Tuple, Union

import click
import numpy as np
from scipy.ndimage import gaussian_laplace

Expand All @@ -14,6 +13,7 @@
)
from starfish.imagestack.imagestack import ImageStack
from starfish.types import Number
from starfish.util import click


class Laplace(FilterAlgorithmBase):
Expand Down
3 changes: 1 addition & 2 deletions starfish/image/_filter/max_proj.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Optional

import click

from starfish.imagestack.imagestack import ImageStack
from starfish.types import Indices
from starfish.util import click
from ._base import FilterAlgorithmBase


Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_filter/mean_high_pass.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from functools import partial
from typing import Callable, Optional, Tuple, Union

import click
import numpy as np
from scipy.ndimage.filters import uniform_filter

from starfish.imagestack.imagestack import ImageStack
from starfish.types import Number
from starfish.util import click
from ._base import FilterAlgorithmBase
from .util import (
determine_axes_to_group_by, preserve_float_range, validate_and_broadcast_kernel_size
Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_filter/richardson_lucy_deconvolution.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from functools import partial
from typing import Optional

import click
import numpy as np
from scipy.signal import convolve, fftconvolve

from starfish.imagestack.imagestack import ImageStack
from starfish.types import Indices, Number
from starfish.util import click
from ._base import FilterAlgorithmBase
from .util import gaussian_kernel, preserve_float_range

Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_filter/scale_by_percentile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from functools import partial
from typing import Optional

import click
import numpy as np

from starfish.imagestack.imagestack import ImageStack
from starfish.util import click
from ._base import FilterAlgorithmBase
from .util import determine_axes_to_group_by, preserve_float_range

Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_filter/white_tophat.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Optional

import click
import numpy as np
from skimage.morphology import ball, disk, white_tophat

from starfish.imagestack.imagestack import ImageStack
from starfish.util import click
from ._base import FilterAlgorithmBase
from .util import determine_axes_to_group_by

Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_filter/zero_by_channel_magnitude.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from copy import deepcopy
from typing import Optional

import click
import numpy as np
from tqdm import tqdm

from starfish.config import StarfishConfig
from starfish.imagestack.imagestack import ImageStack
from starfish.types import Indices
from starfish.util import click
from ._base import FilterAlgorithmBase


Expand Down
3 changes: 1 addition & 2 deletions starfish/image/_registration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Type

import click

from starfish.imagestack.imagestack import ImageStack
from starfish.pipeline import AlgorithmBase, import_all_submodules, PipelineComponent
from starfish.util import click
from . import _base
import_all_submodules(__file__, __package__)

Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_registration/fourier_shift.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from copy import deepcopy
from typing import Optional, Tuple, Union

import click
import numpy as np
from scipy.ndimage import fourier_shift
from skimage.feature import register_translation

from starfish.image._filter.util import preserve_float_range
from starfish.imagestack.imagestack import ImageStack
from starfish.types import Indices
from starfish.util import click
from ._base import RegistrationAlgorithmBase


Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_segmentation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Type

import click
from skimage.io import imsave

from starfish.imagestack.imagestack import ImageStack
from starfish.pipeline import AlgorithmBase, import_all_submodules, PipelineComponent
from starfish.util import click
from . import _base
import_all_submodules(__file__, __package__)

Expand Down
2 changes: 1 addition & 1 deletion starfish/image/_segmentation/watershed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Optional, Tuple

import click
import numpy as np
import scipy.ndimage.measurements as spm
from scipy.ndimage import distance_transform_edt
Expand All @@ -11,6 +10,7 @@
from starfish.image._filter.util import bin_open, bin_thresh
from starfish.imagestack.imagestack import ImageStack
from starfish.types import Indices, Number
from starfish.util import click
from ._base import SegmentationAlgorithmBase


Expand Down
3 changes: 1 addition & 2 deletions starfish/spots/_decoder/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from typing import Type

import click

from starfish.codebook.codebook import Codebook
from starfish.intensity_table.intensity_table import IntensityTable
from starfish.pipeline import AlgorithmBase, import_all_submodules, PipelineComponent
from starfish.util import click
from . import _base

import_all_submodules(__file__, __package__)
Expand Down
3 changes: 1 addition & 2 deletions starfish/spots/_decoder/per_round_max_channel_decoder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import click

from starfish.codebook.codebook import Codebook
from starfish.intensity_table.intensity_table import IntensityTable
from starfish.util import click
from ._base import DecoderAlgorithmBase


Expand Down
3 changes: 1 addition & 2 deletions starfish/spots/_detector/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from typing import Type

import click

from starfish.codebook.codebook import Codebook
from starfish.imagestack.imagestack import ImageStack
from starfish.pipeline import AlgorithmBase, import_all_submodules, PipelineComponent
from starfish.types import Indices
from starfish.util import click
from . import _base

import_all_submodules(__file__, __package__)
Expand Down
2 changes: 1 addition & 1 deletion starfish/spots/_detector/blob.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Optional, Union

import click
import numpy as np
import pandas as pd
import xarray as xr
Expand All @@ -9,6 +8,7 @@
from starfish.imagestack.imagestack import ImageStack
from starfish.intensity_table.intensity_table import IntensityTable
from starfish.types import Features, Indices, Number, SpotAttributes
from starfish.util import click
from ._base import SpotFinderAlgorithmBase
from .detect import detect_spots, measure_spot_intensity

Expand Down
2 changes: 1 addition & 1 deletion starfish/spots/_detector/local_max_peak_finder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import List, Optional, Tuple, Union

import click
import numpy as np
import pandas as pd
import xarray as xr
Expand All @@ -14,6 +13,7 @@
from starfish.imagestack.imagestack import ImageStack
from starfish.intensity_table.intensity_table import IntensityTable
from starfish.types import Features, Indices, Number, SpotAttributes
from starfish.util import click
from ._base import SpotFinderAlgorithmBase
from .detect import detect_spots

Expand Down
2 changes: 1 addition & 1 deletion starfish/spots/_detector/pixel_spot_detector.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Tuple

import click
import numpy as np

from starfish.codebook.codebook import Codebook
from starfish.imagestack.imagestack import ImageStack
from starfish.intensity_table.intensity_table import IntensityTable
from starfish.util import click
from ._base import SpotFinderAlgorithmBase
from .combine_adjacent_features import CombineAdjacentFeatures, ConnectedComponentDecodingResult

Expand Down
2 changes: 1 addition & 1 deletion starfish/spots/_detector/trackpy_local_max_peak_finder.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import warnings
from typing import Optional, Tuple, Union

import click
import numpy as np
import xarray as xr
from trackpy import locate

from starfish.imagestack.imagestack import ImageStack
from starfish.intensity_table.intensity_table import IntensityTable
from starfish.types import SpotAttributes
from starfish.util import click
from ._base import SpotFinderAlgorithmBase
from .detect import detect_spots

Expand Down
2 changes: 1 addition & 1 deletion starfish/spots/_target_assignment/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
from typing import Type

import click
from skimage.io import imread

from starfish.intensity_table.intensity_table import IntensityTable
from starfish.pipeline import AlgorithmBase, PipelineComponent
from starfish.util import click
from . import label
from ._base import TargetAssignmentAlgorithm

Expand Down
2 changes: 1 addition & 1 deletion starfish/spots/_target_assignment/label.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click
import numpy as np

from starfish.intensity_table.intensity_table import IntensityTable
from starfish.types import Features, Indices
from starfish.util import click
from ._base import TargetAssignmentAlgorithm


Expand Down
Loading

0 comments on commit 7034bc5

Please sign in to comment.