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 each schedule payload before any event data is read.
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
Any
required
Decoded JSON payload to validate.
payloadis a dict.payload["schema_version"]equals1.payload["years"]is a dict.- Every key in
yearsis a string of digits, for example"2025". - Every value in
yearsis a dict. - For every year:
eventsis a list of strings. - For every year:
sessionsis a dict. - For every event name in
events:sessions[event_name]is a list of strings.
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. A validation failure stops event and schedule lookups before they read malformed data.
Related APIs
- Events API: the event schedule built on this validator
- Schedule API: schedule data access
- Validation API: pydantic validators for session payloads
- Exceptions API:
InvalidDataErrorand the exception hierarchy