You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spec provides a deserialize() method which uses an internal pydantic type adapter to deserialize a dict into any Spec.
As a developer I would like to deserailize a dict into an arbitrary type that I do not know at compile time so that I can include scanspecs in blueapi plans.
In the last version of scanspec I could do this with:
Traceback (most recent call last):
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/type_adapter.py", line 277, in _init_core_attrs
self._core_schema = _getattr_no_parents(self._type, '__pydantic_core_schema__')
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/type_adapter.py", line 119, in _getattr_no_parents
raise AttributeError(attribute)
AttributeError: __pydantic_core_schema__
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in<module>
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/type_adapter.py", line 264, in __init__
self._init_core_attrs(rebuild_mocks=False)
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/type_adapter.py", line 142, in wrapped
return func(self, *args, **kwargs)
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/type_adapter.py", line 284, in _init_core_attrs
self._core_schema = _get_schema(self._type, config_wrapper, parent_depth=self._parent_depth)
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/type_adapter.py", line 102, in _get_schema
schema = gen.generate_schema(type_)
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 507, in generate_schema
from_property = self._generate_schema_from_property(obj, obj)
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 679, in _generate_schema_from_property
schema = get_schema(
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/scanspec/core.py", line 234, in __get_pydantic_core_schema__
return handler(source_type)
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/_internal/_schema_generation_shared.py", line 83, in __call__
schema = self._handler(source_type)
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 789, in _generate_schema_inner
return self.match_type(obj)
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 875, in match_type
return self._unknown_type_schema(obj)
File "/home/vid18871/projects/bluesky/blueapi/venv/lib64/python3.10/site-packages/pydantic/_internal/_generate_schema.py", line 415, in _unknown_type_schema
raise PydanticSchemaGenerationError(
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for<class 'scanspec.specs.Spec'>. Set `arbitrary_types_allowed=True`in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.
If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__`then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.
For further information visit https://errors.pydantic.dev/2.8/u/schema-for-unknown-type
The text was updated successfully, but these errors were encountered:
Spec
provides adeserialize()
method which uses an internal pydantic type adapter to deserialize adict
into anySpec
.As a developer I would like to deserailize a dict into an arbitrary type that I do not know at compile time so that I can include scanspecs in blueapi plans.
In the last version of scanspec I could do this with:
This is now deprecated and has been replaced with
TypeAdapter
, so the equivalent would be:Using both of the above I get the same error:
The text was updated successfully, but these errors were encountered: