Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ptychozoon = ["ptychozoon"]
[tool.uv.sources]
#ptychi = { path = "../pty-chi", editable = true }
#ptychopinn = { path = "../PtychoPINN", editable = true }
ptychopinn = { git = "https://github.com/hoidn/PtychoPINN", branch = "main" }
#ptychopinn = { git = "https://github.com/hoidn/PtychoPINN", branch = "main" }

#[[tool.uv.index]]
#name = "pytorch-cu132"
Expand Down
2 changes: 1 addition & 1 deletion src/ptychodus/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def main() -> int:

from ptychodus.view import ViewCore

view = ViewCore()
view = ViewCore(is_developer_mode_enabled=model.is_developer_mode_enabled)

from ptychodus.controller import ControllerCore

Expand Down
2 changes: 2 additions & 0 deletions src/ptychodus/api/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def register_plugin(self, strategy: T, *, display_name: str, simple_name: str =

def get_current_plugin(self) -> Plugin[T]:
"""Return the currently selected plugin."""
if not self._registered_plugins:
raise LookupError('No plugins registered')
return self._registered_plugins[self._current_index]

def set_current_plugin(self, name: str) -> None:
Expand Down
30 changes: 16 additions & 14 deletions src/ptychodus/controller/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,16 @@ def __init__(
view.product_view,
self._file_dialog_factory,
)
self._product_visualization_controller = ProductVisualizationController(
model.analysis_core.residual_analyzer,
model.analysis_core.residual_real_space_visualization_engine,
model.analysis_core.residual_reciprocal_space_visualization_engine,
self._product_controller,
view.product_visualization_view,
self._status_bar,
self._file_dialog_factory,
)
if is_developer_mode_enabled:
self._product_visualization_controller = ProductVisualizationController(
model.analysis_core.residual_analyzer,
model.analysis_core.residual_real_space_visualization_engine,
model.analysis_core.residual_reciprocal_space_visualization_engine,
self._product_controller,
view.product_visualization_view,
self._status_bar,
self._file_dialog_factory,
)
self._probe_positions_controller = ProbePositionsController(
model.product_core.probe_positions_repository,
model.product_core.probe_positions_api,
Expand Down Expand Up @@ -209,7 +210,7 @@ def __init__(
view.genesis_action: model.genesis_core.is_supported,
}

self._swap_central_widgets(view.patterns_action)
self._swap_central_widgets(view.patterns_action, animated=False)
view.patterns_action.setChecked(True)
view.navigation.action_group.triggered.connect(
lambda action: self._swap_central_widgets(action)
Expand All @@ -222,19 +223,20 @@ def show_main_window(self, window_title: str) -> None:
self.view.setWindowTitle(window_title)
self.view.show()

def _swap_central_widgets(self, action: QAction | None) -> None:
def _swap_central_widgets(self, action: QAction | None, *, animated: bool = True) -> None:
if action is None:
raise ValueError('QAction is None!')

self.view.navigation.set_current_index(action.data())
self._update_subview_visibility(action)
self._update_subview_visibility(action, animated=animated)

def _update_subview_visibility(self, action: QAction) -> None:
def _update_subview_visibility(self, action: QAction, *, animated: bool = True) -> None:
for group in self.view.navigation.subview_groups:
expanded = action is group.parent_action or action in group.child_actions
for child in group.child_actions:
allowed = self._action_permitted.get(child, True)
child.setVisible(expanded and allowed)
group.container.set_child_button_visible(child, allowed)
group.container.set_expanded(expanded, animated=animated)
group.top_separator.setVisible(expanded)
group.bottom_separator.setVisible(expanded)

Expand Down
32 changes: 28 additions & 4 deletions src/ptychodus/model/genesis/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,38 +102,59 @@ def supported_transfer_clients(self) -> Sequence[str]:
return [plugin.display_name for plugin in self._transfer_client_chooser]

def refresh_projects(self) -> None:
if not self._facility_chooser:
logger.debug('refresh_projects: no facility adapter registered; skipping')
return
facility_adapter = self._facility_chooser.get_current_plugin().strategy
facility_adapter.refresh_projects()

def supported_projects(self) -> Sequence[str]:
if not self._facility_chooser:
return []
facility_adapter = self._facility_chooser.get_current_plugin().strategy
return facility_adapter.project_names()

def map_project_name_to_id(self, name: str) -> str:
if not self._facility_chooser:
return name
facility_adapter = self._facility_chooser.get_current_plugin().strategy
return facility_adapter.map_project_name_to_id(name)

def map_project_id_to_name(self, project_id: str) -> str:
if not self._facility_chooser:
return project_id
facility_adapter = self._facility_chooser.get_current_plugin().strategy
return facility_adapter.map_project_id_to_name(project_id)

def refresh_compute_resources(self) -> None:
if not self._facility_chooser:
logger.debug('refresh_compute_resources: no facility adapter registered; skipping')
return
facility_adapter = self._facility_chooser.get_current_plugin().strategy
facility_adapter.refresh_compute_resources()

def supported_compute_resources(self) -> Sequence[str]:
if not self._facility_chooser:
return []
facility_adapter = self._facility_chooser.get_current_plugin().strategy
return facility_adapter.compute_resource_names()

def map_compute_resource_name_to_id(self, name: str) -> str:
if not self._facility_chooser:
return name
facility_adapter = self._facility_chooser.get_current_plugin().strategy
return facility_adapter.map_compute_resource_name_to_id(name)

def map_compute_resource_id_to_name(self, resource_id: str) -> str:
if not self._facility_chooser:
return resource_id
facility_adapter = self._facility_chooser.get_current_plugin().strategy
return facility_adapter.map_compute_resource_id_to_name(resource_id)

def apply_facility_defaults(self) -> None:
if not self._facility_chooser:
logger.debug('apply_facility_defaults: no facility adapter registered; skipping')
return
adapter = self._facility_chooser.get_current_plugin().strategy
globus_collection = adapter.get_default_globus_collection()

Expand Down Expand Up @@ -163,10 +184,13 @@ def __init__(
for name, provider in create_globus_transfer_providers().items():
self._transfer_client_chooser.register_plugin(provider, display_name=name)

self._facility_chooser.synchronize_with_parameter(self.settings.facility)
self._transfer_client_chooser.synchronize_with_parameter(
self.settings.globus_transfer_provider
)
if self._facility_chooser:
self._facility_chooser.synchronize_with_parameter(self.settings.facility)

if self._transfer_client_chooser:
self._transfer_client_chooser.synchronize_with_parameter(
self.settings.globus_transfer_provider
)

status_q: queue.Queue[GenesisStatus] = queue.Queue()
self.status_repository = GenesisStatusRepository(status_q)
Expand Down
Loading
Loading