Skip to content

Commit e1bfe01

Browse files
authored
fix binding generation for lists; add cli test (#46)
* fix binding generation for lists; add cli test This also: - moves the `examples/http/wit` directory to a shared location - bumps the version to 0.7.1 Signed-off-by: Joel Dice <joel.dice@fermyon.com> * update `sys.argv` at runtime; add matrix-math example This ensures we get the runtime set of CLI args rather than the empty set present during pre-init. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * use `Once` to avoid redundant work in runtime; update example instructions Signed-off-by: Joel Dice <joel.dice@fermyon.com> --------- Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent 65e7697 commit e1bfe01

47 files changed

Lines changed: 156 additions & 62 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "componentize-py"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
edition = "2021"
55
exclude = ["cpython"]
66

README.md

Lines changed: 2 additions & 2 deletions

examples/cli/README.md

Lines changed: 35 additions & 0 deletions

examples/cli/app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from command import exports
2+
3+
class Run(exports.Run):
4+
def run(self):
5+
print("Hello, world!")

examples/http/README.md

Lines changed: 3 additions & 3 deletions

examples/http/wit/deps/cli/environment.wit

Lines changed: 0 additions & 18 deletions
This file was deleted.

examples/http/wit/test.wit

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/matrix-math/README.md

Lines changed: 46 additions & 0 deletions

examples/matrix-math/app.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This app can either be used as a library (by calling `matrix-math#multiply`)
2+
# or a CLI command (by calling `wasi:cli/run#run`)
3+
4+
import sys
5+
import numpy
6+
import matrix_math
7+
from matrix_math import exports
8+
from matrix_math.types import Err
9+
10+
class MatrixMath(matrix_math.MatrixMath):
11+
def multiply(self, a: list[list[float]], b: list[list[float]]) -> list[list[float]]:
12+
print(f"matrix_multiply received arguments {a} and {b}")
13+
return numpy.matmul(a, b).tolist()
14+
15+
class Run(exports.Run):
16+
def run(self):
17+
args = sys.argv[1:]
18+
if len(args) != 2:
19+
print(f"usage: matrix-math <matrix> <matrix> (got {args})", file=sys.stderr)
20+
exit(-1)
21+
22+
print(MatrixMath().multiply(eval(args[0]), eval(args[1])))
23+

0 commit comments

Comments
 (0)