Skip to content

Convert from jsonschema to BaseModel + TypedDict - #341

Closed
evvaaaa wants to merge 2 commits into
mainfrom
337-add-basemodel-support
Closed

evvaaaa wants to merge 2 commits into
mainfrom
337-add-basemodel-support

Conversation

@evvaaaa

@evvaaaa evvaaaa commented Dec 17, 2024

Copy link
Copy Markdown
Collaborator

Closes #337

@evvaaaa evvaaaa self-assigned this Dec 17, 2024
@evvaaaa
evvaaaa force-pushed the 337-add-basemodel-support branch 2 times, most recently from 56b88ef to 5f1d747 Compare December 18, 2024 11:17

@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.

Neat! This is looking pretty good

Comment thread src/event_model/__init__.py Resolved
@evvaaaa
evvaaaa force-pushed the 337-add-basemodel-support branch 3 times, most recently from 59a86e9 to fdf2837 Compare December 19, 2024 10:56
@evvaaaa
evvaaaa marked this pull request as ready for review December 19, 2024 10:56
@evvaaaa
evvaaaa force-pushed the 337-add-basemodel-support branch 2 times, most recently from 315bf60 to 35645e1 Compare December 19, 2024 14:24
@evvaaaa
evvaaaa requested a review from coretl December 19, 2024 15:13
Comment thread src/event_model/documents/__init__.py Resolved
@evvaaaa

evvaaaa commented Jan 6, 2025 •

Copy link
Copy Markdown
Collaborator Author

@jacopoabramo

Some of the schema will allow additional fields if the given field has a key which doesn't contain dots. This means some documents, e.g run_start or event_descriptor, will be of variable length. I think this may make them incompatible with msgspec, which I assume optimizes based on fixed definitions for keys?

@jacopoabramo

Copy link
Copy Markdown
Contributor

I think this may make them incompatible with msgspec, which I assume optimizes based on fixed definitions for keys?

Not necessarely but right off the bat I can't be certain. I wanted to try it out once this PR is completed, so to also review it myself to replicate the same steps.

@evvaaaa
evvaaaa force-pushed the 337-add-basemodel-support branch from e699645 to 3524ac2 Compare January 7, 2025 11:09
@evvaaaa
evvaaaa marked this pull request as draft January 7, 2025 11:09
@evvaaaa
evvaaaa force-pushed the 337-add-basemodel-support branch 2 times, most recently from 71a6d0d to 1c94d67 Compare January 9, 2025 11:50
@evvaaaa
evvaaaa force-pushed the 337-add-basemodel-support branch from 1c94d67 to e0b0872 Compare January 9, 2025 12:01
@evvaaaa
evvaaaa force-pushed the 337-add-basemodel-support branch from e0b0872 to 48a9986 Compare January 9, 2025 12:10
@evvaaaa
evvaaaa marked this pull request as ready for review January 9, 2025 12:10
@evvaaaa
evvaaaa requested a review from coretl January 9, 2025 12:11

@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.

Did I get this right, the source is now the JSON schemas rather than TypedDicts or BaseModels? Hmm, I'm not a big fan of writing JSON schemas by hand. Let's discuss offline...

Comment thread pyproject.toml

[project.scripts]
regenerate-schema = "event_model.documents.generate.__main__:main"
regenerate-documents = "event_model.generate.__main__:generate"

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 wonder if we should be exposing this as a script, as it's only used internally to the module. Could we ditch this section and call this via python -m event_model.generate instead?

@evvaaaa
evvaaaa marked this pull request as draft January 10, 2025 10:51
@evvaaaa evvaaaa changed the title Convert from BaseModel to static jsonschema + TypedDict Convert from jsonschema to BaseModel + TypedDict Jan 10, 2025
@evvaaaa evvaaaa closed this Jan 10, 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.

BaseModel documents and change to schema generation

3 participants