Skip to main content

Contains all the python boilerplate you need to create a Brightway ecosystem package.

Project description

trailpack

PyPI Status Python Version License

Read the documentation at https://trailpaack.readthedocs.io/ Tests Codecov

pre-commit Black

Installation

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

$ pip install trailpack

Usage

Web UI

Trailpack includes a Streamlit-based web UI for mapping Excel columns to PyST concepts:

# Run the UI
streamlit run trailpack/ui/streamlit_app.py

Or using the run script:

python trailpack/ui/run_streamlit.py

The UI provides a 3-step workflow with smooth transitions:

  1. Upload File & Select Language: Upload an Excel file and select language for PyST mapping
  2. Select Sheet: Choose which sheet to process with data preview
  3. Map Columns: Map each column to PyST concepts with automatic suggestions and dataframe preview

The view object is stored internally for further processing.

For more details, see trailpack/ui/README.md.

Deploying to Streamlit Cloud? See STREAMLIT_DEPLOYMENT.md for complete deployment instructions.

Python API

You can also use trailpack programmatically:

from trailpack.excel import ExcelReader
from trailpack.pyst.api.client import get_suggest_client

# Read Excel structure
reader = ExcelReader("data.xlsx")
sheets = reader.sheets()
columns = reader.columns("Sheet1")

# Get PyST suggestions
client = get_suggest_client()
suggestions = await client.suggest("carbon footprint", "en")

✨ New: UI-Ready DataPackage Schema Classes

This project now includes comprehensive schema classes for building data package metadata through user interfaces:

Key Features

  • DataPackageSchema: Defines field types, validation rules, and UI configuration
  • MetaDataBuilder: Fluent interface for creating metadata programmatically
  • Field validation: Built-in validation for package names, versions, URLs
  • UI integration ready: Field definitions include labels, placeholders, patterns
  • Standards compliant: Follows Frictionless Data Package specification

Quick Example

from trailpack.datapackage_schema import MetaDataBuilder, Resource, Field

# Create metadata with fluent interface
metadata = (MetaDataBuilder()
    .set_basic_info(name="my-dataset", title="My Dataset")
    .add_license("CC-BY-4.0")
    .add_contributor("Your Name", "author")
    .add_resource(Resource(name="data", path="data.parquet"))
    .build())

# Use with existing Packing class
from trailpack.packing import Packing
packer = Packing(df, metadata)
packer.write_parquet("output.parquet")

UI Integration

The schema classes provide everything needed for UI frameworks:

  • Field definitions with types, labels, validation patterns
  • Enumerated options for dropdowns (licenses, profiles, etc.)
  • Built-in validation methods
  • Error messages for invalid input

See examples/datapackage_ui_demo.py for detailed usage examples.

Contributing

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

License

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

Issues

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

Building the Documentation

You can build the documentation locally by installing the documentation Conda environment:

conda env create -f docs/environment.yml

activating the environment

conda activate sphinx_trailpaack

and running the build command:

sphinx-build docs _build/html --builder=html --jobs=auto --write-all; open _build/html/index.html

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

trailpack-0.1.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

trailpack-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file trailpack-0.1.0.tar.gz.

File metadata

  • Download URL: trailpack-0.1.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for trailpack-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e3356e0675905420f6a7efeb76cd1d6065f46ff7d3918e0b8ba6731bdc8d655b
MD5 18ea6ea600aad7fb149c4c17178997cb
BLAKE2b-256 966b25f421a53c04e7ccde055d492bfe4c453f49ab28f6bac68b1f732a4bd941

See more details on using hashes here.

Provenance

The following attestation bundles were made for trailpack-0.1.0.tar.gz:

Publisher: python-package-deploy.yml on TimoDiepers/trailpack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trailpack-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: trailpack-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for trailpack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a764d5368903b94af80d524934fa1f58c996d664f9be1328a3b21ae27047525
MD5 4c5592bac1123499a8b6ab14aeacaa2b
BLAKE2b-256 75378b477f7d7808dc45e52e3297e70216139d7511eb95a4c6acb774a42308d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for trailpack-0.1.0-py3-none-any.whl:

Publisher: python-package-deploy.yml on TimoDiepers/trailpack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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