Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-work package resolution and make runners use it #3852

Merged
merged 64 commits into from
May 25, 2023
Merged

Conversation

Michael-F-Bryan
Copy link
Contributor

@Michael-F-Bryan Michael-F-Bryan commented May 9, 2023

This PR refactors runners to take advantage of #3841 and #3831. @theduke and I have also completely re-worked the package resolution workflow to better suit Deploy's needs.

TL;DR:

  • The Runner trait now has two methods
    • an associated can_run_command() function for checking whether a runner can run something, and
    • a run_command() function which gets the command name, a WEBC container, and a WasiRuntime
  • All runtime-related state (task manager, module caching, stores, compilation, etc.) is now retrieved from the WasiRuntime instead of being stored as a field in the runner
  • The BinaryPackage type has been repurposed so it represents not just a single package, but the entire environment that will be available at runtime (all commands, file systems, etc.)
  • New concepts:
    • PackageLoader - something that can load a *.webc file
    • Source - something that can answer questions about package dependencies (WAPM, local directory for testing, etc.)
    • Registry - a collection of Sources
    • Summary - just enough metadata about a single package to do package resolution
    • resolve() - the top-level function that takes a "root" package and a Registry, and figures out both the concrete dependency graph (DependencyGraph) and what the resulting package would look like (ResolvedPackage)
    • load_package_tree() - a new method on WasiRuntime that you can override when loading ResolvedPackage into a BinaryPackage, primarily so Deploy can add custom caching and such

Later on we'll probably refactor BinaryPackageCommand so commands and filesystems can be lazily loaded, but I'm leaving that for future Michael.

Fixes #3603, fixes #3748, fixes #3812.

@Michael-F-Bryan Michael-F-Bryan changed the title Updated runners Make runners use PackageResolver and ModuleCache May 9, 2023
@Michael-F-Bryan Michael-F-Bryan changed the title Make runners use PackageResolver and ModuleCache Re-work package resolution and make runners use it May 15, 2023
@Michael-F-Bryan Michael-F-Bryan force-pushed the updated-runners branch 3 times, most recently from c6b70d8 to 3987ce9 Compare May 17, 2023 06:37
@Michael-F-Bryan Michael-F-Bryan marked this pull request as ready for review May 17, 2023 10:02
Copy link
Contributor

@theduke theduke left a comment

Choose a reason for hiding this comment

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

Overall: amazing work!

lib/wasi/src/runtime/mod.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/mod.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/mod.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/package_loader/builtin_loader.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/resolver/utils.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/resolver/source.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/module_cache/types.rs Show resolved Hide resolved
lib/wasi/src/runtime/resolver/inputs.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/resolver/source.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@theduke theduke left a comment

Choose a reason for hiding this comment

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

Overall: amazing work!

lib/wasi/src/runtime/mod.rs Show resolved Hide resolved
lib/wasi/src/runtime/package_loader/builtin_loader.rs Outdated Show resolved Hide resolved
lib/wasi/src/state/env.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/resolver/source.rs Outdated Show resolved Hide resolved
lib/wasi/src/runtime/resolver/inputs.rs Outdated Show resolved Hide resolved
@syrusakbary syrusakbary mentioned this pull request May 18, 2023
Copy link
Member

@syrusakbary syrusakbary left a comment

Choose a reason for hiding this comment

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

Preapproving it, we just need to simplify the trait implementation for now. But feel free to merge once that's implemented

@theduke theduke force-pushed the updated-runners branch from 9cae74e to 30386f5 Compare May 25, 2023 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants