I wonder if wasmtime-py is able to process components in form of .wasm files. Can anyone confirm that?
The example loader_component.py seems to load and call a component indeed. I can see it executing. However, it loads a .wat.
In case I try to load a component as .wasm, I get the following error:
$ python -m myloader
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/finnfalter/dev/python/wasmtimecomp/myloader.py", line 2, in <module>
import demo_component
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "myloader.py", line 80, in exec_module
exec(component_files[relative_path], module.__dict__)
File "<string>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "myloader.py", line 80, in exec_module
exec(component_files[relative_path], module.__dict__)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'imports.py'
Running
import wasmtime, wasmtime.loader
import demo_component
store = wasmtime.Store()
component = demo_component.Root(store)
component.run(store)
Where demo_component
corresponds to demo.component
here
Support for this was the intention of https://github.com/bytecodealliance/wasmtime-py/pull/224 but you might have stumbled across a bug? If so mind opening an issue?
Thank you, yes, I have seen that PR and I can positively repeat it but I do not succeed with any .wasm file.
Just created issue #245
I also created a public repo with an example to quickly replay my observation.
@Catherine (whitequark) would you be able to quickly see if that may be a bug or rather a problem in front of the computer?
This is a bug in my PR. For whatever reason, wasmtime's bindgen actually produces a different list of Python build products between .wasm and .wat inputs, so while I assumed that the .wat and .wasm cause the same code paths to be taken, that was not correct.
Oh, wait. I realize now that the .wasm/.wat distinction is a red herring. Your demo component includes an import, and I don't handle those right; the included example with an adder does not.
But I also don't think we have a design to handle component imports of Python functions (if I recall; I may be wrong) so that will probably have to be solved first.
Thank you for your fast feedback!
I am very interested in that feature. If I can help somehow, please let me know.
At least, I might test it.
Sorry, my health does not permit me to spend time on this fix right now.
Christoph Brewing has marked this topic as resolved.
Last updated: Dec 23 2024 at 13:07 UTC