-
Notifications
You must be signed in to change notification settings - Fork 6
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
Run BlueskyContext and Worker in subprocess #343
Conversation
These changes do allow the run engine and worker to run in a subprocess but I'm not sure this is the best design as it ends up with many implementations of these methods. I've tested it though and it does work. Probably something to discuss next week. |
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.
Looks good, needs tests. See comment about intermittent issue.
I think after this we can clean up subprocess_handler.py
a bit more and break up handler as discusses
9797074
to
ae4fabc
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #343 +/- ##
==========================================
+ Coverage 87.17% 88.70% +1.53%
==========================================
Files 42 43 +1
Lines 1645 1797 +152
==========================================
+ Hits 1434 1594 +160
+ Misses 211 203 -8 ☔ View full report in Codecov by Sentry. |
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.
Probably needs some tests of the subprocess handler.
a4873b3
to
afdaadd
Compare
Would merging this close #317? |
I think the four definitions of functions flaw can be solved by a refactor in the future, this is a good first attempt. |
Yes, is you commenting of that sufficient to auto close the issue when this is merged? |
No idea :) |
ae32bbd
to
c4fd452
Compare
This approach is possibly not the best design as it results in four definitions of all the functions.
ab42bbf
to
75925f3
Compare
8a2fd05
to
f94dac4
Compare
Setting environment state to not valid will cause the subprocess context to be reloaded.
Dependency override should import from main.py (app) not handler module.
Added mostly to satisfy type checking as the _subprocess field is set to None before it is started and when it is stopped.
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.
Please could you make issues to do the following (unless you feel like doing them now but I think we should get this merged):
- Document this approach, probably requires an explanation page and perhaps an ADR
- Add CLI commands to inspect/restart the environment
- Better error handling if someone calls, say,
/devices
while the environment is restarting
Yes I agree - it's probably best to draw a line under this and make new issues. |
Closes #369 The validated and processed parameters from a plan request were being cached inside the `Task` class because they were needed in two separate threads. Unfortunately, with the introduction of the subprocess (#343), pickling was causing issues with the cached object (see #369 for more details). This PR is the simplest solution: remove the cache and generate the parameters twice. It also adds regression tests for the bug case in #369
Create SubprocessHandler as additional BlueskyHandler implementation to forward calls to a subprocess. This is to allow a new REST endpoint with the result of reloading the plans and devices without having to restart the service. Additionally the API version is incremented due to new schema and a reference to delete_task replaced with clear_pending_task which was missed in a previous PR. Further improvements required in later PRs.
Closes #369 The validated and processed parameters from a plan request were being cached inside the `Task` class because they were needed in two separate threads. Unfortunately, with the introduction of the subprocess (#343), pickling was causing issues with the cached object (see #369 for more details). This PR is the simplest solution: remove the cache and generate the parameters twice. It also adds regression tests for the bug case in #369
This approach is possibly not the best design as it results in four definitions of all the functions.