Skip to content

Fix EPICS enum signals support - #347

Merged
evvaaaa merged 2 commits into
bluesky:mainfrom
flowln:fix_epics_enum_units
Mar 7, 2025
Merged

evvaaaa merged 2 commits into
bluesky:mainfrom
flowln:fix_epics_enum_units

Conversation

@flowln

@flowln flowln commented Mar 6, 2025

Copy link
Copy Markdown
Contributor

In EPICS, enum (mbbi / mbbo) values do not possess units, so Ophyd fills their values with None before composing the descriptor document.

As such, any such signals would fail validation prior to this patch.

This reverts a behavior change from PR #343.

@danielballan

Copy link
Copy Markdown
Member

Thanks!

The change to the schema seems OK, but I have question about pinning down the dependency. From the commit message:

Since we're using PythonVersion.PY_38 in the typeddict generator,
we can't use the newer versions, that dropped support for Python
version older than 3.9.

This kind of thing does not generally require any action on our part. Package metadata on each release of datamodel-code-generator should indicate which versions of Python it supports, and pip should get the most recent release that supports the appropriate Python version. So, in a Python 3.8 environment, we would get the latest release that supported 3.8, and in a Python 3.9+ environment, we would get potentially newer versions.

@flowln

flowln commented Mar 6, 2025

Copy link
Copy Markdown
Contributor Author

This kind of thing does not generally require any action on our part. Package metadata on each release of datamodel-code-generator should indicate which versions of Python it supports, and pip should get the most recent release that supports the appropriate Python version. So, in a Python 3.8 environment, we would get the latest release that supported 3.8, and in a Python 3.9+ environment, we would get potentially newer versions.

The issue here is that the schema generator code here in this code base hardcodes the 3.8 version:

target_python_version=datamodel_code_generator.PythonVersion.PY_38,

This in theory means that event-model itself should only support Python 3.8, which is definitely not ideal. I'm not sure why this was made like that, as the commit message introducing it does not explain it, and I really don't know what's the consequence of changing this version, so I opted to restrict the dependency version to be the least intrusive possible while still generating a valid dev environment.

@coretl
coretl requested a review from evvaaaa March 7, 2025 07:50
@evvaaaa

evvaaaa commented Mar 7, 2025 •

Copy link
Copy Markdown
Collaborator

I'm not sure why this was made like that, as the commit message introducing it does not explain it

Apologies, when I made this change bluesky was still supporting 3.8, and as such I wanted the generated TypedDict to be compatible with it.

We've removed 3.8 from supported versions of bluesky so I'm happy for this to be bumped to

        target_python_version=datamodel_code_generator.PythonVersion.PY_39,

@evvaaaa evvaaaa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks very much!

I think we should just remove target_python_version= as an argument, it'll end up being more trouble than it's worth. For now there is no difference in generated schema.

Comment thread pyproject.toml Resolved
flowln added 2 commits March 7, 2025 07:52
In EPICS, enum (mbbi / mbbo) values do not possess units, so Ophyd
fills their values with None before composing the descriptor document.
As such, any such signals would fail validation previously.

This reverts a behavior change from PR bluesky#343.

Signed-off-by: Sofia Donato Ferreira <[email protected]>
Since version 0.28 of datamodel-code-generator, support for Python
3.8 was removed, so the previous configuration became invalid.

Without the argument explicitly specified, the minimum supported
version is used, which for now is Python 3.9.

Signed-off-by: Sofia Donato Ferreira <[email protected]>
@flowln
flowln force-pushed the fix_epics_enum_units branch from 71da362 to 471eb44 Compare March 7, 2025 10:55
@flowln
flowln requested a review from evvaaaa March 7, 2025 10:56

@evvaaaa evvaaaa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@evvaaaa
evvaaaa merged commit 33cdfaf into bluesky:main Mar 7, 2025
@flowln
flowln deleted the fix_epics_enum_units branch March 7, 2025 16:00
Tom-Willemsen pushed a commit that referenced this pull request Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants