Skip to main content

pcq - contract runtime + agent CLI surface for CQ ML experiments

Project description

pcq

Apache-2.0 Python library for agent-operable experiment evidence and control. Bring any training code; pcq standardizes the run boundary.

pcq turns a project with cq.yaml into a reproducible experiment unit. It loads config, resolves output paths, captures metrics, writes standard artifacts, finalizes run evidence, and exposes JSON/JSONL surfaces that coding agents, CI jobs, notebooks, and services can consume.

pcq is not a training framework, model zoo, adapter matrix, or CQ-only client. Use PyTorch, Hugging Face Trainer, Lightning, sklearn, TabPFN, PyCaret, XGBoost, shell scripts, remote jobs, or project-local research code. The contract is the integration layer.

pcq does not operate the model.
pcq operates the experiment boundary.

SITE | INTRODUCTION | V4_DIRECTION | SPEC | VISION | AGENT_OPERABILITY | RUN_RECORD | CQ_YAML_RUNTIME_CONTRACT | JSON_CONTRACTS | STRICTNESS | AGENT_OPERATING_GUIDE | CHANGELOG

Agent-readable site files: llms.txt, llms-full.txt, agent-manifest.json.

Identity

pcq = open-source experiment evidence/control library
cq  = managed execution + orchestration + dashboard + agent loop

CQ service is one managed consumer of the contract. pcq remains useful without CQ: locally, in CI, in notebooks, and inside third-party orchestrators.

Why pcq

  • Framework-neutral — keep the training stack that fits the problem.
  • Agent-readable — use JSON/JSONL instead of terminal scraping.
  • Agent-verifiable — validate source, config, environment, metrics, artifacts, and run records.
  • Agent-operable — run, observe, validate, describe, compare, lineage, and iterate through stable commands.
  • Service-ready — CQ can consume the same contract for managed execution and automatic experiment loops.

Installation

uv add pcq

pyproject.toml:

[project]
dependencies = ["pcq"]

For a tag, branch, or private fork:

[tool.uv.sources]
pcq = { git = "https://github.com/playidea-lab/pcq.git", tag = "v3.0.4" }

The PyPI distribution, import name, CLI command, GitHub repository, runtime workspace, and JSON contract namespace are all pcq. Runtime contract names from CQ remain stable: cq.yaml, CQ_CONFIG_JSON, and cq://.

Minimal Contract

cq.yaml declares the run:

name: sklearn-baseline
cmd: uv run python train.py
configs:
  output_dir: output
  seed: 42
  strictness: 3
  monitor: eval_acc
  mode: max
metrics:
  - epoch
  - eval_acc
artifacts:
  - output/
inputs: {}

train.py can use any framework:

import pickle

import pcq
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split

cfg = pcq.config()
out = pcq.output_dir()
pcq.seed_everything(cfg.get("seed", 42))

x, y = load_iris(return_X_y=True)
x_train, x_eval, y_train, y_eval = train_test_split(
    x,
    y,
    test_size=0.25,
    random_state=int(cfg.get("seed", 42)),
    stratify=y,
)

model = RandomForestClassifier(random_state=int(cfg.get("seed", 42)))
model.fit(x_train, y_train)
eval_acc = float(model.score(x_eval, y_eval))

with (out / "model.pkl").open("wb") as f:
    pickle.dump(model, f)

history = [{"epoch": 0, "eval_acc": eval_acc}]
pcq.log(**history[-1])
pcq.save_all(history=history, artifacts={"model": "model.pkl"})

No sklearn adapter is required. The same pattern works for HF Trainer, Lightning, XGBoost, TabPFN, PyCaret, shell commands, or custom code.

Agent Command Surface

Read and validate the project:

pcq resolve --json
pcq inspect . --json
pcq validate . --strictness 2 --json

Run the project:

pcq run --path . --json
pcq run --path . --jsonl
pcq run --path . --events output/events.jsonl --json

Validate and summarize outputs:

pcq validate-run output --strictness 3 --json
pcq describe-run output --json
pcq compare-runs old_output new_output --json
pcq lineage output --json

Iterate:

pcq apply-plan experiment.plan.json --json

Agent rule: prefer JSON/JSONL surfaces over scraping human output. pcq reports facts; the agent or service chooses policy.

Standard Artifacts

A completed run should produce:

  • config.json
  • metrics.json
  • manifest.json
  • run_summary.json
  • run_record.json
  • validation_report.json

run_record.json is the canonical completion object. It combines execution, source, environment, input identity, metric schema, artifact manifest, agent provenance, validation, and summary evidence.

Agent Runtime Assets

pcq can install its canonical agent instructions and skill into a project. Package installation itself never mutates project agent files.

pcq agent install --target codex --path .
pcq agent install --target claude --path .
pcq agent install --target both --path . --dry-run --json
pcq agent status --target both --path . --json

Reusable assets:

v4 Direction

v4 clarifies the product boundary:

  • contract-first workflow, not a 3-tier training API
  • project-local training code, not built-in production catalogs
  • contract scripts, not framework adapters
  • run evidence validation, not recipe ownership
  • JSON/JSONL facts, not prose parsing

See pcq v4 Direction.

Development

uv run ruff check src/ tests/ scripts/
uv run python -m compileall src/pcq
uv run pytest tests/ -q
bash scripts/release-smoke.sh

License

Apache-2.0.

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

pcq-4.0.0.tar.gz (263.0 kB view details)

Uploaded Source

Built Distribution

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

pcq-4.0.0-py3-none-any.whl (104.8 kB view details)

Uploaded Python 3

File details

Details for the file pcq-4.0.0.tar.gz.

File metadata

  • Download URL: pcq-4.0.0.tar.gz
  • Upload date:
  • Size: 263.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pcq-4.0.0.tar.gz
Algorithm Hash digest
SHA256 24db52affe9f7b03da403bc69d9c21af6fb48dd147258a0e2d0ff23804babdd9
MD5 6a58f9ee799218e1dc0608ebeac7349b
BLAKE2b-256 2d57ebab6c22d4164b0cdd48495e7f98cf2a86566c80be57162b235fdcd41fe0

See more details on using hashes here.

File details

Details for the file pcq-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: pcq-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 104.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pcq-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7db884cdf46b2ae9de1e39e5547f7d76ad3e9fe6af3bb7ed38c082f54d4c41c0
MD5 1aa4cecaaf6f7aece57e925cff142f24
BLAKE2b-256 50de95b53f54462be5e5418707507e5989e26fed7d46be58c1cdabf320751a9a

See more details on using hashes here.

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