Domain-specific language and toolchain for electrochemical procedures
Project description
ecproc
A domain-specific language and toolchain for defining, validating, compiling, and executing electrochemical procedures.
Overview
ecproc provides a complete pipeline for electrochemical experiment specification:
- Author procedures in YAML (
.ecproc) or programmatically via the Python SDK - Parse into a typed Abstract Syntax Tree (AST) with source-location tracking
- Generate a validated Faraday Intermediate Representation (
.ir.json) with SI unit normalization - Validate across 4 layers: syntax, electrochemistry, safety, and hardware compatibility
- Compile to execution targets (Python runtime or human-readable manual)
- Execute against real or mock potentiostat hardware
- Record results as provenance-complete ECDL documents (
.ecdl.json)
Who it's for
- Electrochemists — write procedures in YAML with human-readable units (
50 mV/s,1 mA,60 s) - ML/Data Engineers — build procedures programmatically via the Python SDK for automated DOE campaigns
- Lab Managers — generate reproducible lab manuals in Markdown/PDF from the same procedure definition
Architecture
.ecproc (YAML) ──┐ ┌── Python Runtime
├─→ AST ─→ Faraday IR ─→ Validate ─┤
SDK (Python) ──┘ └── Manual (Markdown/PDF)
│
▼
ECDL Record
| Module | Purpose | Files |
|---|---|---|
parser |
YAML + Python SDK parsing → AST | 4 |
ir |
AST → Faraday IR with SI normalization | 4 |
validator |
4-layer validation engine | 6 |
sdk |
Programmatic procedure builder | 16 |
targets |
Compilation + execution backends | 12 |
ecdl |
Output record generation + validation | 5 |
protocols |
Standard protocol templates (DOE, JRC) | 6 |
hardware_profiles |
Potentiostat capability profiles | 7 |
cli |
8 CLI commands via Typer | 8 |
utils |
Units, time parsing, logging | 3 |
86 source files, ~6,600 lines of production code.
Installation
pip install ecproc
For development:
pip install -e ".[dev]"
Quick Start
YAML (.ecproc)
metadata:
protocol: Simple CV
version: "1.0"
system:
electrodes: 3
reference: RHE
procedure:
- name: Conditioning
steps:
- cv:
between: 0.05 V and 1.2 V
rate: 50 mV/s
cycles: 20
Python SDK
from ecproc import Procedure
proc = Procedure("Simple CV", version="1.0")
proc.system(electrodes=3, reference="RHE")
with proc.phase("Conditioning") as p:
p.cv(between="0.05 V and 1.2 V", rate="50 mV/s", cycles=20)
result = proc.validate()
CLI
ecproc parse my_procedure.ecproc # Parse and display AST
ecproc validate my_procedure.ecproc # Validate (L1-L4)
ecproc compile my_procedure.ecproc # Compile to Python target
ecproc run my_procedure.ecproc # Parse → validate → execute
ecproc execute my_procedure.ecproc # Execute pre-compiled IR
ecproc manual my_procedure.ecproc # Generate lab manual (Markdown)
ecproc convert my_procedure.ecproc # Convert between formats
ecproc version # Show version
Validation Levels
| Level | Name | Rules | Checks |
|---|---|---|---|
| L1 | Syntax | SYN001–SYN005 | Required fields, valid techniques, type correctness |
| L2 | Electrochemistry | PV001–PV013, DR001–DR011 | Parameter bounds, domain rules, electrochemical constraints |
| L3 | Safety | SF001–SF007 | Voltage/current/temperature limits, thermal runaway detection, reference electrode monitoring |
| L4 | Hardware | HW001–HW003 | Potentiostat capability matching, technique support, range verification |
Validation stops early on L1 errors (structural problems) before running L2+ checks.
Supported Techniques
| Technique | YAML Key | SDK Method | Description |
|---|---|---|---|
| Cyclic Voltammetry | cv |
p.cv() |
Potential sweep between vertices |
| Linear Sweep | lsv |
p.lsv() |
Single-direction potential sweep |
| Open Circuit Potential | ocp |
p.ocp() |
Monitor OCP over time |
| Chronoamperometry | ca / hold |
p.hold() |
Potentiostatic hold |
| Chronopotentiometry | cp / galvanostatic |
p.galvanostatic() |
Galvanostatic hold |
| EIS | eis |
p.eis() |
Electrochemical impedance spectroscopy |
| Differential Pulse | dpv |
p.dpv() |
Differential pulse voltammetry |
| Square Wave | swv |
p.swv() |
Square wave voltammetry |
| Galvanostatic Cycling | gcd |
p.gcd() |
Charge/discharge cycling |
| Constant Current | cc |
p.cc() |
Constant current hold |
| Stripping | stripping |
p.stripping() |
Stripping voltammetry |
| Purge | purge |
p.purge() |
Gas purge step |
Unit Convention
| Layer | Units | Example |
|---|---|---|
| YAML / Display | Human-friendly | 50 mV/s, 1 mA, 10 cm², 0.1 M, 100 kHz |
| Faraday IR | SI base | 0.05 V/s, 0.001 A, 0.001 m², 100 mol/m³, 100000 Hz |
| Temperature | °C in both | Electrochemistry convention |
The IR generator handles all unit conversions automatically.
Hardware Profiles
Built-in profiles for common potentiostats:
- Gamry Interface 1010E / 1010B
- BioLogic SP-300
- PalmSens4
- Pine WaveDrive
- Mock (for testing/dry-run)
Profiles define supported techniques, voltage/current ranges, and frequency limits for L4 validation.
Standard Protocols
Pre-built protocol templates following published standards:
- DOE — ORR catalyst, OER catalyst, catalyst support durability
- JRC — PEM electrolysis, alkaline electrolysis
Quality
| Metric | Value |
|---|---|
| Tests | 1,196 |
| Coverage | 100% |
| Type checking | mypy --strict, 0 errors |
| Linting | ruff, 0 violations |
Development
# Install in development mode
pip install -e ".[dev]"
# Run all quality gates
make all # lint + typecheck + test
# Individual commands
make test # pytest with coverage
make lint # ruff check + format check
make typecheck # mypy --strict
make fmt # auto-fix lint + format
make clean # remove caches
Project Structure
ecproc/
├── src/ecproc/
│ ├── cli/ # 8 CLI commands (Typer)
│ ├── ecdl/ # ECDL record generation + validation
│ ├── hardware_profiles/ # Potentiostat JSON profiles
│ ├── ir/ # Faraday IR schema, generator, serializer
│ ├── parser/ # YAML + Python SDK parsers → AST
│ ├── protocols/ # DOE + JRC standard protocol templates
│ ├── sdk/ # Programmatic procedure builder + techniques
│ ├── targets/ # Python runtime + manual (Markdown/PDF)
│ ├── utils/ # Units, time, logging
│ └── validator/ # 4-layer validation engine
├── tests/ # 1,196 tests across 57 test files
├── schemas/ # JSON schemas (ECDL, Faraday IR, ecproc, hardware)
├── examples/ # Example .ecproc, .py, and .ecdl.json files
├── docs/ # MkDocs documentation
└── .github/workflows/ # CI: test, lint, docs, release
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ecproc-0.1.0.tar.gz.
File metadata
- Download URL: ecproc-0.1.0.tar.gz
- Upload date:
- Size: 181.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f362aea6eedd4513c77a29d6880d7ef7a4eecefb1ec5f7f51aa9242597c1a1ff
|
|
| MD5 |
30cc50da7fe25065568d55e8562832b4
|
|
| BLAKE2b-256 |
6a759de53ddec5bb33130c7cc99ad5f25bab9ba0f50cc5ae32ff045ba1e610d6
|
File details
Details for the file ecproc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ecproc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 97.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6d5511b0cb844bdb4be6879532e43bdd4d8367594262d0316068a710fdc648e
|
|
| MD5 |
f4f221b3dc3e262683dd94a1a501c8a7
|
|
| BLAKE2b-256 |
3d049232d767279a34945ebb838edc3c8c96c972ee0203c05d4b239492fd5b71
|