Skip to content

Commit

Permalink
download reactor on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFriel committed Sep 9, 2024
1 parent acbf6db commit efa2f9b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions controllers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./wasi_snapshot_preview1.reactor.wasm
17 changes: 16 additions & 1 deletion py/pyaici/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import os
import argparse
import requests

from . import rest, jssrc
from . import add_cli_args, runner_from_cli
Expand All @@ -15,6 +16,20 @@ def cli_error(msg: str):
sys.exit(1)


def acquire_reactor_adaptor():
REACTOR_PATH = "controllers/wasi_snapshot_preview1.reactor.wasm"

if os.path.exists(REACTOR_PATH):
return os.path.abspath(REACTOR_PATH)

print("Downloading reactor adaptor...")
url = "https://github.com/bytecodealliance/wasmtime/releases/download/dev/wasi_snapshot_preview1.reactor.wasm"
response = requests.get(url)
with open(REACTOR_PATH, "wb") as f:
f.write(response.content)

return os.path.abspath(REACTOR_PATH)

def build_rust(folder: str, features: List[str] = []):
bin_file = ""
spl = folder.split("::")
Expand Down Expand Up @@ -66,7 +81,7 @@ def build_rust(folder: str, features: List[str] = []):
+ ".component.wasm"
)

reactor_path = "controllers/wasi_snapshot_preview1.reactor.wasm"
reactor_path = acquire_reactor_adaptor()

# remove file first, so we're sure it's rebuilt
try:
Expand Down

0 comments on commit efa2f9b

Please sign in to comment.