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

feat: add TypedPlugin class #21

Closed
wants to merge 4 commits into from
Closed

feat: add TypedPlugin class #21

wants to merge 4 commits into from

Conversation

zshipko
Copy link
Contributor

@zshipko zshipko commented Jan 17, 2024

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)

Comment on lines +859 to +860
if item == Pickle:
return lambda x: pickle.loads(x[:])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excuse my python ignorance, but is this safe now?

@zshipko
Copy link
Contributor Author

zshipko commented Jun 14, 2024

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

@zshipko zshipko closed this Jun 14, 2024
@zshipko zshipko deleted the typed-plugins branch June 14, 2024 20:45
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.

2 participants