extism / python-sdk

Extism Python Host SDK - easily run WebAssembly modules / plugins from Python applications
https://extism.org
BSD 3-Clause "New" or "Revised" License
19 stars 0 forks source link

feat: add `TypedPlugin` class #21

Closed zshipko closed 5 months ago

zshipko commented 10 months ago

Adds TypedPlugin class, which can be inherited from to create something similar to the typed_plugin! macro in the Rust SDK

Example

class Example(example.TypedPlugin):
  def count_vowels(self, s: str) -> typing.Annotated[dict, extism.Json]:
    raise NotImplementedError

example_plugin = Example(manifest)

TypedPlugin attempts to do automatic conversion of input and return values similar to how host_fn does it (one major difference is integers/floats aren't supported by default)

zshipko commented 5 months ago

Closing this because the TypedPlugin interface doesn't work as well with a dynamically typed language.