feat: stream initial package installations for WASM#9702
Draft
dmadisetti wants to merge 3 commits into
Draft
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
for more information, see https://pre-commit.ci
Contributor
There was a problem hiding this comment.
4 issues found across 8 files
Architecture diagram
sequenceDiagram
participant UI as Client UI
participant useInstall as useInstallPackage hook
participant WS as WebSocket
participant Kernel as Kernel Runtime
participant PkgCallbacks as PackagesCallbacks
participant PkgMgr as PackageManager
participant MicropipStream as MicropipStreamInstall
participant DB as Database
participant Ntf as Broadcast Notification
Note over UI,Ntf: WASM Package Installation Flow
UI->>useInstall: installPackages(["numpy", "pandas", "scipy"])
useInstall->>useInstall: join packages with space separator
useInstall->>WS: addPackage({ package: "numpy pandas scipy" })
WS->>Kernel: enqueue InstallPackagesCommand
Kernel->>PkgCallbacks: _handle_install()
PkgCallbacks->>PkgCallbacks: _notebook_index_urls() - read PEP 723 config
Note over PkgCallbacks: Mark all packages as "installing" up-front
PkgCallbacks->>Ntf: broadcast InstallingPackageAlertNotification (installing)
PkgCallbacks->>PkgMgr: stream_install(["numpy","pandas","scipy"], versions, index_urls)
alt Micropip available (Pyodide)
PkgMgr->>MicropipStream: stream_transaction_install()
Note over MicropipStream: Resolve all requirements via micropip Transaction
MicropipStream->>MicropipStream: gather_requirements(flat_requirements)
alt Resolution failures
MicropipStream-->>PkgMgr: yield (package, False) per failed
end
Note over MicropipStream: Install all wheels in parallel via asyncio.as_completed
par Each wheel completes
MicropipStream->>MicropipStream: wheel.install()
MicropipStream-->>PkgMgr: yield (package, True/False) as completed
end
Note over MicropipStream: Handle pyodide-native packages via loadPackage
MicropipStream->>MicropipStream: loadPackage()
MicropipStream-->>PkgMgr: yield (package, True) per pyodide package
MicropipStream->>MicropipStream: Check remaining packages via importlib.metadata
MicropipStream-->>PkgMgr: yield (package, True/False)
else Micropip unavailable or Transaction API shifted
Note over PkgMgr: Fallback to sequential base install
loop Each package sequentially
PkgMgr->>PkgMgr: install(package, version)
PkgMgr-->>PkgMgr: yield (package, True/False)
end
end
PkgMgr-->>PkgCallbacks: async iterator of (package, success)
loop Each result from stream
PkgCallbacks->>PkgCallbacks: Mark package as installed/failed
alt Success
PkgCallbacks->>Ntf: broadcast InstallingPackageAlertNotification (installed, log "done")
else Failure
PkgCallbacks->>DB: add to excluded_modules
PkgCallbacks->>Ntf: broadcast InstallingPackageAlertNotification (failed, log "done")
end
end
PkgCallbacks->>Ntf: broadcast CompletedRunNotification
Ntf-->>WS: notification to client
WS-->>useInstall: response.success = True
useInstall->>UI: showAddPackageToast for each package
useInstall->>UI: onSuccess callback
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
- Track requested packages by parsed PEP 508 base name (via packaging.requirements.Requirement), so versioned / URL specs like `foo==1.0` and `foo @ git+…@ref` correctly match the wheel names micropip yields back instead of getting reported as failed. - Replace `# type: ignore` micropip imports with importlib.import_module so the module loads cleanly outside Pyodide and mypy doesn't need to see the optional dep at all. - Isolate loadPackage failures so one pyodide-batch error yields per-package False rather than terminating the generator. - Fallback path now retries only packages the engine didn't yield, avoiding double-yield + (pkg, False) reports for packages that already succeeded. - Defensive isinstance(url, str) checks when reading PEP 723 index config from the notebook (guards malformed pyproject entries). - Regenerate packages/openapi/api.yaml for the new index_urls field.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
Allow parallel installations in pyodide