Skip to main content

Validator for Transit Operational Data Standard (TODS) feeds, formerly the Operational Data Standard (ODS)

Project description

tods-validate

A validator for Transit Operational Data Standard (TODS) feeds, with a CLI and a GitHub Action.

TODS is an open standard for describing scheduled transit operations: crew runs, deadheads, vehicle assignments, and other non-public service that GTFS does not cover. It works as an overlay on an agency's GTFS feed. The standard was originally published by Cal-ITP as the Operational Data Standard (ODS) and is now maintained with MobilityData under its current name. This validator checks feeds against the current spec, TODS v2.1.0.

tods-validate reads a TODS package, checks it against the spec, and reports findings in language a scheduler can act on. Each finding says what is wrong, where, and what good looks like, and cites the spec section it comes from.

Install

Requires Python 3.11 or newer.

pipx install tods-validate

or pip install tods-validate into an environment of your choice.

Usage

Point it at the directory or .zip file containing your TODS files. If your GTFS feed lives in a separate file, pass it with --gtfs so trip, stop, service, and block references can be checked:

tods-validate exports/tods/ --gtfs exports/gtfs.zip

When the TODS files sit next to the GTFS files in one package, the GTFS files are picked up automatically:

$ tods-validate /tmp/demo-feed
tods-validate: /tmp/demo-feed (TODS v2.1.0)

2 errors:
  ERROR TODS-E203 [run_events.txt, row 4, field 'end_time']
    run_events.txt row 4: end_time is '9:45', which is not a valid time. Use HH:MM:SS, e.g. '09:45:00' or '25:10:00' for 1:10 AM the next service day.
  ERROR TODS-E307 [run_events.txt, row 4, field 'trip_id']
    run_events.txt row 4: trip_id 'WKDY-1002' does not exist in the companion GTFS trips.txt (after applying trips_supplement.txt). Run events that represent work on a trip must reference a scheduled trip.
    Fix: Correct the trip_id, or add the trip via trips_supplement.txt if it is non-revenue service.

Summary: 2 error(s), 0 warning(s), 0 info.
$ echo $?
1

The exit code is 0 when no errors are found, 1 when there are errors, and 2 when the package cannot be read at all. Warnings do not fail the run unless you pass --fail-on warning.

Other output formats:

  • --format json prints a stable JSON document for tooling.
  • --format github prints GitHub Actions workflow annotations.

References into GTFS are resolved after applying the supplement files, so a trip added by trips_supplement.txt is a valid target for run_events.trip_id, and a stop deleted by stops_supplement.txt is not.

GitHub Action

If your TODS export lives in a repository, this workflow validates it on every pull request and annotates findings inline:

name: Validate TODS feed
on: [pull_request]
jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ChelseaKR/tods-validate@v0
        with:
          path: feed/tods
          gtfs: feed/gtfs        # omit if GTFS files sit next to the TODS files

Rules

The full catalog of checks, with IDs, severities, and spec citations, is in docs/rules.md. Rule IDs are stable: a CI pipeline can safely filter or suppress specific IDs.

Ambiguities in the spec discovered while building the validator are tracked in docs/spec-questions.md.

What this does not check

tods-validate validates the TODS files and their references into the companion GTFS feed. It does not re-validate the GTFS feed itself, and it does not check that the merged ("TODS-Supplemented") GTFS dataset is valid GTFS. For those, run MobilityData's gtfs-validator, optionally on the merged feed.

Development

git clone https://github.com/ChelseaKR/tods-validate
cd tods-validate
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
pytest

Lint and type-check with ruff check src tests scripts and mypy. The rule catalog is generated: after adding or changing a rule, run python scripts/generate_rules_doc.py and commit the result; CI fails if it drifts.

License

Apache-2.0, matching the TODS specification repository.

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

tods_validate-0.1.0.tar.gz (43.1 kB view details)

Uploaded Source

Built Distribution

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

tods_validate-0.1.0-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file tods_validate-0.1.0.tar.gz.

File metadata

  • Download URL: tods_validate-0.1.0.tar.gz
  • Upload date:
  • Size: 43.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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 tods_validate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 38607da7bd32def4ba9e789ab16a4648071126019f6cdd6ef8e169fd1738c78f
MD5 acd082b81c5c50b1fed97199e94efe82
BLAKE2b-256 32b0e9604d82ea1f82bc9cbcab97bc29595a135d628238dd8fd8df0f1572bc9e

See more details on using hashes here.

File details

Details for the file tods_validate-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tods_validate-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","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 tods_validate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e50ad51b5227df3389e3a0a5b1ccf95e89c85d3719342786e1f50922977f9e41
MD5 c57d51dacd7a48369bebcdf09dcac875
BLAKE2b-256 f8833a334d9ba5b9e3e25350a83832e89dd97069def6dc12cb487411ed69169d

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