Skip to content

Commit 0d3fe54

Browse files
Gui update (#458)
* update cli to take one position, update apply inv tranf one to position to cli and comment slurm * fixes for GUI fixes to make the GUI compatible with updated libs reworked client/server socket setup for propagating CLI progress * git merge * Update utils.py * Update compute_transfer_function.py * Update apply_inverse_transfer_function.py * fixes - formatting, jobs_mgmt bug * test run needs to wait since CLI is running in a separate thread, assert for file check needs to wait. for now we are using 60s for the reconstruction to finish * test case for client/server socket., formatting - implemented client/server feedback strategy to test case - formatting * test_cli_apply_inv_tf_output fix test_cli_apply_inv_tf_output seems to do an assert check on captured text. implemented an output from the client/server strategy * test_cli_apply_inv_tf_output text out * re-worked jobs management/implementation - removed client/server sockets implementation - process are now managed by subprocess for updating GUI - removed extraneous code from CLI related to sockets implementation/jobs mgmt * Update tab_recon.py fix import / styling * Update tab_recon.py - expand first model by default * Update tab_recon.py - styling * Update tab_recon.py Updated comments, removed commented out code * revert CLI to original, etc. --------- Co-authored-by: Taylla Theodoro <[email protected]>
1 parent b4f5d6a commit 0d3fe54

File tree

11 files changed

+222
-1091
lines changed

11 files changed

+222
-1091
lines changed

tests/cli_tests/test_reconstruct.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def test_append_channel_reconstruction(tmp_input_path_zarr):
140140
utils.model_to_yaml(fluor_settings, fluor_config_path)
141141

142142
# Apply birefringence reconstruction
143+
143144
runner = CliRunner()
144145
runner.invoke(
145146
cli,
@@ -151,14 +152,17 @@ def test_append_channel_reconstruction(tmp_input_path_zarr):
151152
str(biref_config_path),
152153
"-o",
153154
str(output_path),
155+
"-uid",
156+
str("birefringence_reconstruction"),
154157
],
155158
catch_exceptions=False,
156159
)
160+
157161
assert output_path.exists()
158162
with open_ome_zarr(output_path) as dataset:
159163
assert dataset["0/0/0"]["0"].shape[1] == 4
160164

161-
# Append fluoresncence reconstruction
165+
# Append fluorescence reconstruction
162166
runner.invoke(
163167
cli,
164168
[
@@ -169,10 +173,14 @@ def test_append_channel_reconstruction(tmp_input_path_zarr):
169173
str(fluor_config_path),
170174
"-o",
171175
str(output_path),
176+
"-uid",
177+
str("fluorescence_reconstruction"),
172178
],
173179
catch_exceptions=False,
174180
)
181+
175182
assert output_path.exists()
183+
176184
with open_ome_zarr(output_path) as dataset:
177185
assert dataset["0/0/0"]["0"].shape[1] == 5
178186
assert dataset.channel_names[-1] == "GFP_Density3D"

waveorder/acq/acquisition_workers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,6 @@ def _reconstruct(self):
598598
transfer_function_dirpath=transfer_function_path,
599599
config_filepath=self.config_path,
600600
output_dirpath=reconstruction_path,
601-
unique_id="waveorderAcq",
602601
)
603602

604603
# Read reconstruction to pass to emitters

waveorder/cli/apply_inverse_transfer_function.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
import torch.multiprocessing as mp
1010
from iohub import open_ome_zarr
1111

12-
from waveorder.cli import apply_inverse_models, jobs_mgmt
12+
from waveorder.cli import apply_inverse_models
1313
from waveorder.cli.parsing import (
1414
config_filepath,
1515
input_position_dirpaths,
1616
output_dirpath,
1717
processes_option,
1818
transfer_function_dirpath,
19+
unique_id,
1920
)
2021
from waveorder.cli.printing import echo_headline, echo_settings
2122
from waveorder.cli.settings import ReconstructionSettings
@@ -25,8 +26,6 @@
2526
)
2627
from waveorder.io import utils
2728

28-
JM = jobs_mgmt.JobsManagement()
29-
3029

3130
def _check_background_consistency(
3231
background_shape, data_shape, input_channel_names
@@ -107,6 +106,7 @@ def apply_inverse_transfer_function_single_position(
107106
num_processes,
108107
output_channel_names: list[str],
109108
) -> None:
109+
110110
echo_headline("\nStarting reconstruction...")
111111

112112
# Load datasets
@@ -277,6 +277,7 @@ def apply_inverse_transfer_function_single_position(
277277
output_dataset.zattrs["settings"] = settings.dict()
278278

279279
echo_headline(f"Closing {output_position_dirpath}\n")
280+
280281
output_dataset.close()
281282
transfer_function_dataset.close()
282283
input_dataset.close()

waveorder/cli/compute_transfer_function.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def generate_and_save_birefringence_transfer_function(settings, dataset):
6363

6464

6565
def generate_and_save_phase_transfer_function(
66-
settings: ReconstructionSettings, dataset: Position, zyx_shape: tuple
66+
settings: ReconstructionSettings,
67+
dataset: Position,
68+
zyx_shape: tuple,
6769
):
6870
"""Generates and saves the phase transfer function to the dataset, based on the settings.
6971
@@ -150,7 +152,9 @@ def generate_and_save_phase_transfer_function(
150152

151153

152154
def generate_and_save_fluorescence_transfer_function(
153-
settings: ReconstructionSettings, dataset: Position, zyx_shape: tuple
155+
settings: ReconstructionSettings,
156+
dataset: Position,
157+
zyx_shape: tuple,
154158
):
155159
"""Generates and saves the fluorescence transfer function to the dataset, based on the settings.
156160
@@ -187,7 +191,9 @@ def generate_and_save_fluorescence_transfer_function(
187191

188192

189193
def compute_transfer_function_cli(
190-
input_position_dirpath: Path, config_filepath: Path, output_dirpath: Path
194+
input_position_dirpath: Path,
195+
config_filepath: Path,
196+
output_dirpath: Path,
191197
) -> None:
192198
"""CLI command to compute the transfer function given a configuration file path
193199
and a desired output path.

waveorder/cli/gui_widget.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
pass
1414

1515
try:
16-
import qdarktheme
16+
import qdarktheme # pip install pyqtdarktheme==2.1.0 --ignore-requires-python
1717
except:
1818
pass
1919

@@ -31,7 +31,8 @@ def gui():
3131
) # Other options: "Fusion", "Windows", "macOS", "WindowsVista"
3232
try:
3333
qdarktheme.setup_theme("dark")
34-
except:
34+
except Exception as e:
35+
print(e.args)
3536
pass
3637
window = MainWindow()
3738
window.setWindowTitle(PLUGIN_ICON + " " + PLUGIN_NAME + " " + PLUGIN_ICON)

waveorder/cli/jobs_mgmt.py

Lines changed: 0 additions & 204 deletions
This file was deleted.

waveorder/cli/parsing.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,17 @@ def decorator(f: Callable) -> Callable:
106106
)(f)
107107

108108
return decorator
109+
110+
111+
def unique_id() -> Callable:
112+
def decorator(f: Callable) -> Callable:
113+
return click.option(
114+
"--unique-id",
115+
"-uid",
116+
default="",
117+
required=False,
118+
type=str,
119+
help="Unique ID.",
120+
)(f)
121+
122+
return decorator

waveorder/cli/reconstruct.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
input_position_dirpaths,
1414
output_dirpath,
1515
processes_option,
16+
unique_id,
1617
)
1718

1819

@@ -21,11 +22,13 @@
2122
@config_filepath()
2223
@output_dirpath()
2324
@processes_option(default=1)
25+
@unique_id()
2426
def _reconstruct_cli(
2527
input_position_dirpaths,
2628
config_filepath,
2729
output_dirpath,
2830
num_processes,
31+
unique_id,
2932
):
3033
"""
3134
Reconstruct a dataset using a configuration file. This is a

0 commit comments

Comments
 (0)