Skip to main content

A package for reading and writing data sets in the openLCA schema format.

Project description

olca-schema

This is a package for reading and writing data sets in the openLCA schema format version 2. It provides a typed class model of the schema elements, methods for reading and writing them in the JSON format, reading and writing data sets in zip packages, and some utility methods.

Usage

The package is published on PyPI and can be installed with pip:

pip install olca-schema

Here is a small example that creates a package that can be imported into openLCA 2:

import olca_schema as o
import olca_schema.zipio as zipio

# create a unit group and flow property
units = o.new_unit_group('Units of mass', 'kg')
kg = units.units[0]
mass = o.new_flow_property('Mass', units)

# create a product flow and a process with the product as output
steel = o.new_product('Steel', mass)
process = o.new_process('Steel production')
output = o.new_output(process, steel, 1, kg)
output.is_quantitative_reference = True

# prints the Json string of the process
print(process.to_json())

# write a zip package with the data sets
with zipio.ZipWriter('path/to/example.zip') as w:
    for entity in [units, mass, steel, process]:
        w.write(entity)

Tests and packaging

The Python library for the openLCA schema is part of the olca-schema project. It does not have any runtime dependencies. The optional test and packaging extras are used for local development tasks.

Run the tests with:

cd olca-schema/py
# easy with uv; initialize the virtual environment
uv venv [-p 3.12]
# install the test dependencies
uv sync --extra test
# run the tests
uv run pytest -v

Build and validate a release package with:

# install the packaging dependencies
uv sync --extra packaging
# build the source and wheel distributions
uv run python -m build
# validate the generated artifacts
uv run twine check dist/*

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

olca_schema-2.6.2.tar.gz (34.3 kB view details)

Uploaded Source

Built Distribution

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

olca_schema-2.6.2-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file olca_schema-2.6.2.tar.gz.

File metadata

  • Download URL: olca_schema-2.6.2.tar.gz
  • Upload date:
  • Size: 34.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for olca_schema-2.6.2.tar.gz
Algorithm Hash digest
SHA256 899b29e3658aff8907b3c649fa0e27771b659613a50ce89c7c9672971b15c29f
MD5 2e2ae02917d98c6efc2b7f9d7978dda3
BLAKE2b-256 b5f3a0c0ff2ee54aecd68e56de9bd2b681c7ce2323056d9cd1f551b8e5b215c4

See more details on using hashes here.

File details

Details for the file olca_schema-2.6.2-py3-none-any.whl.

File metadata

  • Download URL: olca_schema-2.6.2-py3-none-any.whl
  • Upload date:
  • Size: 29.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for olca_schema-2.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6bdc1de25ba09d893d2f730c9f876cd6489270e713900ccda7d4b9d869c9ef81
MD5 fdcf711e2c680a7b96d338b1d0804b2e
BLAKE2b-256 7c80eec9837bc0124d94310ddc659fb8793be3a015adfa0053cfb8c4b02cae09

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