Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[draft] plugin_fn extractors #32

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

fliepeltje
Copy link
Contributor

This is a proof of concept of implementing extractors based on function annotation.

This works with the Config example as described. What does not work is defining an input. For example:

@extism.plugin_fn
def count_vowels(config: extism.Config, input: str) -> Count:
  ...

will raise the following error:

Error: the `wizer.initialize` function trapped

Caused by:
    0: error while executing at wasm backtrace:
           0: 0xc3d536 - core.wasm!extism_pdk::extism::load_input::ha87e3399c3e88427
           1: 0xc3da6f - core.wasm!extism_pdk::input_bytes::hb6157a98e888d918
           2: 0x99a9 - core.wasm!core::py_module::__pyfunction_input_str::h20274f6b4ee092c8
           3: 0x8e3a - core.wasm!pyo3::impl_::trampoline::trampoline::hba91026dbca8481a
           4: 0x9984 - core.wasm!core::py_module::<impl core::py_module::input_str::MakeDef>::_PYO3_DEF::trampoline::hb47a2005df801990
           5: 0x12613f - core.wasm!cfunction_vectorcall_NOARGS
           6: 0x1da1a - core.wasm!_PyObject_VectorcallTstate
           7: 0x1f06e - core.wasm!PyObject_Vectorcall
           8: 0x2d366e - core.wasm!_PyEval_EvalFrameDefault
           9: 0x2b18db - core.wasm!_PyEval_EvalFrame
          10: 0x2b129b - core.wasm!_PyEval_Vector
          11: 0x2b0f9c - core.wasm!PyEval_EvalCode
          12: 0x36b71c - core.wasm!exec_code_in_module
          13: 0x36b40f - core.wasm!PyImport_ExecCodeModuleObject
          14: 0x36b0ab - core.wasm!PyImport_ExecCodeModuleWithPathnames
          15: 0x36b4b1 - core.wasm!PyImport_ExecCodeModuleEx
          16: 0xc4f726 - core.wasm!pyo3::types::module::PyModule::from_code_bound::hee18162d729acce4
          17: 0x19d32 - core.wasm!wizer.initialize
          18: 0xc89a3b - core.wasm!wizer.initialize.command_export
    1: Error: attempted to call an unknown imported function: 'extism:host/env' 'input_length'
       
       You cannot call arbitrary imported functions during Wizer initialization.

I'd love some help with figuring out how to not have this error :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant