Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experiments: add state cleanup for deleted experiments #2611

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions artiq/dashboard/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,25 @@ async def open_file(self, file):
self.open_experiments[expurl].close()
self.open_experiment(expurl)

def cleanup_state(self):
attributes = [
"submission_scheduling",
"submission_options",
"submission_arguments",
"argument_ui_names",
"dock_states",
"colors"
]
for attr in attributes:
state_dict = getattr(self, attr)
for expurl in list(state_dict.keys()):
# Only clean up state for repository-managed experiments
# as file-based experiments are not tracked in explist
if expurl[:5] == "repo:" and expurl[5:] not in self.explist:
if expurl in self.open_experiments:
self.open_experiments[expurl].close()
Comment on lines +717 to +718
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you delete the state of an experiment if it's open?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this code is likely never called? See:

    def restore_state(self, state):
        if self.open_experiments:
            raise NotImplementedError
   ...

del state_dict[expurl]

def save_state(self):
for expurl, dock in self.open_experiments.items():
self.dock_states[expurl] = dock.save_state()
Expand All @@ -719,8 +738,10 @@ def restore_state(self, state):
self.submission_options = state["options"]
self.submission_arguments = state["arguments"]
self.argument_ui_names = state.get("argument_uis", {})
self.colors = state.get("colors", {})
for expurl in state["open_docks"]:
self.open_experiment(expurl)
self.cleanup_state()

def show_quick_open(self):
if self.is_quick_open_shown:
Expand Down