Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Python package

on:
push:
branches:
- main
- dev
pull_request:

jobs:
getPackages:
runs-on: ubuntu-latest
outputs:
matrix: ${{ env.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- id: set-matrix
run: echo "matrix=$(./scripts/getPackages.sh)" >> $GITHUB_ENV
build:
runs-on: ubuntu-latest
needs:
- getPackages
strategy:
matrix: ${{fromJSON(needs.getPackages.outputs.matrix)}}
defaults:
run:
working-directory: ./packages/${{ matrix.package }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: poetry install
- name: Typecheck
run: poetry run tox -e typecheck
# FIXME: make this work
# - name: Lint
# run: poetry run tox -e lint
# - name: Security
# run: poetry run tox -e secure
- name: Test
run: poetry run tox
7 changes: 4 additions & 3 deletions packages/polywrap-wasm/polywrap_wasm/wasm_package.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional
from typing import Optional, Union

from polywrap_core import IFileReader, IWasmPackage, Wrapper

Expand All @@ -22,10 +22,11 @@ def __init__(
)

async def get_wasm_module(self) -> bytearray:
self.wasm_module = self.wasm_module or await self.file_reader.read_file(
wasm_module: bytearray = self.wasm_module or await self.file_reader.read_file(
WRAP_MODULE_PATH
)
return self.wasm_module
self.wasm_module = wasm_module
return wasm_module

def create_wrapper(self) -> Wrapper:
return WasmWrapper(self.file_reader, self.wasm_module)
13 changes: 13 additions & 0 deletions packages/polywrap-wasm/polywrap_wasm/wasm_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from textwrap import dedent
from typing import Optional, Union

from polywrap_core import (
Expand Down Expand Up @@ -60,6 +61,18 @@ async def invoke(self, options: InvokeOptions, invoker: Invoker) -> InvocableRes
else msgpack_encode(options.env)
)

if not (state.method and state.args and state.env):
raise ValueError(
dedent(
"""
Expected invocation state to be definied got:
method: ${state.method}
args: ${state.args}
env: ${state.env}
"""
)
)

method_length = len(state.method)
args_length = len(state.args)
env_length = len(state.env)
Expand Down
18 changes: 18 additions & 0 deletions scripts/getPackages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function joinByString() {
local separator="$1"
shift
local first="$1"
shift
printf "%s" "$first" "${@/#/$separator}"
}

packages_arr=($(ls packages))
# classic for-loop
for ((idx=0; idx < ${#packages_arr[@]}; ++idx)); do
# act on ${packages_arr[$idx]}
packages_arr[$idx]="\"${packages_arr[$idx]}\""
done

packages_str=$(joinByString ', ' ${packages_arr[@]})
packages_json="{ \"package\": [ ${packages_str} ] }"
echo $packages_json