gemseo.core.grammars.pydantic_grammar module#

A grammar based on a Pydantic model.

class PydanticGrammar(name, model=None, **kwargs)[source]#

Bases: BaseGrammar

A grammar based on a Pydantic model.

The Pydantic model passed to the grammar is used to initialize the grammar defaults. Currently, changing the defaults will not update the model. Changing the descriptions will update the model when accessing schema.

Warning

A name can be prefixed by a namespace. Never add a namespace by any other means than the method add_namespace().

Notes

Contrary to the standard dictionary, the :meth:.copy method creates a deep copy.

Initialize self. See help(type(self)) for accurate signature.

Parameters:
  • name (str) -- The name of the grammar.

  • model (ModelType | None) -- A Pydantic model. If None, the model will be empty.

  • **kwargs (Any) -- These arguments are not used.

Raises:

ValueError -- If the name is empty.

DATA_CONVERTER_CLASS#

alias of DataConverter

set_descriptions(descriptions)[source]#

Set the properties descriptions.

Parameters:

descriptions (Mapping[str, str]) -- The mapping from names to the description.

Return type:

None

property schema: dict[str, Schema]#

The dictionary representation of the schema.