Skip to main content

TIDAS Python SDK

中文文档

Type-safe Python SDK for working with ILCD/TIDAS life-cycle assessment (LCA) data. It provides generated Pydantic models plus higher-level helpers so you can read, manipulate, validate and export ILCD-compatible datasets from Python.

Installation

From PyPI

pip install tidas-sdk

From source (this repository)

cd sdks/python
uv sync --group dev

Quick Start

Run the end-to-end sample to see the core features in action:

uv run python examples/usage.py

Minimal usage example:

from tidas_sdk import create_process

process = create_process({})
process.process_data_set.process_information.data_set_information.name.base_name.set_text(
    "Sample Process", lang="en"
)

print(process.to_json())

Basic Usage

Creating entities

from tidas_sdk import create_process, create_flow, create_source

process = create_process({})
flow = create_flow({})
source = create_source({})

You can also build entities directly from ILCD‑style JSON:

from pathlib import Path
from tidas_sdk import create_process_from_json

process = create_process_from_json(Path("process.json"))

Or start from ILCD XML when you already have the canonical .xml datasets:

from pathlib import Path
from tidas_sdk import create_process_from_xml, TidasProcess

process = create_process_from_xml(Path("process.xml"))
# or, if you prefer to work with the class directly
process = TidasProcess.from_xml(Path("process.xml"))

Working with multilingual fields

name_list = process.process_data_set.process_information.data_set_information.name.base_name
name_list.set_text("Sample Process", lang="en")
name_list.set_text("示例工艺", lang="zh")
print(name_list.get_text("en"))

Validation and export

Version 0.4.0 rejects repeated languages within a declared multilingual field in Pydantic validation. Preserve the original paragraphs in one entry per language when migrating existing data. Raw JSON Schema validation applies the pinned Draft-07 whole-item uniqueness rule.

is_valid = process.validate()          # Pydantic (and optional JSON Schema) validation
json_payload = process.to_json()       # ILCD‑compatible dict
xml_payload = process.to_xml()         # ILCD XML string

Main Features

  • JSON ➜ Object: create_process() and other factory helpers build rich entity objects from complete or partial ILCD JSON.
  • Object ➜ JSON: to_json() returns ILCD-compatible dictionaries suitable for storage or downstream tooling.
  • Multilingual fields: MultiLangList with set_text() / get_text() simplifies @xml:lang / #text handling.
  • Strong typing: generated Pydantic models expose full type hints for IDE autocompletion and static checking.
  • On-demand validation: validate() runs Pydantic and optional JSON Schema validation when your dataset is ready.
  • XML export: to_xml() converts entities into ILCD XML for interoperability with other LCA systems.

See examples/usage.py for a step‑by‑step walkthrough of these features.

Development Workflow (for contributors)

# Install / update dependencies
uv sync --group dev

# Linting & formatting
uv run ruff check src
uv run ruff format src

# Type checking
uv run mypy src

# Tests
uv run pytest

Project Layout

  • src/tidas_sdk: Core implementation and generated models
  • examples/usage.py: Feature walkthrough used in this README
  • scripts/: Utility scripts for code generation and maintenance

For questions or contributions, open an issue or pull request at https://github.com/tiangong-lca/tidas-sdk.

Process exchange Flow reference names

Python 0.5.0 exposes compose_flow_name, collect_process_flow_references and analyze_process_flow_references from tidas_sdk and tidas_sdk.core. They accept raw TIDAS dictionaries with JSON field names.

from tidas_sdk import analyze_process_flow_references, compose_flow_name

candidate = compose_flow_name(
    flow["flowDataSet"]["flowInformation"]["dataSetInformation"]["name"]
)
result = analyze_process_flow_references(
    process, flows=[{"uuid": flow_uuid, "version": flow_version, "document": flow}]
)

The analyzer and composer implement the tidas.process-flow-reference-name.v1 policy shared with TypeScript. The four fields are joined in each language with semicolon and space. Missing translations and names over 1000 Unicode code points are reported explicitly. Use the results alongside structural validation. The caller provides the exact Flow document and the functions leave the input dictionaries intact.

Process exchange inventory amounts

When an exchange has no nonblank variable reference, its mean and resulting amounts must have the same exact decimal value. Signed zero, insignificant zeros and equivalent exponents compare equal. A conflict reports process_exchange_amount_conflict on the exchange’s resultingAmount field with both original values. Validation preserves the payload. A named variable may produce a different result. Scalar and reference field constraints still apply.

Metadata

Release files for tidas-sdk 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tidas-sdk 0.6.0
File Size Uploaded Provenance Actions
tidas_sdk-0.6.0.tar.gz 419.4 kB With provenance Details for tidas_sdk-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tidas-sdk 0.6.0
File Interpreter ABI Platform Actions
tidas_sdk-0.6.0-py3-none-any.whl Python 3 none any Details for tidas_sdk-0.6.0-py3-none-any.whl

Total release size: 864.7 kB

Release files / tidas_sdk-0.6.0.tar.gz

Download URL tidas_sdk-0.6.0.tar.gz
Size 419.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ef028d8e871a1743bf4762f95350e919b05c15b15c04b8bddab012e04aaa0157
BLAKE2b-256 checksum
How to use checksums
daad6a407e555bd3a5983ed67717d9fe0f280a258414e601d6e2fdfbddb3b64c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / tidas_sdk-0.6.0-py3-none-any.whl

Download URL tidas_sdk-0.6.0-py3-none-any.whl
Size 445.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81585853c3971a7d72b0c46b84474b48dc18f8bba9dc53f7aec79f65015c0278
BLAKE2b-256 checksum
How to use checksums
76aeb5ec875eea255a63a050edf9e39f65b8aba0be8a80dec1c0a34eff353349
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for tidas-sdk 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tidas_sdk-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page