pyDIGGS
A Python package for Data Interchange for Geotechnical and Geoenvironmental Specialists (DIGGS).
- Licensed under the Apache License 2.0; see Licence and use for redistribution, bundled third-party material and professional use
- Documentation: https://xinp-hub.github.io/pydiggs
- GitHub: https://github.com/xinp-hub/pydiggs
- PyPI: https://pypi.org/project/pydiggs
- Release updates: Watch → Custom → Releases on this repository, the releases feed, or email (see Stay updated)
Authors
- Project lead: Xin Peng (xin_peng@outlook.com)
- Contributor: Asitha Senanayake (asitha.senanayake@utexas.edu)
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 theframes,polarsandgisextras,pydiggs.framesgives pandas or polars data frames andpydiggs.gisgives GeoDataFrames, GeoPackage and GeoParquet files. For reading, the public modules arepydiggs,pydiggs.model,pydiggs.crs,pydiggs.framesandpydiggs.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.xmlandpydiggs.diff.compare()list the boreholes, samples, tests and values that were added, removed or changed, whatever thegml: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 conformancemakes 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
- Machine-readable findings with stable rule ids, lines, XPaths and
- 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
serverextra, thenpydiggs serve --http, or mountpydiggs.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(nolatesttag) - 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
mcpextra, thenpydiggs 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)
- Python:
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
codeSpacethat 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.18.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydiggs-1.18.1.tar.gz | 4.4 MB | With provenance | Details for pydiggs-1.18.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydiggs-1.18.1-py3-none-any.whl | Python 3 | none | any | Details for pydiggs-1.18.1-py3-none-any.whl |
Total release size: 6.9 MB
Release files / pydiggs-1.18.1.tar.gz
| Download URL | pydiggs-1.18.1.tar.gz |
|---|---|
| Size | 4.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d96fd85f6089b7c406fc3d2d5985768db8ca702db191fbbc35b654dd7bf6fc8c
|
|
BLAKE2b-256 checksum How to use checksums |
a1ded77e4f756f445a629c213a9bf77be85825ad685651f78c9e3839e7afbde6
|
| 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 26, 2026.
Transparency logRelease files / pydiggs-1.18.1-py3-none-any.whl
| Download URL | pydiggs-1.18.1-py3-none-any.whl |
|---|---|
| Size | 2.5 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce84c61784b129f90786fa8f5a8259b7e063b5090f62dda89e31e84ae1419330
|
|
BLAKE2b-256 checksum How to use checksums |
2b0367230911e0fb87ef2792158d370c465e75f5df3ca3fb3dc42c2fbb9ea271
|
| 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 26, 2026.
Transparency logSecurity for pydiggs 1.18.1
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.
Attestation for pydiggs-1.18.1.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 26, 2026.
Transparency logA 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.