Using Pyodide lockFileURL + packages when a cache exists #121
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.
This MR introduces 2 loadPyodide extra features:
With the current tests and just
numpy
as foreign package the bootstrap went down 1 second on average so I expect even more improvements with more convoluted scenarios.About packages cache
Only packages present in the py-config are considered, as runtime packages might be both heavy or undesired.
If a package is always added at runtime it should be moved into the
packages
field.The order, version, amount of packages decides the the cache key, as these are serialized as JSON and then used as unique identifier for the cache.
Cleanup the whole cache
As projexts might change and grow in time, or even remove dependencies, it is possible to force-erase the whole cache for any specific Pyodide version by using
packages_cache = "never"
in the TOML / JSON config file.This could also be an easy way to just clean the cache once and then recreate it, otherwise users would need to manually reach their devtool Application panel, dig the IndexedDB related folder and erase previous cache manually.
Each DB is based on the current version of Pyodide so that multiple versions cna use different caches from different times.
Note about mocked tests
Unfortunately it's extremely hard, but so (imho) pointless, to mimic this Pyodide only behavior so while I am sad to temporarily drop current unit tests in favor of integration manual tests, I am sure once this whole project will be refactored into PyScript core itself we'll have all tests that do all the things we expect to validate things just work as expected in there too.