Skip to main content

Interface schemas for data transfer in Brightway

Project description

bw_interface_schemas

[PyPI][pypi status] [Status][pypi status] [Python Version][pypi status] License

About

bw_interface_schemas defines a set of pydantic classes which will be the fundamental data schema for Brightway Cloud, the next iteration of the Brightway LCA software ecosystem. These schemas provide clear and consistent graph-based interfaces between Brightway software libraries, and simplify and harmonize the way data was modeled and stored in Brightway.

We have chosen to model all data in a graph, as a list of nodes and edges. This includes inventory data, which models how processes consume and produce products to form supply chains. It also includes impact assessment, where elementary flows are linked to impact categories via characterization edges, and data organization. Now both projects and databases are also in the graph, and process and product nodes are linked to databases via belongs_to relationship edges.

Example

Here is our standard bicycle production example in the new paradigm:

You can see two ways of building this graph in code in tests/conftest.py.

Comparison with Brightway2

These new interfaces break backwards compatibility. We do not take such steps lightly; these changes were necessary to include database, projects, and methods in the same data store as other nodes and edges, and to add sanity checks and simpler code paths to building correct supply chain models.

Our approach has the following advantages:

  • Edge source and target attributes now correctly indicate direction. Previously production edges had the product being produced as an input. Similarly, elementary flows being emitted were still modeled as inputs.
  • Removal of implicit production edges. These seemed like a convenience but ultimately led to many hacks and difficult to diagnose incorrect behaviour for users.
  • Removal of edge type labels which were at best confusing and sometimes incorrect. Edges now have a small set of possible types which only indicates the matrix they can be used in, and explicit instead of implicit direction.
  • Clear separation of processes and products. Processes can only consume and produce products, and vice-versa. The previous allowance of chimaera processes which acted as products made modelling of multifunctional processes difficult and error-prone.
  • The single graph format with LCI and LCIA nodes can sensibly model impact assessment data. Previously impact assessment data had to pretend to be inventory databases in bw2io.
  • A unified data format which is identical in Python and JSON. This makes serialization, database storage, and exchange across systems and languages much easier.
  • Pydantic validation provides usable feedback and prevents data errors entering the database.

Installation

You can install bw_interface_schemas via [pip] from [PyPI]:

$ pip install bw_interface_schemas

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, bw_interface_schemas is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bw_interface_schemas-0.2.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bw_interface_schemas-0.2-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file bw_interface_schemas-0.2.tar.gz.

File metadata

  • Download URL: bw_interface_schemas-0.2.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.0

File hashes

Hashes for bw_interface_schemas-0.2.tar.gz
Algorithm Hash digest
SHA256 50b8368cd5cae6e82b5596557bc22763d492d42bbdd63ed0e8252174d2efa5cd
MD5 9f0ce57234af3442ace7e247f1206598
BLAKE2b-256 ef3caac4fb91eadc23cc9b3215ba0f4fc0e5be69b245491943207c6b52318fb0

See more details on using hashes here.

File details

Details for the file bw_interface_schemas-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for bw_interface_schemas-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0722606137b7e3089545c39ada3c43309812153454766c9d5e29ac08dfa21ce8
MD5 1cf9f06bf5ea3b9a3e45e0dc7d8093b6
BLAKE2b-256 3570d4813835993643e78005c2e6a0aa1dc1b8056e37fd1c159e95ee1b22288b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page