⚠️ Brightway Live is in Public Beta ⚠️

Limitations#

Note

Almost all Python functionality is available in Brightway Live. However, there are some limitations. If you find that something is not working as expected, please report it here.

Filesystem (Data Storage)#

SQL Database Access#

Currently, an error is raised when trying to query a SQLite database in JupyterLite. This affects the use of Brightway, which stores data in sqlite databases through the peewee Python library. For instance, this simple test of the peewee library:

from peewee import *

# Define a database object
db = SqliteDatabase('my_database.db')

# Define a model class
class Person(Model):
    name = CharField()
    age = IntegerField()

    class Meta:
        database = db

# Create the table in the database
db.connect()
db.create_tables([Person])

person1 = Person(name='Alice', age=25)
person1.save()

raises the following error:

DatabaseError: database disk image is malformed

Instead of the default storage location a different location at /tmp/ must be specified for the database. This is done by setting the BRIGHTWAY_DIR environment variable.

Searchable Databases#

Brightway uses the whoosh package to index and search databases. Currently, an error is being raised when Brightway attempts to use the whoosh package. This is because whoosh attempts to use packages that are not available in WASM to lock files while accessing them. Emscripten currently does not have a “lock file” feature. Searching databases will therefore not work in Brightway Live.

Restoring Brightway Project Backups (from *.tar.gz)#

Brightway can back up and restore projects using the

bw2io.backup_project_directory(project='default')

and

bw2io.restore_project_directory(
    fp = '/brightway2-project-default-backup.14-September-2023-11-21AM.tar.gz',
    project_name = 'default',
    overwrite_existing = True
)

functions. The resulting backup file (*.tar.gz) can be as large as 300MB for a project based on Ecoinvent 3.9. Unfortunately, the current version of JupyterLite does not support the extraction of *.tar.gz files larger than ~1MB. This is likely due to a bug and does not present an inherent limitation of JupyterLite or WASM.

Missing pyfilesystem2 Support#

Pyodide currently does not implement all of the standard pyfilesystem2 library. Running

bw2io.add_example_database(searchable=False)

will therefore lead to the error:

AttributeError: 'Config' object has no attribute 'is_test'

A patched version of fs has been made available. This means, that setup of Brightway in the notebooks must follow this pattern (including the order of commands):

import micropip
await micropip.install(
    'https://files.brightway.dev/fs-2.5.1-py2.py3-none-any.whl'
)
import os
os.environ["BRIGHTWAY_DIR"] = "/tmp/"
await micropip.install('bw2data==4.0.dev29', keep_going = True)
await micropip.install('bw2io==0.9.dev23', keep_going = True)
await micropip.install('bw2calc==2.0.dev14', keep_going = True)
import bw2data
import bw2calc
import bw2io
bw2io.add_example_database(searchable=False)