Skip to content

Wasm file resolution bug #1407

@qartik

Description

@qartik

Following #1339 and subsequent release of guppy v0.21.7, there's a regression in wasm file path resolution.

If I have my file structure as follows:

❯ tree
.
├── guppy_wasm.ipynb
└── wasm
    ├── arith.wasm
    └── wasm.py

and wasm.py has:

@wasm_module("arith.wasm")
class MyWasm:
    @wasm
    def add(self: "MyWasm", a: int, b: int) -> int: ...
[...]
@guppy
def main() -> None:

    [mod1] = spawn_wasm_contexts(1, MyWasm)
    res5 = mod1.add(10, 32)
[...]

Then if I do from wasm.wasm import main from guppy_wasm.ipynb, I get:

---------------------------------------------------------------------------
GuppyError                                Traceback (most recent call last)
Cell In[1], [line 3](vscode-notebook-cell:?execution_count=1&line=3)
      1 import qnexus as qnx
      2 from rich import print as rprint
----> [3](vscode-notebook-cell:?execution_count=1&line=3) from wasm.wasm import main

File ~/GH/qapi-submit/wasm/wasm.py:10
      6 from guppylang.std.qsystem.wasm import spawn_wasm_contexts
      7 from guppylang_internals.decorator import wasm, wasm_module
---> [10](~/GH/qapi-submit/wasm/wasm.py:10) @wasm_module("arith.wasm")
     11 class MyWasm:
     12     @wasm
     13     def add(self: "MyWasm", a: int, b: int) -> int: ...

File ~/GH/qapi-submit/.venv/lib/python3.13/site-packages/guppylang_internals/decorator.py:217, in wasm_module(filename)
    215     wasm_sigs = decode_wasm_functions(filename)
    216 else:
--> [217](~/GH/qapi-submit/.venv/lib/python3.13/site-packages/guppylang_internals/decorator.py:217)     raise GuppyError(WasmFileNotFound(None, filename))
    219 def type_def_wrapper(
    220     id: DefId,
    221     name: str,
   (...)    224     config: str | None,
    225 ) -> OpaqueTypeDef:
    226     assert config is None

GuppyError: WasmFileNotFound(span=None, _parent=None, children=[], file='arith.wasm')

Changing the file path in the decorate to @wasm_module("wasm/arith.wasm") works.

We should be looking at the relative path from the guppy source, not the execution site.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions