schedule_schema module validates the shape of packaged F1 schedule payloads. It contains one function, validate_schedule_payload. The tif1.events module calls it on the combined payload of the packaged schedule files the first time it reads them.
Overview
A schedule payload is a dict with this shape:metadata key holds per-event metadata. The validator does not check its contents.
validate_schedule_payload
payloadis a dict.payload["schema_version"]equals1.payload["years"]is a dict.
- The key is a string of digits, for example
"2025". - The value is a dict.
eventsis a list of strings.sessionsis a dict.- For every event name in
events:sessions[event_name]is a list of strings. An empty list passes.
InvalidDataError with a reason string that names the problem and, where possible, the year and event involved. The module raises no other exception type.
Example
This example runs offline.Error messages
Each failed check has its own reason string:Where tif1 uses it
tif1.events loads the packaged schedule files from tif1/data/schedules/f1schedule/schedule_{year}.json and converts each year to the shape above. validate_schedule_payload then validates the combined payload, once per process. A validation failure stops event and schedule lookups before they read malformed data. The current season, future seasons, and years outside the packaged files come from the live theOehrly/f1schedule repository and skip this validator. Only the conversion step checks them. A live season that falls back to its packaged file reads it from the validated payload.
Related APIs
- Events API: the event schedule built on this validator
- Schedule Schema & Validation: validation rules, schedule data sources, and longer examples
- Validation API: pydantic validators for session payloads
- Exceptions API:
InvalidDataErrorand the exception hierarchy