Skip to content

Commit

Permalink
TrainingModel composes ExperimentsModel
Browse files Browse the repository at this point in the history
  • Loading branch information
hughes036 committed Oct 4, 2023
1 parent 0f415f5 commit 0968b85
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from allencell_ml_segmenter.core.event import Event


class FakeExperimentModel(IExperimentsModel):
class FakeExperimentsModel(IExperimentsModel):
def __init__(self):
self._experiment_name = None
self._checkpoint = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from allencell_ml_segmenter.training.training_model import (
TrainingModel,
)
from allencell_ml_segmenter._tests.fakes.fake_experiments_model import FakeExperimentsModel


@pytest.fixture
Expand All @@ -20,7 +21,7 @@ def training_service() -> TrainingService:
Returns a TrainingService object with arbitrary-set fields in the model for testing.
"""
experiments_model = ExperimentsModel(CytoDlConfig(Path(), Path()))
training_model: TrainingModel = TrainingModel(MainModel())
training_model: TrainingModel = TrainingModel(MainModel(), FakeExperimentsModel())
training_model.set_experiment_type("segmentation")
training_model.set_hardware_type("cpu")
training_model.set_image_dims(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from qtpy.QtCore import Qt
from pytestqt.qtbot import QtBot
from allencell_ml_segmenter.main.main_model import MainModel
from allencell_ml_segmenter._tests.fakes.fake_experiments_model import FakeExperimentsModel

from allencell_ml_segmenter.training.image_selection_widget import (
ImageSelectionWidget,
Expand All @@ -22,7 +23,7 @@ def training_model() -> TrainingModel:
"""
Fixture that creates an instance of TrainingModel for testing.
"""
return TrainingModel(MainModel())
return TrainingModel(MainModel(), FakeExperimentsModel())


@pytest.fixture
Expand Down
3 changes: 2 additions & 1 deletion src/allencell_ml_segmenter/_tests/training/test_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from pathlib import Path
from allencell_ml_segmenter._tests.fakes.fake_experiments_model import FakeExperimentsModel
from allencell_ml_segmenter.main.main_model import MainModel

from allencell_ml_segmenter.training.training_model import (
Expand All @@ -15,7 +16,7 @@ def training_model() -> TrainingModel:
"""
Returns a TrainingModel instance for testing.
"""
return TrainingModel(MainModel())
return TrainingModel(MainModel(), FakeExperimentsModel())


def test_get_experiment_type(training_model: TrainingModel) -> None:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from pytestqt.qtbot import QtBot
from allencell_ml_segmenter._tests.fakes.fake_experiments_model import (
FakeExperimentModel,
FakeExperimentsModel,
)
from allencell_ml_segmenter.main.i_experiments_model import IExperimentsModel
from allencell_ml_segmenter.main.main_model import MainModel
Expand All @@ -12,11 +12,12 @@
from allencell_ml_segmenter.training.training_model import (
TrainingModel,
)
from allencell_ml_segmenter._tests.fakes.fake_experiments_model import FakeExperimentsModel


@pytest.fixture
def experiment_model() -> IExperimentsModel:
return FakeExperimentModel()
return FakeExperimentsModel()


@pytest.fixture
Expand All @@ -25,7 +26,7 @@ def training_model() -> TrainingModel:
Fixture that creates an instance of TrainingModel for testing.
"""
return TrainingModel( # instead of this, how about i mock os.listdir ?
MainModel()
MainModel(), FakeExperimentsModel()
)


Expand Down

0 comments on commit 0968b85

Please sign in to comment.