Skip to main content

pyDIGGS

PyPI version Python Versions Downloads Downloads/Month Build Status Documentation Status GitHub Issues License

A Python package for Data Interchange for Geotechnical and Geoenvironmental Specialists (DIGGS).

Authors

Contributing

Contributions are welcome under the project's Apache-2.0 licence, with each commit signed off (git commit -s) under the Developer Certificate of Origin. See CONTRIBUTING.md.

Features

  • Validate DIGGS instance files against:
    • DIGGS XSD Schema (2.5.a, 2.6, 3.0.0) with namespace auto-detect (default profile 3.0.0 when the namespace is unknown)
    • DIGGS Standard dictionaries / codeSpace semantics (offline bundle from diggsml.org/def)
    • Schematron business rules (bundled DIGGS lxml-adapted rules by default)
    • Lightweight context checks (structure / SRS / xlink / dataBlock arity)
  • Read what is in a file: pydiggs.read() returns boreholes, samples, tests and their result tables as Python objects and as JSON (diggs-model 1.0), the same shape for DIGGS 2.5.a, 2.6 and 3.x (Reading files). With the frames, polars and gis extras, pydiggs.frames gives pandas or polars data frames and pydiggs.gis gives GeoDataFrames, GeoPackage and GeoParquet files. For reading, the public modules are pydiggs, pydiggs.model, pydiggs.crs, pydiggs.frames and pydiggs.gis.
  • AGS4: read, write and check AGS4 files against the AGS4 rules (pydiggs.ags4, pydiggs ags4 check), and convert AGS4 to DIGGS 3.0.0 and DIGGS to AGS4 (4.2 or 4.1.1) with every loss reported (pydiggs.convert, pydiggs convert, POST /v1/convert; AGS4 files, AGS4 and DIGGS conversion). No AGS dictionary or example file is bundled, and pyDIGGS is not an AGS-approved tool.
  • Compare two DIGGS files: pydiggs diff old.xml new.xml and pydiggs.diff.compare() list the boreholes, samples, tests and values that were added, removed or changed, whatever the gml:ids, the element order and the number formatting; a change of unit is always reported and nothing is converted (Comparing two files).
  • Test how software reads and writes DIGGS (preview): pydiggs conformance makes a seeded challenge, grades the DIGGS file your software exported (or the answers read from an imported file) on your own machine, and writes evidence anyone can re-run. A catalogue of every part of DIGGS 3.0.0 shows what is not testable yet (Testing DIGGS support).
  • Flexible validation output:
    • Machine-readable findings with stable rule ids, lines, XPaths and gml:ids, as JSON (diggs-findings 1.3) or SARIF 2.1.0 (pydiggs validate, validate())
    • Write validation errors to log files
    • Print validation errors directly to console
  • Command-line interface (CLI) for easy integration
  • Use it from any application:
    • Python: validate() for files, validate_bytes() for uploads and other in-memory data
    • Web apps: an HTTP API with OpenAPI 3.1 (the server extra, then pydiggs serve --http, or mount pydiggs.server.create_router() in FastAPI)
    • Containers: that HTTP API as a non-root, attested image for amd64 and arm64, ghcr.io/xinp-hub/pydiggs:X.Y.Z (no latest tag)
    • Desktop and native apps: a stdio JSON-RPC 2.0 sidecar (pydiggs serve --stdio) that any host language can drive
    • AI assistants: an MCP server with read-only tools to validate a document, explain rules, and read features, samples, tests and result tables (the mcp extra, then pydiggs serve --mcp)
    • Browsers: in a web page with Pyodide, so the file never leaves the user's machine (a dependency-free Web Worker example is in examples/browser-worker)

Security

pyDIGGS treats every DIGGS file as untrusted input. All XML is parsed with external entities, DTD loading and network access refused, so a file cannot make pyDIGGS read other local files or contact a server. There are two exceptions:

  • A codeSpace that points at a local dictionary (file:///, ./, ../). The DIGGS whitelist permits these, and pyDIGGS parses them with the same hardened settings.
  • With DictionarySemanticValidator(allow_network=True), which is off by default, pyDIGGS downloads dictionaries, but only from whitelisted http/https URLs, re-checked on every redirect, with time and size limits.

Schemas and Schematron rules are different: they are code, not data. A custom schema_path or schematron_path runs with your permissions (Schematron is compiled to XSLT, which can read local files), so only pass files you trust. The bundled DIGGS schemas and rules make no file or network access.

Log files are written to the working directory and are never written through a symlink. Vulnerabilities: please report them privately (see SECURITY.md).

Install from the PyPI wheels, which bundle libxml2, rather than building lxml against an older system libxml2.

Web Application

Not a Python user? Looking for leveraging the power of pyDIGGS in a modern web application? Check out:

Quick Start

Install pydiggs (requires Python 3.11+), then validate a file. The Quickstart walks through it:

uv tool install pydiggs   # or: python -m pip install pydiggs
pydiggs validate BH-01.xml

Basic usage with Python. uv tool install keeps pydiggs in its own environment, so to import it, add it to your project with uv add pydiggs (or pip) first:

from pydiggs import detect_diggs_version, validator

# Profile auto-detected from the instance namespace (unknown → 3.0.0)
validation = validator("path/to/your/diggs_file.xml")

print(detect_diggs_version("path/to/your/diggs_file.xml"))  # "2.5.a", "2.6", or "3.0.0"

# Or pin a profile explicitly (Python API only)
validation = validator("path/to/your/diggs_file.xml", diggs_version="2.6")

# Schema validation
validation.schema_check()

# Dictionary validation (DIGGSml semantic checks; offline dictionaries)
validation.dictionary_check()

# Schematron validation (bundled DIGGS rules by default)
validation.schematron_check()

# Context checks
validation.context_check()

# Or supply a custom Schematron file
validation = validator("path/to/your/diggs_file.xml", schematron_path="path/to/schematron.sch")
validation.schematron_check()

Every check at once, as machine-readable findings:

# JSON (diggs-findings 1.3); exit 0 = no errors, 1 = errors, 2 = usage/unreadable input
pydiggs validate --format json "path/to/your/diggs_file.xml"

# A whole folder as SARIF 2.1.0 for code-scanning tools
pydiggs validate --format sarif --output pydiggs.sarif "path/to/folder"
from pydiggs import validate

report = validate("path/to/your/diggs_file.xml")  # prints nothing, writes no files
print(report.ok, report.counts)
for finding in report.findings:
    print(finding.rule_id, finding.severity, finding.line, finding.xpath)

See findings for the format, rule ids, exit codes and privacy defaults (no snippets, no absolute paths).

Basic usage with CLI:

# Schema validation (auto-detects DIGGS 2.5.a / 2.6 / 3.0.0)
pydiggs schema_check "path/to/your/diggs_file.xml"

# Dictionary validation
pydiggs dictionary_check "path/to/your/diggs_file.xml"

# Schematron validation (bundled rules)
pydiggs schematron_check "path/to/your/diggs_file.xml"

# Context validation
pydiggs context_check "path/to/your/diggs_file.xml"

# Custom Schematron
pydiggs schematron_check "path/to/your/diggs_file.xml" --schematron_path "path/to/schematron.sch"

See usage for diggs_version / schema_path overrides, log output options, and known limits (dictionary check 12 as WARNING, bundled Schematron subset, and more).

For more detailed information and advanced usage, please see the documentation.

Metadata

Release files for pydiggs 1.17.0

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

Source distribution (sdist)

Source distribution for pydiggs 1.17.0
File Size Uploaded Provenance Actions
pydiggs-1.17.0.tar.gz 4.3 MB With provenance Details for pydiggs-1.17.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pydiggs 1.17.0
File Interpreter ABI Platform Actions
pydiggs-1.17.0-py3-none-any.whl Python 3 none any Details for pydiggs-1.17.0-py3-none-any.whl

Total release size: 6.7 MB

Release files / pydiggs-1.17.0.tar.gz

Download URL pydiggs-1.17.0.tar.gz
Size 4.3 MB
Tags Source
SHA-256 checksum
How to use checksums
960535473ba81297e8848cae701af2948b0a22a7713aba8ae347e978cd5b74cf
BLAKE2b-256 checksum
How to use checksums
6c9e0d69818d761a56216634dae96b3672398997f1c3aac474c2f2e99b374b2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / pydiggs-1.17.0-py3-none-any.whl

Download URL pydiggs-1.17.0-py3-none-any.whl
Size 2.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
cd17fbba99c789265a9fdb676d670c227f9bf8b0236414d2499c297804c33fc7
BLAKE2b-256 checksum
How to use checksums
71f37a5405f6f0bcb4027e0a24ebedef7456103dcc47fdc382509b1a1f9c1f11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for pydiggs 1.17.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pydiggs-1.17.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

1.17.0 This release

2 release files Full provenance

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