Skip to content

Commit 09333b0

Browse files
committed
Testing and minor updates
- Run tests on ubuntu - Updated tests - Added Log test and Log init update
1 parent 500c37b commit 09333b0

File tree

8 files changed

+79
-65
lines changed

8 files changed

+79
-65
lines changed
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
#name: napari hub Preview Page # we use this name to find your preview page artifact, so don't change it!
2-
## For more info on this action, see https://github.com/chanzuckerberg/napari-hub-preview-action/blob/main/action.yml
3-
#
4-
#on:
5-
# pull_request:
6-
# branches:
7-
# - 'test' # '**' for all
8-
#
9-
#jobs:
10-
# preview-page:
11-
# name: Preview Page Deploy
12-
# runs-on: ubuntu-latest
13-
#
14-
# steps:
15-
# - name: Checkout repo
16-
# uses: actions/checkout@v2
17-
#
18-
# - name: napari hub Preview Page Builder
19-
# uses: chanzuckerberg/[email protected].5
20-
# with:
21-
# hub-ref: main
1+
name: napari hub Preview Page # we use this name to find your preview page artifact, so don't change it!
2+
# For more info on this action, see https://github.com/chanzuckerberg/napari-hub-preview-action/blob/main/action.yml
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- 'test' # '**' for all
8+
9+
jobs:
10+
preview-page:
11+
name: Preview Page Deploy
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v2
17+
18+
- name: napari hub Preview Page Builder
19+
uses: chanzuckerberg/[email protected].6
20+
with:
21+
hub-ref: main

.github/workflows/test_and_deploy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ jobs:
2424
strategy:
2525
matrix:
2626
# platform: [ubuntu-latest, windows-latest, macos-latest]
27-
platform: [windows-latest]
28-
python-version: [3.8, 3.9, "3.10"]
27+
platform: [ubuntu-latest]
28+
python-version: [3.8, 3.9, 3.10]
2929

3030
steps:
3131
- uses: actions/checkout@v2
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from napari_cellseg3d.interface import Log
2+
3+
def test_log(qtbot):
4+
log = Log()
5+
log.print_and_log("test")
6+
7+
assert log.toPlainText() == "\ntest"
8+
9+
log.replace_last_line("test2")
10+
11+
assert log.toPlainText() == "\ntest2"
12+
13+
qtbot.add_widget(log)

napari_cellseg3d/_tests/test_plugin_inference.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def test_inference(make_napari_viewer, qtbot):
2626

2727
assert widget.check_ready()
2828

29-
# widget.start() # takes too long on Github Actions (~30min)
30-
# assert widget.worker is not None
31-
#
32-
# with qtbot.waitSignal(signal=widget.worker.finished) as blocker:
33-
# blocker.connect(widget.worker.errored)
34-
#
29+
widget.start() # takes too long on Github Actions (~30min)
30+
assert widget.worker is not None
31+
32+
with qtbot.waitSignal(signal=widget.worker.finished, timeout=60000, raising=False) as blocker:
33+
blocker.connect(widget.worker.errored)
34+
3535
# assert len(viewer.layers) == 2

napari_cellseg3d/_tests/test_training.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@ def test_training(make_napari_viewer, qtbot):
2222

2323
widget.images_filepaths = [im_path]
2424
widget.labels_filepaths = [im_path]
25+
widget.epoch_choice.setValue(1)
2526

2627
assert widget.check_ready()
2728

2829
#################
2930
# Training is too long to test properly this way. Do not use on Github
3031
#################
3132

32-
# widget.start()
33-
# assert widget.worker is not None
34-
#
35-
# with qtbot.waitSignal(signal=widget.worker.finished, timeout=60000) as blocker: # wait only for 60 seconds.
36-
# blocker.connect(widget.worker.errored)
33+
widget.start()
34+
assert widget.worker is not None
35+
36+
with qtbot.waitSignal(signal=widget.worker.finished, timeout=60000, raising=False) as blocker: # wait only for 60 seconds.
37+
blocker.connect(widget.worker.errored)
3738

3839

3940
def test_update_loss_plot(make_napari_viewer):

napari_cellseg3d/interface.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def show_utils_menu(self, widget, event):
208208
class Log(QTextEdit):
209209
"""Class to implement a log for important user info. Should be thread-safe."""
210210

211-
def __init__(self, parent):
211+
def __init__(self, parent=None):
212212
"""Creates a log with a lock for multithreading
213213
214214
Args:
@@ -223,31 +223,31 @@ def __init__(self, parent):
223223

224224
# def receive_log(self, text):
225225
# self.print_and_log(text)
226-
def write(self, message):
227-
"""
228-
Write message to log in a thread-safe manner
229-
Args:
230-
message: string to be printed
231-
"""
232-
self.lock.acquire()
233-
try:
234-
if not hasattr(self, "flag"):
235-
self.flag = False
236-
message = message.replace("\r", "").rstrip()
237-
if message:
238-
method = "replace_last_line" if self.flag else "append"
239-
QtCore.QMetaObject.invokeMethod(
240-
self,
241-
method,
242-
QtCore.Qt.QueuedConnection,
243-
QtCore.Q_ARG(str, message),
244-
)
245-
self.flag = True
246-
else:
247-
self.flag = False
248-
249-
finally:
250-
self.lock.release()
226+
# def write(self, message):
227+
# """
228+
# Write message to log in a thread-safe manner
229+
# Args:
230+
# message: string to be printed
231+
# """
232+
# self.lock.acquire()
233+
# try:
234+
# if not hasattr(self, "flag"):
235+
# self.flag = False
236+
# message = message.replace("\r", "").rstrip()
237+
# if message:
238+
# method = "replace_last_line" if self.flag else "append"
239+
# QtCore.QMetaObject.invokeMethod(
240+
# self,
241+
# method,
242+
# QtCore.Qt.QueuedConnection,
243+
# QtCore.Q_ARG(str, message),
244+
# )
245+
# self.flag = True
246+
# else:
247+
# self.flag = False
248+
#
249+
# finally:
250+
# self.lock.release()
251251

252252
@QtCore.Slot(str)
253253
def replace_last_line(self, text):

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ install_requires =
5050
tifffile>=2022.2.9
5151
imageio-ffmpeg>=0.4.5
5252
torch>=1.11
53-
monai[nibabel,scikit-image,itk,einops]>=0.9.0
53+
monai[nibabel,itk,einops]>=0.9.0
5454
tqdm
5555
nibabel
5656
scikit-image

tox.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ python =
99

1010
[gh-actions:env]
1111
PLATFORM =
12-
; ubuntu-latest: linux
12+
ubuntu-latest: linux
1313
; macos-latest: macos
14-
windows-latest: windows
14+
; windows-latest: windows
1515

1616
[testenv]
1717
platform =
18+
linux: linux
1819
; macos: darwin
19-
; linux: linux
20-
windows: win32
20+
; windows: win32
2121
passenv =
2222
CI
2323
PYTHONPATH

0 commit comments

Comments
 (0)