-
Notifications
You must be signed in to change notification settings - Fork 4
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
add stop to experiment #484
base: master
Are you sure you want to change the base?
Conversation
15677e9
to
dd35cad
Compare
How is this different from calling |
It's class method, so you can stop even when you forget to store the handle to exp.run() and it is more structurized stop that tries to finish stuff in a that you can actually re-run the experiment afterwards (e.g. if a cont. motor is moving the cancel would only stop it in the acceleration phase). |
I see, alright. |
I thought to catch the CancelError and then make a structured stop, but then this would shadow the cancel of the motors etc. which might be also required in some cases. |
a015bc9
to
54dd377
Compare
54dd377
to
36771cb
Compare
Codecov Report
@@ Coverage Diff @@
## master #484 +/- ##
==========================================
+ Coverage 87.53% 87.54% +0.01%
==========================================
Files 114 114
Lines 7819 7843 +24
==========================================
+ Hits 6844 6866 +22
- Misses 975 977 +2
Continue to review full report at Codecov.
|
579e641
to
ceec8e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite there yet I think.
concert/experiments/imaging.py
Outdated
for i in range(int(number)): | ||
if self._stop: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, instead of checking this in every experiment class, we can catch a stop request in the Acquistion
, namely you can wrap the broadcast
into something which accepts a stop request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what will it change? I have to write everywhere, where right now is if self._stop
a handler of the stop request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will have one check in the Acquisition
class instead of N checks where N is the number of all possible producers.
I have to write everywhere, where right now is if self._stop a handler of the stop request?
Of course not, you don't have to write anything in the producers, that's the point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But a clean stop is very experiment specific. So I abort all the acquisitions and then call a clean-up function, that has to take care that everything is back in a well defined state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In all your producers you just do if stop then break
, so no clean up. And of course if special handler is needed you can always override the Experiment.stop
method.
ceec8e9
to
3f6ef18
Compare
3f6ef18
to
37c5b0b
Compare
How about this? It is basically the cancel, but with a different exception. So in a generator I can catch it and make a structured stop. |
Oh no: asyncio.Task inherits from Future all of its APIs except Future.set_result() and Future.set_exception(). |
Add a possibility to stop a running experiment without killing all tasks.
ToDo: