Skip to content

Conversation

chillenzer
Copy link
Contributor

@chillenzer chillenzer commented Oct 10, 2025

This is the second of a series of PRs relating to #5500.

This introduces one new functionality:
The schema validation falls back to requesting a schema directly from the class (which is hopefully a pydantic.BaseModel in that case) if it can't find a pertinent one in the schema registry. This unfortunately only works for the immediate class at hand and does not apply to following references in other schemata. The latter would involve some bookkeeping to map the referenced URI to the corresponding Python class. Playing around with that a little yielded no really satisfying solutions.

Given that

  • all of this is transitional technology that's supposed to be removed after the transition is completed
  • and Pydantic already handles the validation for us and is supposed to become the ground truth eventually

I haven't put to much effort into making referencing work. Instead, we can put wildcards where there are references currently.

I've applied this to two examples from #5501: Grid3D and TimeStepSpec, but not Auto. Removing the reference in plugin.Plugin.json would allow for plugins to contain arbitrary content and effectively circumvent all schema validation which is not what we want. Removing the plugin schemata should consider all plugins in one go instead.

@chillenzer chillenzer added this to the 0.9.0 / next stable milestone Oct 10, 2025
@chillenzer chillenzer added refactoring code change to improve performance or to unify a concept but does not change public API CI:no-compile CI is skipping compile/runtime tests but runs PICMI tests PICMI pypicongpu and picmi related labels Oct 10, 2025
@chillenzer chillenzer force-pushed the transition-pypic-to-pydantic-poc-schema branch from fa9922f to 25ab425 Compare October 10, 2025 11:09
@chillenzer chillenzer force-pushed the transition-pypic-to-pydantic-poc-schema branch from 25ab425 to 84c9d35 Compare October 20, 2025 08:19
@chillenzer chillenzer marked this pull request as ready for review October 20, 2025 08:23
@chillenzer
Copy link
Contributor Author

Ready for review but the CI is not up to the task yet.
Still, feel free to have a look @pordyna and @PrometheusPi!

Copy link
Member

@pordyna pordyna left a comment

Choose a reason for hiding this comment

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

Looks good to me! Out of curiosity, how does such a pydantic generated schema look like?

@pordyna
Copy link
Member

pordyna commented Oct 22, 2025

@PrometheusPi Do you still want to take a look? Otherwise, you can just merge it.

@chillenzer
Copy link
Contributor Author

Looks good to me! Out of curiosity, how does such a pydantic generated schema look like?

Well, let's try:

>>> from pydantic import BaseModel
>>> class A(BaseModel):
...     a: str='asdf'      
...     b: int=42
... 
>>> A.model_json_schema()
{'properties': {'a': {'default': 'asdf', 'title': 'A', 'type': 'string'}, 'b': {'default': 42, 'title': 'B', 'type': 'integer'}}, 'title': 'A', 'type': 'object'}

@pordyna pordyna merged commit dacd29e into ComputationalRadiationPhysics:dev Oct 22, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:no-compile CI is skipping compile/runtime tests but runs PICMI tests PICMI pypicongpu and picmi related refactoring code change to improve performance or to unify a concept but does not change public API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants