You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "python/bin/componentize-py", line 6, in <module>
sys.exit(script())
~~~~~~^^
AssertionError: ModuleNotFoundError: No module named 'dispatch'
Caused by:
ModuleNotFoundError: No module named 'dispatch'
I tried generating the bindings and can't find anything that would cause this error. Am I doing something wrong?
Since the world your component is targeting exports the dispatch interface, and that interface includes several resource types, you must provide implementations of those types as well. You can add a file named dispatch.py to the same directory that contains plugin.py with content like this:
Thank you, that worked! I'm sure it took some work effort to investigate this, I appreciate it.
I would suggest a few ways moving forward:
Documenting how to implement resources.
Better error messages. It should have been "missing implementations for ...". This would probably mean validating each implementation instead of just importing it.
Adding examples with imports, exports, resources.
Perhaps there can be a new command, e.g. componentize-py skeleton, which can generate a working stub for users to flesh out with their own code.
Can you help me with something else? I am trying to use --export-interface-name to rename the dispatch export, but none of my attempts work (and there is no error message):
Try --export-interface-name floria:plugins/dispatch=test (in which case you'll need to update your plugin.py to match). And yes, this is another place the documentation should be improved.
Better error messages. It should have been "missing implementations for ...". This would probably mean validating each implementation instead of just importing it.
Agreed that this would be great, but I'm wondering how it would be implemented. Would it require parsing the Python code and statically analyzing it to determine whether it defines the expected symbols? If so, that sounds daunting given how dynamic Python is (i.e. able to add and/or delete symbols and fields at runtime). Maybe there's a simple solution I'm not seeing?
Adding examples with imports, exports, resources.
The existing examples involve imports, exports, and (imported) resources, but you're right that we also need at least one example that exports a resource.
Perhaps there can be a new command, e.g. componentize-py skeleton, which can generate a working stub for users to flesh out with their own code.
Agreed; that would be great, and mirrors the --stubs option in wit-bindgen rust.
2. Better error messages. It should have been "missing implementations for ...". This would probably mean validating each implementation instead of just importing it.
Note that this has been improved as of #240, which uses decorators to register implementations, allowing for better error messages.
Activity
dicej commentedon May 20, 2026
Hi @tliron. Thanks for reporting this.
Since the world your component is targeting exports the
dispatchinterface, and that interface includes severalresourcetypes, you must provide implementations of those types as well. You can add a file nameddispatch.pyto the same directory that containsplugin.pywith content like this:(replacing the
raise NotImplementedErrorlines with whatever you want the implementations to do). That should fix the issue.tliron commentedon May 20, 2026
Thank you, that worked! I'm sure it took some work effort to investigate this, I appreciate it.
I would suggest a few ways moving forward:
componentize-py skeleton, which can generate a working stub for users to flesh out with their own code.tliron commentedon May 20, 2026
Can you help me with something else? I am trying to use
--export-interface-nameto rename the dispatch export, but none of my attempts work (and there is no error message):I'm not clear on what the export name should be.
dicej commentedon May 20, 2026
Try
--export-interface-name floria:plugins/dispatch=test(in which case you'll need to update yourplugin.pyto match). And yes, this is another place the documentation should be improved.dicej commentedon May 20, 2026
Agreed!
Agreed that this would be great, but I'm wondering how it would be implemented. Would it require parsing the Python code and statically analyzing it to determine whether it defines the expected symbols? If so, that sounds daunting given how dynamic Python is (i.e. able to add and/or delete symbols and fields at runtime). Maybe there's a simple solution I'm not seeing?
The existing examples involve imports, exports, and (imported) resources, but you're right that we also need at least one example that exports a resource.
Agreed; that would be great, and mirrors the
--stubsoption inwit-bindgen rust.dicej commentedon Sep 1, 2026
Note that this has been improved as of #240, which uses decorators to register implementations, allowing for better error messages.