Skip to content

Commit

Permalink
Run github actiosns CI tests on Windows, Mac and Linux (#267)
Browse files Browse the repository at this point in the history
Add CI for windows and mac

---------

Co-authored-by: Constantin Pape <[email protected]>
  • Loading branch information
GenevieveBuckley and constantinpape authored Nov 18, 2023
1 parent d427e9f commit 5546343
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10"]

steps:
Expand Down
4 changes: 4 additions & 0 deletions micro_sam/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ def _get_checkpoint(model_type, checkpoint_path=None):


def _get_default_device():
# check that we're in CI and use the CPU if we are
# otherwise the tests may run out of memory on MAC if MPS is used.
if os.getenv("GITHUB_ACTIONS") == "true":
return "cpu"
# Use cuda enabled gpu if it's available.
if torch.cuda.is_available():
device = "cuda"
Expand Down
1 change: 0 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
coverage
line-profiler
memray
napari[all]
pdoc
pytest
Expand Down
3 changes: 3 additions & 0 deletions test/test_gui.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import platform

import numpy as np
import pytest

Expand All @@ -20,6 +22,7 @@ def _check_layer_initialization(viewer):


@pytest.mark.gui
@pytest.mark.skipif(platform.system() == "Windows", reason="Gui test is not working on windows.")
def test_annotator_2d(make_napari_viewer_proxy, tmp_path):
"""Integration test for annotator_2d widget with automatic mask generation.
Expand Down
2 changes: 1 addition & 1 deletion test/test_instance_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def write_object(center, radius):

@staticmethod
def _get_model(image, model_type):
predictor = util.get_sam_model(model_type=model_type)
predictor = util.get_sam_model(model_type=model_type, device=util._get_device(None))
image_embeddings = util.precompute_image_embeddings(predictor, image)
return predictor, image_embeddings

Expand Down
2 changes: 1 addition & 1 deletion test/test_prompt_based_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _get_input(shape=(256, 256)):

@staticmethod
def _get_model(image, model_type):
predictor = util.get_sam_model(model_type=model_type)
predictor = util.get_sam_model(model_type=model_type, device=util._get_device(None))
image_embeddings = util.precompute_image_embeddings(predictor, image)
util.set_precomputed(predictor, image_embeddings)
return predictor
Expand Down

0 comments on commit 5546343

Please sign in to comment.