bw_interface_schemas.graph ========================== .. py:module:: bw_interface_schemas.graph Attributes ---------- .. autoapisummary:: bw_interface_schemas.graph.EDGE_MAPPING bw_interface_schemas.graph.NODE_MAPPING Classes ------- .. autoapisummary:: bw_interface_schemas.graph.Graph Functions --------- .. autoapisummary:: bw_interface_schemas.graph.getter bw_interface_schemas.graph.graph_to_pydantic Module Contents --------------- .. py:class:: Graph(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` A `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. .. py:method:: _objects_linked_to_product_system(label: str) -> None .. py:method:: biosphere_edge_source_target_types() -> Self .. py:method:: characterization_edge_source_target_types() -> Self .. py:method:: edges_reference_nodes() -> Self .. py:method:: elementary_flows_in_product_system() -> Self .. py:method:: model_dump(*args, serialize_as_any=True, **kwargs) -> dict 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. .. py:method:: normalization_edge_source_target_types() -> Self .. py:method:: process_has_at_least_one_functional_edge() -> Self .. py:method:: processes_in_product_system() -> Self .. py:method:: products_in_product_system() -> Self .. py:method:: technosphere_edge_must_specify_functionality() -> Self .. py:method:: technosphere_edge_source_target_types() -> Self .. py:method:: weighting_edge_source_target_types() -> Self .. py:attribute:: edges :type: list[bw_interface_schemas.models.Edge] .. py:attribute:: nodes :type: dict[bw_interface_schemas.models.Identifier, bw_interface_schemas.models.Node] .. py:function:: getter(obj: Any, attr: str) -> Any Retrieve `obj.attr` or `obj[attr]` .. py:function:: 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 Load `graph` as simple Python objects into Pydantic classes. Intended for validation. Parameters ---------- graph Graph as dictionary: `{"nodes": {: }, "edges": []}`. .. py:data:: EDGE_MAPPING .. py:data:: NODE_MAPPING