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

387 clean reset of applet state when scan is overwritten #395

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

pmldrmota
Copy link
Contributor

When the source_id changes, just reset the applet state.

@pmldrmota pmldrmota linked an issue Apr 19, 2024 that may be closed by this pull request
@pmldrmota
Copy link
Contributor Author

Alternatively to e6fef59, we could only reset the applet if source_id and self._context.get_source_id() != source_id without changing the unittest.

@dnadlinger
Copy link
Member

I wonder whether this is enough. Ideally, we'd want to clear out all of values at the beginning of a new scan, so we don't accidentally show old data.

@pmldrmota
Copy link
Contributor Author

It cleared it with a SinglePointModel, but it didn't do the trick for a ScanModel.

I added two commits that both individually should solve the problem (pick one?)
The first is changing the TopLevelRunner to clear out the point datasets at the start of a new scan.
The second is filtering the points from the values on the applet side.

@dnadlinger
Copy link
Member

What happens if one scan with an explicit prefix is scheduled on top of a second scan with the same explicit prefix? This is something we quite possibly can't handle cleanly, but maybe the solutions differ there.

In general, this is some tricky order-dependent code, so we should doucment the constraints assumed by the solution somewhere, at least in the form of some unit tests (like for the single-point point_phase mechanism, though ideally with more comments).

@pmldrmota
Copy link
Contributor Author

pmldrmota commented Apr 22, 2024

The second scan runs from a clean applet/dataset state with correct RID and correct data.
When the first scan resumes, it doesn't broadcast its RID and keeps appending to the second scan's results. The applet is not aware that experiments have switched because none of the metadata is reset after pause().
It also means the points from the first scan taken before the second scan was issued, are lost! But I think that was already the case before.

@pmldrmota
Copy link
Contributor Author

We could, however, catch that in TopLevelRunner.run() using

    def run(self):
        """Run the (possibly trivial) scan."""
        previous_completed = self.get_dataset(self.dataset_prefix + "completed", default=True)
        if not previous_completed:
            raise Exception("TopLevelRunner with same explicit prefix is still running")

Scans usually have a new dataset where completed doesn't exist - hence the default - and if they do, then completed = False.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean reset of applet state when scan is overwritten
2 participants