Metadata-Version: 2.4
Name: olca_schema
Version: 2.6.2
Summary: A package for reading and writing data sets in the openLCA schema format.
Project-URL: Homepage, https://github.com/GreenDelta/olca-schema
Project-URL: Bug Tracker, https://github.com/GreenDelta/olca-schema/issues
Keywords: openLCA,life cycle assessment,LCA
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3
Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: File Formats :: JSON
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Provides-Extra: test
Requires-Dist: pytest>=9.0; extra == "test"
Provides-Extra: packaging
Requires-Dist: build>=1.4; extra == "packaging"
Requires-Dist: twine>=6.2; extra == "packaging"

# olca-schema

This is a package for reading and writing data sets in the [openLCA
schema](https://github.com/GreenDelta/olca-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](https://pypi.org/project/olca-schema/) and
can be installed with `pip`:

```bash
pip install olca-schema
```

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

```python
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](https://github.com/GreenDelta/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:

```bash
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:

```bash
# 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/*
```
