Skip to main content

compipar-validator

Small, dependency-free validator for Compi test parameter files.

It reads compi.parameters and the optional parameters.metadata.json file used by Compi pipelines, evaluates cross-parameter validation rules, and reports warnings or strict errors.

The package has no GUI dependencies and can be used from Python or from the compipar-validate command line.

Installation

pip install .

For development:

pip install -e ".[dev]"

Supported rules

The top-level validations array in parameters.metadata.json accepts:

{
  "schema_version": 1,
  "parameters": {},
  "validations": [
    {
      "id": "one-of-input",
      "type": "exactly_one",
      "parameters": ["targetFasta", "targetDir"],
      "strict": true
    },
    {
      "id": "optional-mutual-exclusion",
      "type": "at_most_one",
      "parameters": ["modeA", "modeB"]
    },
    {
      "id": "custom-db",
      "type": "requires",
      "when": "useCustomDb",
      "require": ["dbPath", "dbVersion"],
      "message": "When useCustomDb is active, dbPath and dbVersion are required."
    }
  ]
}

Rule types:

  • exactly_one: exactly one parameter in the group must be active.
  • at_most_one: zero or one parameter in the group may be active.
  • requires: when when is active, every parameter in require must be active.

A parameter is active when:

  • it is a flag and it is present;
  • or its value is non-empty and is not one of FALSE, 0, 0.0, NO, OFF, NONE, NULL.

Non-strict rules produce warnings. Strict rules make the result invalid.

Python API

from pathlib import Path

from compipar_validator import validate_files

result = validate_files(
    Path("parameters.metadata.json"),
    Path("compi.parameters"),
)

if result.valid:
    print("Parameters are valid")
else:
    for violation in result.strict_violations:
        print(f"ERROR [{violation.constraint_id}]: {violation.message}")

Lower-level API:

from compipar_validator import (
    evaluate_constraints,
    load_metadata,
    parse_parameters,
    validate_values,
)

document = load_metadata("parameters.metadata.json")
values = parse_parameters("compi.parameters")
result = validate_values(values, document)

load_metadata also exposes metadata problems through document.metadata_issues. Invalid validation rules are reported and ignored; the rest of the rules are still evaluated.

CLI

compipar-validate \
  --metadata parameters.metadata.json \
  --params compi.parameters

Options:

--metadata PATH   parameters.metadata.json
--params PATH     compi.parameters
--json            Machine-readable output on stdout
--quiet           Suppress non-strict warnings
--version         Show the package version

Exit codes:

Code Meaning
0 Valid, or only non-strict warnings
1 At least one strict violation
2 Invalid inputs or arguments
3 Internal error

Example JSON output:

{
  "valid": false,
  "violations": [
    {
      "id": "one-of-input",
      "message": "Exactly one of these parameters must be active: targetFasta, targetDir.",
      "strict": true
    }
  ],
  "metadata_issues": []
}

Development

ruff check src tests
mypy src
pytest
python -m build

License

MIT

Metadata

Release files for compipar-validator 0.1.2

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

Source distribution (sdist)

Source distribution for compipar-validator 0.1.2
File Size Uploaded Provenance Actions
compipar_validator-0.1.2.tar.gz 13.7 kB Without provenance Details for compipar_validator-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for compipar-validator 0.1.2
File Interpreter ABI Platform Actions
compipar_validator-0.1.2-py3-none-any.whl Python 3 none any Details for compipar_validator-0.1.2-py3-none-any.whl

Total release size: 26.2 kB

Release files / compipar_validator-0.1.2.tar.gz

Download URL compipar_validator-0.1.2.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b8bf965d32a9d20c40a78089fd6c1fae2f3a9c1e363845015dd9e11eb41c211c
BLAKE2b-256 checksum
How to use checksums
ab77c43765bf067dcfba67d8ccc2d3f4467f5a8b2c273e95ed371081502ed23c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.11

Release files / compipar_validator-0.1.2-py3-none-any.whl

Download URL compipar_validator-0.1.2-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0368e9af5db5e74fe5b263e74982dd799d1e7e84caef8e6d9d7f1046f1b141e7
BLAKE2b-256 checksum
How to use checksums
22af97cd1e90d7d1e830795ef61dcad4db9754febc5f7fbad42bfb79afe4d769
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.11

Security for compipar-validator 0.1.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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