Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 6 additions & 54 deletions python/codegen/codegen/jsonschema_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,12 @@
"jobs.SparkJarTask": ["main_class_name"],
}

# Burn-down list of upstream API descriptions that aren't valid reStructuredText
# and break the Sphinx docs build. Each entry is a temporary override until the
# proto comment is fixed upstream; remove it once the fix lands (the no-op guard
# in override_descriptions flags entries that upstream has already fixed).
#
# sql.SpotInstancePolicy: the upstream comment is a hard-wrapped ASCII grid table
# that docutils rejects as malformed. Rewritten as a list-table.
# See sqlgateway/scheduler/api/proto/endpoint_common.proto.
DESCRIPTIONS: dict[str, str] = {
"sql.SpotInstancePolicy": (
"EndpointSpotInstancePolicy configures whether the endpoint should use spot instances.\n"
"\n"
"The breakdown of how the EndpointSpotInstancePolicy converts to per cloud configurations is:\n"
"\n"
".. list-table::\n"
" :header-rows: 1\n"
"\n"
" * - Cloud\n"
" - COST_OPTIMIZED\n"
" - RELIABILITY_OPTIMIZED\n"
" * - AWS\n"
" - On Demand Driver with Spot Executors\n"
" - On Demand Driver and Executors\n"
" * - AZURE\n"
" - On Demand Driver and Executors\n"
" - On Demand Driver and Executors\n"
),
}

# Field-level counterpart to DESCRIPTIONS. Some upstream property descriptions
# aren't valid reStructuredText and break the Sphinx docs build. We can't render
# them and don't want to maintain a hand-copied RST version, so drop the
# description entirely until the proto comment is fixed upstream. Keyed by schema
# name, then the field names whose descriptions to drop. drop_field_descriptions
# flags entries that upstream has already fixed (the description is now empty).
# Burn-down list of upstream property descriptions that aren't valid
# reStructuredText and break the Sphinx docs build. We can't render them and don't
# want to maintain a hand-copied RST version, so drop the description entirely
# until the proto comment is fixed upstream. Keyed by schema name, then the field
# names whose descriptions to drop. drop_field_descriptions flags entries that
# upstream has already fixed (the description is now empty).
#
# jobs.DeploymentSpec.command_path: embeds a Markdown ```bash code fence, which
# docutils parses as an unterminated inline literal.
Expand Down Expand Up @@ -86,25 +57,6 @@ def add_extra_required_fields(schemas: dict[str, Schema]):
return output


def override_descriptions(schemas: dict[str, Schema]):
if missing := DESCRIPTIONS.keys() - schemas.keys():
raise ValueError(f"Cannot override description for unknown schemas: {missing}")

output = {}
for name, schema in schemas.items():
if override := DESCRIPTIONS.get(name):
if schema.description == override:
raise ValueError(
f"Description override for {name} is a no-op; the upstream "
"description was fixed, so remove the override"
)
output[name] = replace(schema, description=override)
else:
output[name] = schema

return output


def drop_field_descriptions(schemas: dict[str, Schema]):
if missing := DROP_FIELD_DESCRIPTIONS.keys() - schemas.keys():
raise ValueError(
Expand Down
1 change: 0 additions & 1 deletion python/codegen/codegen/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def main(output: str):
schemas = openapi.get_schemas()
schemas = openapi_patch.add_extra_required_fields(schemas)
schemas = openapi_patch.remove_unsupported_fields(schemas)
schemas = openapi_patch.override_descriptions(schemas)
schemas = openapi_patch.drop_field_descriptions(schemas)

schemas = _transitively_mark_deprecated_and_private(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading