Skip to content

Convert from BaseModel to jsonschema + TypedDict - #343

Merged
evvaaaa merged 5 commits into
mainfrom
337-add-basemodel-support-1
Jan 15, 2025
Merged

evvaaaa merged 5 commits into
mainfrom
337-add-basemodel-support-1

Conversation

@evvaaaa

@evvaaaa evvaaaa commented Jan 10, 2025

Copy link
Copy Markdown
Collaborator

Closes #337

@evvaaaa evvaaaa changed the title Convert from BaseModel to jsonschema + TypedDict` Convert from BaseModel to jsonschema + TypedDict Jan 10, 2025
@evvaaaa
evvaaaa force-pushed the 337-add-basemodel-support-1 branch 5 times, most recently from 88e3c04 to 176413f Compare January 10, 2025 11:18
@evvaaaa
evvaaaa requested a review from coretl January 10, 2025 11:18
@evvaaaa evvaaaa self-assigned this Jan 10, 2025
@evvaaaa

evvaaaa commented Jan 10, 2025

Copy link
Copy Markdown
Collaborator Author

Will probably streamline the system of adding extra json schema to BaseModels too

@evvaaaa
evvaaaa force-pushed the 337-add-basemodel-support-1 branch from 176413f to 1e860ad Compare January 10, 2025 11:29

@coretl coretl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm happy with this, and it didn't require any code changes so I think that means the checking for nulls is OK.

@danielballan please can you review the schema changes on projections?

Just to make sure, please can you point bluesky to this and run mypy src/bluesky, then point ophyd-async at this and run pyright src/ophyd_async and check it doesn't think we need to check for nulls anywhere?

@coretl

coretl commented Jan 10, 2025

Copy link
Copy Markdown
Contributor

Also, why is the test failing?

@evvaaaa
evvaaaa marked this pull request as ready for review January 13, 2025 08:02
@evvaaaa

evvaaaa commented Jan 13, 2025 •

Copy link
Copy Markdown
Collaborator Author

Also, why is the test failing?

There wasn't consistency in the order of the generated __init__.py so the test for consistency in regeneration failed. Sorted them now.

I'll wait for a review and then add an ADR and update the docs within this PR once we've decided.

@evvaaaa
evvaaaa force-pushed the 337-add-basemodel-support-1 branch 6 times, most recently from a683dc5 to 2195892 Compare January 13, 2025 10:44
@evvaaaa

evvaaaa commented Jan 13, 2025

Copy link
Copy Markdown
Collaborator Author

I tested that it's working against bluesky and ophyd-async, both tests and type checking.

I had to write some custom code to include Partial documents within the jsonschema itself:

@evvaaaa
evvaaaa force-pushed the 337-add-basemodel-support-1 branch from 2195892 to 895f19d Compare January 13, 2025 10:54

@danielballan danielballan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good.

Incidentally I like the new usage, too. Good use of python -m ....

@evvaaaa

evvaaaa commented Jan 15, 2025

Copy link
Copy Markdown
Collaborator Author

Was going to add tests for the BaseModel themselves. I think it's better to do it in a different PR though.

@evvaaaa
evvaaaa merged commit a8d4575 into main Jan 15, 2025
@evvaaaa
evvaaaa deleted the 337-add-basemodel-support-1 branch January 15, 2025 09:48
flowln added a commit to flowln/event-model that referenced this pull request Mar 6, 2025
In EPICS, enum (mbbi / mbbo) values do not possess units, so Bluesky
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]>
flowln added a commit to flowln/event-model that referenced this pull request Mar 6, 2025
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]>
flowln added a commit to flowln/event-model that referenced this pull request Mar 7, 2025
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]>
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.

BaseModel documents and change to schema generation

3 participants