Skip to content

Fix Python Playground fallback for blocked public downloads - #12068

Draft
Libba Lawrence (l0lawrence) wants to merge 8 commits into
microsoft:mainfrom
l0lawrence:l0lawrence-fix-python-playground-generation
Draft

Libba Lawrence (l0lawrence) wants to merge 8 commits into
microsoft:mainfrom
l0lawrence:l0lawrence-fix-python-playground-generation

Conversation

@l0lawrence

@l0lawrence Libba Lawrence (l0lawrence) commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Why

Python Playground generation downloads Pyodide from jsDelivr and Python dependencies through public package services. Those browser-side requests can fail on internal Microsoft networks. Build-time pip index settings alone do not affect those requests.

Approach

  • Preserve the existing public download path. Only on a reported failure, recover using versioned TypeSpec-hosted runtime assets and browser-compatible Python wheels prepared through CFS.
  • Keep lazy browser initialization and failure recovery in browser-runtime.ts. Reuse an initialized runtime when package installation fails, and preserve both errors if recovery also fails.
  • Prepare hosted assets through a separate build:playground command and dedicated asset builder. Normal wheel builds and Node/tsp-client generation remain unchanged.
  • Remove the previous shared YAML index configuration. No shared tspconfig, Playground state, or README changes; one Python fix Chronus entry.
  • Exclude fallback runtime/wheel assets from the npm package and upload them separately with the Playground bundle.
  • Recovery is failure-only: no Wi-Fi detection, availability probes, or application startup timeout.

Validation

  • The pushed implementation passed normal emitter build, package formatting, emitter lint, repository formatting, all 31 emitter tests, and both Python build-separation regressions.
  • Dedicated Playground asset preparation produced the runtime and 16 universal wheels. A subsequent normal build left all 22 fallback asset files unchanged; npm packaging contains no fallback runtime/wheel assets.
  • A local, uncommitted/unpushed follow-up clears the loader cache when a downloaded bootstrap script fails to define Pyodide, adds four focused loader regressions, and moves cold test-host initialization into test setup. Its full emitter suite has 35 passing tests; type-check, emitter lint, focused formatting, and both Python regressions passed.
  • Controlled real Edge runs using the current local browser bootstrap and the real Python generator produced DemoServiceClient with 19 files for public success, blocked bootstrap JS, a bootstrap response with no runtime export, blocked lockfile, and blocked public Python packages. Public success made no fallback requests, and initialized runtimes were reused. Runtime and package fixtures were served from the existing local assets rather than downloaded from public registries.
  • These checks validate the browser startup/generator path, not deployment of the public production URL or a full Playground UI retest.

Known limitations

  • Partial WASM blocking: if CDN bootstrap JS succeeds but pyodide.asm.wasm is blocked, Pyodide 0.26.2 logs wasm instantiation failed! without rejecting its initialization promise. The failure-only fallback therefore cannot start, and generation remains pending. This was reproduced in a real browser and confirmed in the pinned runtime source. The user explicitly chose to retain failure-only behavior and document this limitation rather than add a startup timeout. This PR does not fix that hang.
  • Blocking the public lockfile does recover generation, but Pyodide emits upstream Failed to fetch unhandled-rejection console errors during the failed public attempt.
  • Recovery still requires the complete hosted assets for the selected emitter version to be published and reachable. If both sources fail, generation reports both errors.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added emitter:client:python Issue for the Python client emitter: @typespec/http-client-python ui:playground labels Sep 29, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-python@12068

commit: a340985

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/http-client-python
Show changes

@typespec/http-client-python - fix ✏️

Retry Playground Python generation with published runtime and CFS-built Python wheels when public package services are unavailable.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Python emitter diff

Baseline gh:eb682766468791b81fe293b889b0dc7531434b3b vs this PR.

No changes to generated output.

Rendered diff: inline on the run summary, or the emitter-diff-html artifact.

Informational check (eng/emitter-diff); does not block the PR.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-sdk-automation

azure-sdk-automation Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…llback

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread packages/http-client-python/emitter/test/browser-pyodide.test.ts Fixed
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@l0lawrence Libba Lawrence (l0lawrence) changed the title Fix Python client generation in shared Playground samples Configure CFS Python index for Playground bundle build Sep 29, 2026
…wnloads fail

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@l0lawrence Libba Lawrence (l0lawrence) changed the title Configure CFS Python index for Playground bundle build Fix Python Playground fallback for blocked public downloads Sep 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python eng ui:playground

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants