Skip to content
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 representers for all channel access types #66

Merged
merged 3 commits into from
Nov 13, 2023
Merged

Conversation

rosesyrett
Copy link
Collaborator

we have save load functionality, but unfortunately it only works for PV access currently. So I've added some lines which let it work for channel access, by adding representers. I've also expanded on existing tests to ensure the serialisation/deserialisation works.

Comment on lines 80 to 83
if isinstance(selected_values, dict):
selected_values = [selected_values]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to know people's opinion on this; while writing tests I found that, if get_signal_values is called using a dictionary containing just one device, the result of yield Msg("locate", ...) will be a dictionary, not a sequence. The type hinting for selected_values suggests it will always be a sequence. But it isn't... Personally I'd prefer if locate always returned a list of dicts, instead of sometimes returning a dict and sometimes returning a list of dicts.

Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rosesyrett Since we are merging this for need then coming back to it, can I just put a type ignore on this to get mypy to behave? It's the only thing flagging now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please. The type hints are wrong; this is probably a bluesky bug.


import numpy as np
import numpy.typing as npt
import yaml
from bluesky.plan_stubs import abs_set, wait
from bluesky.protocols import Location
from bluesky.utils import Msg
from epicscorelibs.ca.dbr import ca_array, ca_float, ca_int, ca_str
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the right solution, but in the wrong place. We need to make sure epicscorelibs imports are only within the ophyd_async.epics packages.

How about a global (yuck) directory of representers that are added to on inport of packages?

Copy link
Collaborator Author

@rosesyrett rosesyrett Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs a broader discussion on where stuff belongs. I don't like the fact that we have plans in ophyd_async.core, but definitely agree epics things shouldn't belong in ophyd_async.core. For the meantime I'd be keen to just merge this in anyway and come up with a better long term solution later...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coretl I suggest merging, making an issue and fixing later because of time constraints

@rosesyrett rosesyrett merged commit 2570efd into main Nov 13, 2023
12 of 14 checks passed
@rosesyrett rosesyrett deleted the add-representers branch November 13, 2023 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants