pudl_diff.report_schema
¶
The JSON Schema of the PUDL Diff JSON report, and its rendering as documentation.
The schema is generated from the report's Pydantic models, so it always matches the
code. A copy is committed at SCHEMA_PATH so that it can be linked to and used
without running any PUDL code, and a test checks that the copy is up to date. To
update it, run pixi run python -m pudl_diff.report_schema, which is also
what the pudl-diff-schema pre-commit hook does.
DOCS_PATH = REPO_ROOT / 'docs/report_schema.md'
module-attribute
¶
Where the committed documentation of the report's fields is.
REPO_ROOT = Path(__file__).parents[2]
module-attribute
¶
The root of the repository, when the package is installed from a checkout of it.
SCHEMA_PATH = REPO_ROOT / 'docs/_static/pudl_diff_report.schema.json'
module-attribute
¶
Where the committed copy of the report's JSON Schema is. It's published with the documentation.
main(schema_path=SCHEMA_PATH, docs_path=DOCS_PATH)
¶
Write the report's JSON Schema and its documentation, if they have changed.
Returns:
| Type | Description |
|---|---|
int
|
|
int
|
be used as a pre-commit hook, and |
Source code in src/pudl_diff/report_schema.py
report_docs_text()
¶
The text of the documentation of every field of the report, as Markdown.
Source code in src/pudl_diff/report_schema.py
report_json_schema()
¶
The JSON Schema of the JSON report, which every PudlDiffReport conforms to.
Generated from the report's models, so that the schema and the descriptions of
what each field means always match the code. It describes the report as it is
written (its serialization schema): fields that have a default value are
still always present, and fields derived from others, like
PudlDiffReport.is_identical, are listed and marked read-only.
Source code in src/pudl_diff/report_schema.py
report_json_schema_text()
¶
schema_models(schema, link=str)
¶
Flatten a report schema into a list of models, for rendering as documentation.
The report's own model comes first, followed by the models it refers to, in the
order that they're first mentioned. Each is a dictionary with its name,
description, and fields: a list of dictionaries with each field's
name, type, description and whether it is derived from other fields.
Source code in src/pudl_diff/report_schema.py
schema_type(spec, link=str)
¶
Describe the type of a property of the schema in a few words.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
JsonSchemaValue
|
The property's schema. |
required |
link
|
Callable[[str], str]
|
How to write the name of a model that the property refers to. |
str
|