Skip to content

Commit

Permalink
Merge branch 'main' into multicellpose-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
christinab12 authored Feb 23, 2024
2 parents 88ed260 + 4c596c4 commit 72397dd
Show file tree
Hide file tree
Showing 18 changed files with 789 additions and 119 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
pip install pytest-xvfb
pip install coverage
pip install -e --no-cache-dir ".[testing]"
pip install matplotlib
working-directory: src/client

- name: Install server dependencies (for communication tests)
Expand Down
24 changes: 15 additions & 9 deletions src/client/dcp_client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ def __init__(
self.inprogr_data_path = inprogr_data_path
self.cur_selected_img = ''
self.cur_selected_path = ''
self.seg_filepaths = []
self.seg_filepaths = []

def upload_data_to_server(self):
"""
Uploads the train and eval data to the server.
"""
self.syncer.first_sync(path=self.train_data_path)
self.syncer.first_sync(path=self.eval_data_path)
success_f1, message1 = self.syncer.first_sync(path=self.train_data_path)
success_f2, message2 = self.syncer.first_sync(path=self.eval_data_path)
return success_f1, success_f2, message1, message2

def try_server_connection(self):
"""
Expand All @@ -89,8 +90,10 @@ def run_train(self):
if self.syncer.host_name=="local":
message_text = self.ml_model.run_train(self.train_data_path)
else:
srv_relative_path = self.syncer.sync(src='client', dst='server', path=self.train_data_path)
message_text = self.ml_model.run_train(srv_relative_path)
success_sync, srv_relative_path = self.syncer.sync(src='client', dst='server', path=self.train_data_path)
# make sure syncing of folders was successful
if success_sync=="Success": message_text = self.ml_model.run_train(srv_relative_path)
else: message_text = None
if message_text is None:
message_text = "An error has occured on the server. Please check your image data and configurations. If the problem persists contact your software provider."
message_title = "Error"
Expand All @@ -105,15 +108,18 @@ def run_inference(self):

if self.syncer.host_name=="local":
# model serving directly from local
list_of_files_not_suported = self.ml_model.run_inference(self.eval_data_path)
list_of_files_not_suported = self.ml_model.run_inference(self.eval_data_path)
success_sync = "Success"
else:
# sync data so that server gets updated files in client - e.g. if file was moved to curated
srv_relative_path = utils.get_relative_path(self.eval_data_path)
success_sync, _ = self.syncer.sync(src='client', dst='server', path=self.eval_data_path)
# model serving from server
list_of_files_not_suported = self.ml_model.run_inference(srv_relative_path)
# sync data so that client gets new masks
_ = self.syncer.sync(src='server', dst='client', path=self.eval_data_path)
success_sync, _ = self.syncer.sync(src='server', dst='client', path=self.eval_data_path)
# check if serving could not be performed for some files and prepare message
if list_of_files_not_suported is None:
if list_of_files_not_suported is None or success_sync=="Error":
message_text = "An error has occured on the server. Please check your image data and configurations. If the problem persists contact your software provider."
message_title = "Error"
else:
Expand Down Expand Up @@ -155,4 +161,4 @@ def delete_images(self, image_names):
if os.path.exists(os.path.join(self.cur_selected_path, image_name)):
self.fs_image_storage.delete_image(self.cur_selected_path, image_name)


8 changes: 4 additions & 4 deletions src/client/dcp_client/config_remote.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"server":{
"user": "ubuntu",
"host": "jusuf-vm2",
"data-path": "/home/ubuntu/dcp-data",
"ip": "134.94.88.74",
"user": "rocky",
"host": "jsc-vm",
"data-path": "/home/rocky/dcp-data/my-project",
"ip": "134.94.198.230",
"port": 7010
}
}
8 changes: 6 additions & 2 deletions src/client/dcp_client/gui/main_window.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations
from typing import TYPE_CHECKING

from PyQt5.QtWidgets import QPushButton, QVBoxLayout, QFileSystemModel, QHBoxLayout, QLabel, QTreeView, QProgressBar
from PyQt5.QtWidgets import QPushButton, QVBoxLayout, QFileSystemModel, QHBoxLayout, QLabel, QTreeView, QProgressBar, QShortcut
from PyQt5.QtCore import Qt, QThread, pyqtSignal
from PyQt5.QtGui import QKeySequence

from dcp_client.utils import settings
from dcp_client.utils.utils import IconProvider
Expand Down Expand Up @@ -117,6 +118,9 @@ def main_window(self):
self.launch_nap_button = QPushButton("View image and fix label", self)
self.launch_nap_button.clicked.connect(self.on_launch_napari_button_clicked) # add selected image
self.inprogress_layout.addWidget(self.launch_nap_button, alignment=Qt.AlignCenter)
# Create a shortcut for the Enter key to click the button
enter_shortcut = QShortcut(QKeySequence(Qt.Key_Return), self)
enter_shortcut.activated.connect(self.on_launch_napari_button_clicked)

dir_layout.addLayout(self.inprogress_layout)

Expand Down Expand Up @@ -212,7 +216,7 @@ def on_launch_napari_button_clicked(self):
_ = self.create_warning_box(message_text, message_title="Warning")
else:
self.nap_win = NapariWindow(self.app)
self.nap_win.show()
self.nap_win.show()

def on_finished(self, result):
'''
Expand Down
Loading

0 comments on commit 72397dd

Please sign in to comment.