-
Notifications
You must be signed in to change notification settings - Fork 0
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
Adapter rework for Zebra #174
Conversation
Codecov Report
@@ Coverage Diff @@
## master #174 +/- ##
==========================================
- Coverage 95.21% 94.64% -0.58%
==========================================
Files 43 41 -2
Lines 1295 1306 +11
==========================================
+ Hits 1233 1236 +3
- Misses 62 70 +8
|
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.
-
The naming
adapters
sound like they should be adapting something but as far as I can make out, they provide IO for external processes to modify the state of devices. Should theDeviceSimulation
/Component
types have a mutators/modfiers/io list instead? Adapter makes sense to be the shim between the device and the interface theio
type requires, ie, anAdapter
adapts aDevice
to allow it to be controlled by anIO
source to mutate theComponent
? -
The epics adapter,
I think this still applies to all the adapters to a certain extent. It feels like there should be a way to make the Io components do more work and have the adapters purely be a mapping from end point to device method.
-
The wrapper
If they weren't working before and no one was using them, deleting them for now and revisiting them when a clearer use case comes up makes sense.
I'm not sure I understand the need for AdapterContainer
s - why can't the io
instances have the adapters passed in at the same time as their configuration? At the moment the whole class seems to be a single function. Where container.run_forever(interrupt)
is called now, it could call io.setup(interrupt)
and have the same behaviour? Or is that what they used to do?
Given this is such a big PR, I've not really looked that closely at the code as much as the restructuring of the adapters. I've not looked at the tests at all.
If this works as it is and unblocks the work on the zebra components, I'm tempted to say commit it as it is and deal with any fallout later. It could drag on for weeks otherwise.
|
||
@abstractmethod | ||
def on_db_load(self) -> None: | ||
"""Customises records that have been loaded in to suit the simulation.""" |
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.
Does the adapter need access to the loaded db records?
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.
At the moment this is the method which actually links the records on the ioc and the device attributes, so yes. It could benefit from renaming.
builder.SetDeviceName(self.ioc_name) | ||
if self.db_file: | ||
self.load_records_without_DTYP_fields() | ||
adapter.on_db_load() |
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.
should this be called if not self.db_file?
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.
No, the confusing naming is perhaps the adapter.on_db_load()
which links the records with device fields, or the callables to get them. You can also make your own records here and assign them, which is what happens in a world without db files.
name: ComponentID | ||
inputs: Dict[PortID, ComponentPort] |
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.
How does repeating a field name on a Pydantic dataclass work? Is this just to be explicit in the docs?
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.
I just copied the other one and it works so honestly I don't know
This is a possible change to the way adapters work within tickit. This attempts unifies the adapters in a composed way by seperating out the IO and the device specific handling logic. The idea is that you use an
AdapterContainer
which has both anadapter
(the part that handles the messages) and theio
which does the rest.The
AdapterContainer
acts as the previous adapters did and contains therun_forever
method. Now though, this calls asetup
method in theio
in which theio
takes the specificadapter
that has been provided. Theadapter
andio
are failry coupled given the io needs a specific adapter type to work, eg.class HttpIo(AdapterIo[HttpAdapter]):
. However i was hoping this change provides a clearer divide in developer and user implemented code.In the http example:
As before users would need to write specific adapters for their devices but this should simplifiy their lives a bit as all they now need is the device and device specific methods. For example the http adapter on an iobox:
Then the component config:
Most importantly, and the motivation for this change, is there is no longer a limitation on what an adapter may apply to. This allows us to write an adapter which inspect the components in a system simulation. I put a quick example one I made in the example folder which used a tcpio and commandadapter.
I'd really appreciate opinions on the idea before I commit to it and rewrite half the test suite. I'm particularly not certain on: