Skip to content

Commit

Permalink
Added option to reload task
Browse files Browse the repository at this point in the history
  • Loading branch information
theonlydvr committed Apr 29, 2024
1 parent 38b6a2c commit fa2c385
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions pybehave/Tasks/TaskProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def handle_event(self, event):
def add_task(self, event: PybEvents.AddTaskEvent):
try:
task_module = importlib.import_module("Local.Tasks." + event.task_name)
task_module = importlib.reload(task_module)
task = getattr(task_module, event.task_name)
self.tasks[event.chamber] = task()
self.tasks[event.chamber].initialize(self, event.metadata) # Create the task
Expand Down
2 changes: 2 additions & 0 deletions pybehave/Workstation/ChamberWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ def contextMenuEvent(self, _):
clear_chamber.triggered.connect(lambda: self.wsg.workstation.remove_task(int(self.chamber_id.text()) - 1))
edit_config = menu.addAction("Edit Configuration") # Edits the Task configuration
edit_config.triggered.connect(self.edit_configuration)
refresh = menu.addAction("Reload Task")
refresh.triggered.connect(self.refresh)
menu.popup(QCursor.pos())

def save_configuration(self) -> None:
Expand Down
4 changes: 3 additions & 1 deletion pybehave/Workstation/Workstation.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ def update_gui(self) -> None:
events = self.decoder.decode(ready.recv_bytes())
for event in events:
if isinstance(event, PybEvents.AddTaskEvent):
gui = getattr(importlib.import_module("Local.GUIs." + event.task_name + "GUI"), event.task_name + "GUI")
module = importlib.import_module("Local.GUIs." + event.task_name + "GUI")
module = importlib.reload(module)
gui = getattr(module, event.task_name + "GUI")
# Position the GUI in pygame
col = event.chamber % self.n_col
row = math.floor(event.chamber / self.n_col)
Expand Down

0 comments on commit fa2c385

Please sign in to comment.