bw_interface_schemas.graph
Attributes
Classes
A Graph is the complete set of data used for sustainability assessment. |
Functions
|
Retrieve obj.attr or obj[attr] |
|
Load graph as simple Python objects into Pydantic classes. |
Module Contents
- class bw_interface_schemas.graph.Graph(/, **data: Any)[source]
Bases:
pydantic.BaseModelA Graph is the complete set of data used for sustainability assessment. This can include inventory and impact assessment data, and any other nodes and edges deemed useful by the practitioner to describe or model product systems and their effects.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_dump(*args, serialize_as_any=True, **kwargs) dict[source]
Usage docs: https://docs.pydantic.dev/2.10/concepts/serialization/#modelmodel_dump
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- Args:
- mode: The mode in which to_python should run.
If mode is ‘json’, the output will only contain JSON serializable types. If mode is ‘python’, the output may contain non-JSON-serializable Python objects.
include: A set of fields to include in the output. exclude: A set of fields to exclude from the output. context: Additional context to pass to the serializer. by_alias: Whether to use the field’s alias in the dictionary key if defined. exclude_unset: Whether to exclude fields that have not been explicitly set. exclude_defaults: Whether to exclude fields that are set to their default value. exclude_none: Whether to exclude fields that have a value of None. round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T]. warnings: How to handle serialization errors. False/”none” ignores them, True/”warn” logs errors,
“error” raises a [PydanticSerializationError][pydantic_core.PydanticSerializationError].
serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.
- Returns:
A dictionary representation of the model.
- edges: list[bw_interface_schemas.models.Edge][source]
- nodes: dict[bw_interface_schemas.models.Identifier, bw_interface_schemas.models.Node][source]
- bw_interface_schemas.graph.graph_to_pydantic(graph: dict[str, list | dict], node_mapping: dict[str, bw_interface_schemas.models.Node] = NODE_MAPPING, edge_mapping: dict[str, bw_interface_schemas.models.Edge] = EDGE_MAPPING) Graph[source]
Load graph as simple Python objects into Pydantic classes.
Intended for validation.
Parameters
- graph
Graph as dictionary: {“nodes”: {<identifier>: <node_dict>}, “edges”: [<edge_dicts>]}.