Coder Social home page Coder Social logo

ya-runtime-wasi's Introduction

Yagna WASI runtime

Continuous integration

ya-runtime-wasi is a Yagna plugin that allows the provider to execute WASI modules in a safe, sandboxed way. Typically, you will use this crate as part of your Yagna provider installation. However, it is also possible to use the integration standalone to execute zipped WASI modules according to some included manifest file.

Building

Building the plugin is very straightforward:

cargo build

If you decide to make some tweaks to the API and would like to test if everything still behaves as expected, you can trigger included end-to-end integration tests. Make sure you have wasm32-wasi target installed (rustup target add wasm32-wasi) and then run:

cargo test --all --features ya-runtime-wasi/integration-tests

Note that running the end-to-end tests requires you to have wasm32-wasi target installed.

Running

As part of Yagna

This step is explained in Yagna's general tutorial.

Standalone

Running standalone is pretty simple. For this, you'll want to use a Wasm module which performs some input from the host, does some computations, and outputs the results to a file on the host. To keep everything simple, we'll assume you use rust-wasi-tutorial. Clone the repo, and build the project:

git clone https://github.com/kubkon/rust-wasi-tutorial.git
cd rust-wasi-tutorial
cargo build --release --target wasm32-wasi

This will automatically cross-compile your project to wasm32-wasi target.

Next, we'll need to create a Yagna package. Go ahead and create new dir called package somewhere in your home directory, and copy rust-wasi-tutorial.wasm module into it:

mkdir package
cp rust-wasi-tutorial/target/wasm32-wasi/release/main.wasm package/rust-wasi-tutorial.wasm

Next, we'll need to create a manifest for the package called manifest.json:

{
    "id": "rust-wasi-tutorial",
    "name": "rust-wasi-tutorial",
    "entry-points": [
        {
            "id": "rust-wasi-tutorial",
            "wasm-path": "rust-wasi-tutorial.wasm"
        }
    ],
    "mount-points": [
        { "rw": "input" },
        { "rw": "output" }
    ]
}

Here, of interest are entry-points and mount-points entries. The former tell the runtime what modules to load up when we specify some entrypoint (e.g., rust-wasi-tutorial will load up the rust-wasi-tutorial.wasm module), whereas the latter instruct the runtime which directories to preopen and map into our container so that we can make use of it. In this case, we'll map a relative dir input as /input inside the container and similarly output as /output.

OK, now we can create the package by zipping the package folder:

zip -r rust-wasi-tutorial.zip package/

Finally, we'll create a workspace dir where we'll mount our package using the runtime:

mkdir workspace

We're now ready to deploy the package:

./target/debug/ya-runtime-wasi --task-package rust-wasi-tutorial.zip --workdir workspace deploy

Deployment created the mount points on the host for us inside workspace. Namely, you should find there workspace/input and workspace/output among other things. Next, go ahead and create some dummy text file in with Hello WASI! and put it in workspace/input/in. It will then automatically get mapped into /input/in for use by our Wasm module.

Next, we need to start the module:

./target/debug/ya-runtime-wasi --task-package rust-wasi-tutorial.zip --workdir workspace start

Finally, we can run it:

./target/debug/ya-runtime-wasi --task-package rust-wasi-tutorial.zip --workdir workspace run --entrypoint rust-wasi-tutorial /input/in /output/out

If everything went according to plan, you should now find out text file with Hello WASI! text in it inside workspace/output/out.

License

Licensed under GPLv3

ya-runtime-wasi's People

Contributors

boryspoplawski avatar kubkon avatar mateuszsrebrny avatar mfranciszkiewicz avatar nieznanysprawiciel avatar prekucki avatar pwalski avatar tworec avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ya-runtime-wasi's Issues

windows provider is non-functional

This is minor thing since we do not want to support Windows initially.

cp conf/ya-runtime-wasi.json "$TARGET_DIR/"
if [ "$OS_NAME" = "windows" ]; then
cp target/release/ya-runtime-wasi.exe "$TARGET_DIR/"
strip "$TARGET_DIR/ya-runtime-wasi.exe"

The json file copied into zip artifact is not functional under Windows since it uses binary paths wo .exe extension, so it will not work.

"supervisor-path": "exe-unit",
"runtime-path": "ya-runtime-wasi",

I'd consider removing windows release altogether for now

cannot install on Ubuntu 18.04

Graphical installer does not give any error and warnings, error below copied from terminal

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'ya-runtime-wasi' instead of './ya-runtime-wasi_0.2.0_amd64.deb'
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies.
 ya-runtime-wasi : Depends: libgcc-s1 (>= 10.1.0) but it is not installable
E: Unable to correct problems, you have held broken packages.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.