Skip to content

fix: static schema gen#2948

Merged
markphelps merged 5 commits intomainfrom
mphelps/fix-static-schema-gen
Apr 20, 2026
Merged

fix: static schema gen#2948
markphelps merged 5 commits intomainfrom
mphelps/fix-static-schema-gen

Conversation

@markphelps
Copy link
Copy Markdown
Contributor

This pull request introduces several improvements and bug fixes to the Dockerfile generation, OpenAPI schema generation, and Python static analysis for the project. The most significant changes include reordering Dockerfile steps for better caching, refining OpenAPI schema handling for default values and enum naming, and enhancing the static parser to resolve descriptions from module-level variables. Additionally, the test harness now builds Docker images sequentially to avoid resource exhaustion.

Dockerfile Generation Improvements

  • Reordered installation steps in StandardGenerator to install user Python packages before the SDK, improving Docker cache efficiency and reducing rebuild times when the SDK changes. Test expectations were updated to match this new order. [1] [2] [3] [4] [5] [6] [7]

OpenAPI Schema Generation Fixes

  • Changed enum schema naming to use the parameter name as-is (lowercase), ensuring consistency with runtime schema generation and fixing references in both code and tests. [1] [2] [3] [4]
  • Improved handling of default values: fields with default=None are only considered to have a default if they are optional, matching runtime behavior. Added tests to ensure required fields with default=None are not treated as having a default, while optional fields emit "default": null. [1] [2]

Python Static Analysis Enhancements

  • Enhanced the static parser to resolve string expressions (such as descriptions) from module-level variables and identifiers, not just string literals. Added a test to confirm descriptions can be sourced from module-level variables. [1] [2] [3]

Test Harness Resource Management

  • Modified the test harness to build Docker images sequentially instead of concurrently, preventing out-of-memory errors on machines with limited resources and improving reliability of test runs. [1] [2]

Signed-off-by: Mark Phelps <mphelps@cloudflare.com>
Reorder the cog-base-image Dockerfile layers so user python_packages
(torch, diffusers, etc.) are installed before the cog SDK/coglet.

This means changing the SDK wheel (via COG_SDK_WHEEL, --cog-ref, or
version bumps) no longer invalidates the Docker cache for expensive
user dependencies. Previously, an SDK change would force a full
rebuild of multi-GB packages like torch.

The non-cog-base-image path already had this ordering. Now both paths
are consistent.
Signed-off-by: Mark Phelps <mphelps@cloudflare.com>
Signed-off-by: Mark Phelps <mphelps@cloudflare.com>
Signed-off-by: Mark Phelps <mphelps@cloudflare.com>
@markphelps markphelps requested a review from a team as a code owner April 17, 2026 17:57
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - all changes are well-reasoned improvements:

  1. Dockerfile ordering: Installing user packages before SDK improves layer caching when using --cog-ref or COG_SDK_WHEEL.

  2. Enum schema naming: Using lowercase parameter names matches runtime behavior.

  3. Default value handling: default=None on non-optional fields now correctly treated as required (matching runtime).

  4. Module-level descriptions: Parser now resolves descriptions from module variables.

  5. Sequential builds: Prevents OOM on memory-constrained Docker VMs during schema comparison.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Apr 17, 2026

LGTM

github run

@markphelps markphelps requested a review from michaeldwan April 17, 2026 18:04
@markphelps markphelps enabled auto-merge April 20, 2026 15:35
@markphelps markphelps added this pull request to the merge queue Apr 20, 2026
Merged via the queue into main with commit b997ef8 Apr 20, 2026
37 checks passed
@markphelps markphelps deleted the mphelps/fix-static-schema-gen branch April 20, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants