The official Python implementation of the WeMush Open Labeling Standard (WOLS) v1.1.0 for specimen tracking in mushroom cultivation.
- Core Module: Create, parse, validate, and serialize specimen labels
- QR Codes: Generate and scan QR codes (PNG, SVG, base64)
- Encryption: AES-256-GCM encryption for sensitive data
- CLI: Command-line interface for all operations
- Type Safe: Full type annotations with PEP 561 support
# Using UV (recommended)
uv add wols
# Using pip
pip install wols# QR code support
uv add "wols[qr]"
# CLI support
uv add "wols[cli]"
# Encryption support
uv add "wols[crypto]"
# Everything
uv add "wols[all]"- Python 3.12 or later
- No required dependencies for core module
The WOLS CLI is also available as a container image:
# Pull the latest image
docker pull ghcr.io/wemush/specimen-labels-py:latest
# Run the CLI
docker run --rm ghcr.io/wemush/specimen-labels-py --version
# Create a specimen
docker run --rm ghcr.io/wemush/specimen-labels-py create \
--species "Pleurotus ostreatus" \
--type SUBSTRATE \
--json
# Validate a specimen (mount local file)
docker run --rm -v $(pwd):/data ghcr.io/wemush/specimen-labels-py \
validate /data/specimen.json
# Generate QR code
docker run --rm -v $(pwd):/data ghcr.io/wemush/specimen-labels-py \
qr /data/specimen.json --output /data/label.pngfrom wols import create_specimen, SpecimenType, GrowthStage, to_json
# Create a specimen
specimen = create_specimen(
type=SpecimenType.SUBSTRATE,
species="Pleurotus ostreatus",
strain="Blue Oyster",
stage=GrowthStage.COLONIZATION,
batch="BATCH-2026-001",
)
# Print the ID
print(f"Created: {specimen.id}")
# Output: Created: wemush:clx1abc123def456
# Serialize to JSON-LD
json_str = to_json(specimen, indent=2)
print(json_str)wols create \
--species "Pleurotus ostreatus" \
--type SUBSTRATE \
--strain "Blue Oyster" \
--stage COLONIZATION \
--output specimen.jsonfrom wols import create_specimen, SpecimenType
from wols.qr import generate_qr_png
specimen = create_specimen(
type=SpecimenType.SUBSTRATE,
species="Pleurotus ostreatus",
)
# Generate QR code
qr_bytes = generate_qr_png(specimen)
# Save to file
with open("label.png", "wb") as f:
f.write(qr_bytes)from wols import validate_specimen, parse_specimen
json_str = '{"@context": "...", "@type": "Specimen", ...}'
specimen = parse_specimen(json_str)
result = validate_specimen(specimen)
if result.valid:
print("Valid specimen!")
else:
for error in result.errors:
print(f"{error.path}: {error.message}")wols validate specimen.jsonAfter installation, verify the library works:
# Check version
python -c "import wols; print(wols.__version__)"
# Check CLI (if installed)
wols --version
# Run a quick test
python -c "
from wols import create_specimen, SpecimenType, to_json
s = create_specimen(type=SpecimenType.CULTURE, species='Test')
print('Success:', s.id)
"# Clone the repository
git clone https://github.com/wemush/specimen-labels-py.git
cd specimen-labels-py
# Install with development dependencies
uv sync --all-extras
# Run tests
uv run pytest
# Run linting
uv run ruff check src tests
uv run ruff format --check src tests
# Run type checking
uv run mypy srcThe demo GIF is generated using VHS:
# Install VHS (macOS)
brew install vhs
# Regenerate the demo
cd demo
vhs demo.tapeApache 2.0 License - see LICENSE for details.
