paidiverpy.frontend.parse#

Parse Pydantic models to a dictionary format for frontend use.

Functions#

define_default_value(→ any)

Define the default value for a Pydantic field.

parse_default_params(→ dict)

Parse the default parameters from a Pydantic model.

parse_get_origin_field(→ dict)

Parse the origin field of a Pydantic field.

parse_union_field(→ dict)

Parse a Pydantic field that is a union type.

parse_fields_from_pydantic_model(→ dict)

Parse fields from a Pydantic model into a dictionary format.

Module Contents#

paidiverpy.frontend.parse.define_default_value(field: pydantic.fields.FieldInfo) any[source]#

Define the default value for a Pydantic field.

Parameters:

field (pydantic.fields.FieldInfo) – The Pydantic field to parse.

Returns:

The default value of the field, or None if no default is set.

Return type:

any

paidiverpy.frontend.parse.parse_default_params(model: pydantic.BaseModel, steps: bool = False) dict[source]#

Parse the default parameters from a Pydantic model.

Parameters:
  • model (pydantic.BaseModel) – The Pydantic model to parse.

  • steps (bool) – If True, the parameters will be parsed for steps.

Returns:

A dictionary containing the parsed parameters.

Return type:

dict

paidiverpy.frontend.parse.parse_get_origin_field(field: pydantic.fields.FieldInfo, origin_field: type) dict[source]#

Parse the origin field of a Pydantic field.

Parameters:
  • field (pydantic.fields.FieldInfo) – The Pydantic field to parse.

  • origin_field (type) – The origin type of the field.

Returns:

A dictionary containing the parsed field information.

Return type:

dict

paidiverpy.frontend.parse.parse_union_field(field: pydantic.fields.FieldInfo, output: dict) dict[source]#

Parse a Pydantic field that is a union type.

Parameters:
  • field (pydantic.fields.FieldInfo) – The Pydantic field to parse.

  • output (dict) – The output dictionary to populate with parsed information.

Returns:

The updated output dictionary with union field information.

Return type:

dict

paidiverpy.frontend.parse.parse_fields_from_pydantic_model(model: pydantic.BaseModel) dict[source]#

Parse fields from a Pydantic model into a dictionary format.

Parameters:

model (pydantic.BaseModel) – The Pydantic model to parse.

Returns:

A dictionary containing the parsed fields with their default values and types.

Return type:

dict