-
Notifications
You must be signed in to change notification settings - Fork 8
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
make device factory decorator #597
base: main
Are you sure you want to change the base?
make device factory decorator #597
Conversation
94124b4
to
27c1b79
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.
No idea if the rest of the code is right until some tests are written...
To clarify, the code in the original ticket is an idea, but has never been run or tests. It is expected that it is wrong in some way, and writing tests to exercise it will reveal how it is wrong... |
docs/developer/explanations/decisions/0003-added-make-devices-decorator.rst
Outdated
Show resolved
Hide resolved
f2ad915
to
fb5e142
Compare
26368ca
to
6cb1db6
Compare
do we want to add 'skip device' to the factory too? we could have just one decorator |
This is a question for @callumforrester and @DominicOram. I don't know what a |
|
it's an architectural question. We can have all the logic that belongs to 'making device class instances' inside a bunch of nested decorators that need to be in right order. OR we can have 1 factory class that accepts a dictionary of features (lazy, mock, skip, directory provicder, post-create script) in one place. |
I have a weak preference for a single decorator, but defer to @callumforrester and @DominicOram for a decision |
Single decorator works for me. |
ok I'll prepare a proof of concept for a single decorator |
6cb1db6
to
49e3bd2
Compare
beamline_utils.py 180 but that is inside ophyd, not sure how it works for ophyd-async |
0ecf386
to
656f918
Compare
00c641b
to
bc4cf6f
Compare
try: | ||
fake_with_ophyd_sim: object | None = kwargs.pop("fake_with_ophyd_sim") | ||
assert isinstance( | ||
fake_with_ophyd_sim, bool | None | ||
), "fake_with_ophyd_sim must be a boolean" | ||
mock = fake_with_ophyd_sim or mock | ||
# the instantiation of the device | ||
except KeyError: | ||
pass |
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.
@DominicOram are we thinking that device_factory
will be used with ophyd v1 devices? If not, then we should delete this section
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.
We will likely have ophyd v1 devices around for a couple more months. If I can mix and match old and new ways of instantiating devices in the same beamline file I'm happy to have device_factory
just on the ophyd-async ones. If so I would like a test confirming that mixing them like this works as expected.
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 had in mind supporting either there
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.
todo: make a test if it works with ophyd v1 devices
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.
VGonio at i24 is one such device, testing with it
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.
it's not a complicated device, could be easily migrated to ophyd_async
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.
only that, Eiger and some AreaDetector implementations and some helpers are using the old ophyd imports.
not sure how does the section indicated map to the difference between the two ophyd implementations
I literally just added a docstring and the CI started failing. what is going on??? |
Fixes #483
Instructions to reviewer on how to test:
Checks for reviewer
dodal connect ${BEAMLINE}