Skip to content

Commit

Permalink
comment out cyto_dl for ci
Browse files Browse the repository at this point in the history
  • Loading branch information
yrkim98 committed Jan 23, 2024
1 parent 3d75672 commit e2cfcd9
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ def test_preprocessing_method(
# ASSERT 2
assert file_input_widget._model.get_preprocessing_method() is None

def test_populate_input_channel_combobox(
qtbot: QtBot
) -> None:

def test_populate_input_channel_combobox(qtbot: QtBot) -> None:
# Arrange
prediction_model: PredictionModel = PredictionModel()
prediction_file_input: PredictionFileInput = PredictionFileInput(prediction_model)
prediction_file_input: PredictionFileInput = PredictionFileInput(
prediction_model
)
prediction_model.set_max_channels(6)

# Act
Expand Down
1 change: 1 addition & 0 deletions src/allencell_ml_segmenter/_tests/prediction/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_input_image_paths(prediction_model: PredictionModel) -> None:
# ASSERT
assert prediction_model.get_input_image_dir() == dummy_paths


def test_image_input_channel_index(prediction_model: PredictionModel) -> None:
"""
Tests that the channel index is set and retrieved properly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,30 @@ def test_extract_num_channels_in_a_folder() -> None:
model_file_service: ModelFileService = ModelFileService(prediction_model)

# Act / Assert
assert model_file_service.extract_num_channels_in_folder(Path(allencell_ml_segmenter.__file__).parent / "_tests" / "test_files" / "images") == 3
assert (
model_file_service.extract_num_channels_in_folder(
Path(allencell_ml_segmenter.__file__).parent
/ "_tests"
/ "test_files"
/ "images"
)
== 3
)


def test_extract_num_channels_from_csv() -> None:
# Arrange
prediction_model: PredictionModel = PredictionModel()
model_file_service: ModelFileService = ModelFileService(prediction_model)

# Act / Assert
assert model_file_service.extract_num_channels_from_csv(Path(allencell_ml_segmenter.__file__).parent / "_tests" / "test_files" / "csv" / "test_csv.csv") == 3
assert (
model_file_service.extract_num_channels_from_csv(
Path(allencell_ml_segmenter.__file__).parent
/ "_tests"
/ "test_files"
/ "csv"
/ "test_csv.csv"
)
== 3
)
23 changes: 12 additions & 11 deletions src/allencell_ml_segmenter/prediction/file_input_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ def __init__(self, model: PredictionModel):

self._browse_dir_edit: InputButton = InputButton(
self._model,
lambda dir: self._model.set_input_image_dir(
Path(dir)
),
lambda dir: self._model.set_input_image_dir(Path(dir)),
"Select directory...",
FileInputMode.DIRECTORY_OR_CSV,
)
Expand All @@ -140,13 +138,16 @@ def __init__(self, model: PredictionModel):
self._channel_select_dropdown.setPlaceholderText(
"select a channel index"
)
self._channel_select_dropdown.currentIndexChanged.connect(self._model.set_image_input_channel_index)
self._channel_select_dropdown.currentIndexChanged.connect(
self._model.set_image_input_channel_index
)
self._channel_select_dropdown.setEnabled(False)
# Event to trigger combobox populate on input image directory selection
self._model.subscribe(Event.ACTION_PREDICTION_INPUT_PATH_SELECTED,
self,
self._populate_input_channel_combobox)

self._model.subscribe(
Event.ACTION_PREDICTION_INPUT_PATH_SELECTED,
self,
self._populate_input_channel_combobox,
)

output_dir_label: LabelWithHint = LabelWithHint("Output directory")
output_dir_label.set_hint("Location to save segmentations.")
Expand Down Expand Up @@ -180,8 +181,8 @@ def _from_directory_slot(self) -> None:
self._browse_dir_edit.setEnabled(True)

def _populate_input_channel_combobox(self, event: Event = None) -> None:
values_range: List[str] = [str(i) for i in range(self._model.get_max_channels())]
values_range: List[str] = [
str(i) for i in range(self._model.get_max_channels())
]
self._channel_select_dropdown.addItems(values_range)
self._channel_select_dropdown.setEnabled(True)


15 changes: 8 additions & 7 deletions src/allencell_ml_segmenter/prediction/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def __init__(self, model: PredictionModel):
self._model.subscribe(
Event.ACTION_PREDICTION_EXTRACT_CHANNELS,
self,
lambda e: self._model.set_max_channels(self._determine_input_selection_type(self._model.get_input_image_dir()))
lambda e: self._model.set_max_channels(
self._determine_input_selection_type(
self._model.get_input_image_dir()
)
),
)

def handle_event(self, event: Event) -> None:
Expand All @@ -47,10 +51,10 @@ def extract_num_channels_in_folder(self, path: Path) -> int:
# we expect user to have the same number of channels for all images in their folders
# and that only images are stored in those folders
# Get first image path
path_generator: Generator[Path] = path.glob('*')
path_generator: Generator[Path] = path.glob("*")
first_image: Path = next(path_generator)
# ignore hidden files
while str(first_image.name).split('.')[0] == "":
while str(first_image.name).split(".")[0] == "":
first_image = next(path_generator)

img: AICSImage = AICSImage(str(first_image.resolve()))
Expand All @@ -61,7 +65,7 @@ def extract_num_channels_from_csv(self, path: Path):
reader: csv.reader = csv.reader(file)
# skip heading
next(reader)
line_data_path:str = next(reader)[1]
line_data_path: str = next(reader)[1]
img: AICSImage = AICSImage(str(line_data_path))
return img.dims.C

Expand All @@ -74,6 +78,3 @@ def _determine_input_selection_type(self, path: Path):

# for testing current api
return self.extract_num_channels_from_csv(path / "train.csv")



2 changes: 1 addition & 1 deletion src/allencell_ml_segmenter/services/prediction_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pathlib import Path
from typing import Union, Dict

from cyto_dl.api.model import CytoDLModel
# from cyto_dl.api.model import CytoDLModel
from napari.utils.notifications import show_warning


Expand Down
2 changes: 1 addition & 1 deletion src/allencell_ml_segmenter/services/training_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from allencell_ml_segmenter.core.subscriber import Subscriber
from allencell_ml_segmenter.core.event import Event

from cyto_dl.api.model import CytoDLModel
# from cyto_dl.api.model import CytoDLModel

# from lightning.pytorch.callbacks import Callback

Expand Down

0 comments on commit e2cfcd9

Please sign in to comment.