-
Notifications
You must be signed in to change notification settings - Fork 6
Remove tango polling #66
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #66 +/- ##
==========================================
+ Coverage 82.75% 85.56% +2.80%
==========================================
Files 23 23
Lines 928 928
==========================================
+ Hits 768 794 +26
+ Misses 160 134 -26 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
|
Also I have removed "register_dev" from being called on start up. Device registration logic is probably better left to the library consumer |
2f98919 to
1a079b9
Compare
f6dba66 to
3b4fb01
Compare
|
This looks good. Just to make sure I understand, is the key thing here removing The tests look quite neat, but they are also a bit hard to understand. Could you add some comments / docstrings to the test utilities to explain what they are doing and maybe link to the pytango docs to explain the magic |
Thank you for the feedback Gary. I think I will try get this merged first and then cascade your comments through my other PRs Id say the core issue is that when I had the task to add a "Tango backend" - I understood that backend implys that Tango needs to do the work. Therefore I had the Tango server:
However, Tango is running its own event loop (I did look at the source and there is no way to pass it an eventloop, maybe theres a way to fool get_event_loop with a context manager of sorts but also afraid of the weird Tango threading) therefore I believe this is why there were issues reported with the locks. The solution is to not poll the attributes and leave that to FastCS. The tango server is simply given the method to read the attributes - which is what gets triggered by a Tango Client request. So the server is only a thin layer. GreenMode here allows the tango server to execute the awaitable methods like the async Commands Btw the change from MethodType for commands is because I could not get it testable (doesnt seem to raise call_count?) Interestingly, the testing is fairly consistent with the testing suggested for FastAPI. I agree it could do with more explanation |
|
Ah OK I see, it is the wrapper functions that have changed. So, the wrapped fget now just calls It might be nicer to use the attribute update_callback to call a tango device function to update the value when it changes, like the EPICS backend does here. |
No, I believe that Tango is only reading that method when the client makes a request and then gives the result to the client. I am not aware that it records the value... According to Tom, such client polling is used at some facilities. But this is a good point. Tom has mentioned that using Tango events is also popular in the Tango space. Hmm doesnt |
|
@GDYendell Comments processed, tests fixed. I think this is ready |
It does currently still call the callback if the value has not changed, but we could rethink that. softioc ignores sets with the same value and that does cause problems sometimes. A common annoyance is if you make a PV that runs a command when set to 1, then that PV needs to be manually set back to 0 afterwards for the user to be able to run the command again. We would have to be careful not to recreate the same issue at the attribute level. Let's leave it for now. |
This would probably also be useful for webhooks |
|
@GDYendell Thanks for the additional remarks, I like it. The only thing I am not liking is the enum being "" as default, but I dont feel that is work for this PR |
|
At the moment, tango enums are not used here. As is, I believe I will have to find and cast "fastcs enums" into python int enums. Pytango supports Python IntEnum as a datatype. FastAPI supports string and int enum (fastapi/fastapi#2129) Is there a reason we dont have enums as something more python native? Maybe something like |
I think we should explore this, but it might not be trivial to implement because the fastcs datatypes have specific functionality that configure the control system. For example we are adding |
|
@GDYendell all good? |
fixes #50
At the time of implementation the attribute polling was deferred to the device server and therefore it had its own event loop