Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0a29
0.1.0a30
4 changes: 2 additions & 2 deletions packages/polywrap-client-config-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ config = builder.build()

# build with a custom cache
config = builder.build({
wrapperCache: WrapperCache(),
resolution_result_cache: ResolutionResultCache(),
})

# or build with a custom resolver
coreClientConfig = builder.build({
config = builder.build({
resolver: RecursiveResolver(...),
})
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List
from typing import Dict, List
from hypothesis import given, settings

from polywrap_client_config_builder import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Dict, List
from typing import Dict, List
from random import randint
from hypothesis import assume, event, given, settings
from hypothesis import event, given, settings

from polywrap_client_config_builder import (
ClientConfigBuilder,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List
from typing import List
from hypothesis import given, settings

from polywrap_client_config_builder import (
Expand Down

This file was deleted.

12 changes: 0 additions & 12 deletions packages/polywrap-client-config-builder/tests/test_sanity.py

This file was deleted.

29 changes: 20 additions & 9 deletions packages/polywrap-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,26 @@ Python implementation of the polywrap client.
Use the `polywrap-uri-resolvers` package to configure resolver and build config for the client.

```python
from polywrap_uri_resolvers import FsUriResolver, SimpleFileReader

config = ClientConfig(
resolver=FsUriResolver(file_reader=SimpleFileReader())
from polywrap_uri_resolvers import (
FsUriResolver,
SimpleFileReader
)

from polywrap_core import Uri, ClientConfig
from polywrap_client import PolywrapClient
from polywrap_client_config_builder import PolywrapClientConfigBuilder

builder = (
PolywrapClientConfigBuilder()
.add_resolver(FsUriResolver(file_reader=SimpleFileReader()))
.set_env(Uri.from_str("ens/foo.eth"), {"foo": "bar"})
.add_interface_implementations(
Uri.from_str("ens/foo.eth"), [
Uri.from_str("ens/bar.eth"),
Uri.from_str("ens/baz.eth")
]
)
)
config = builder.build()
client = PolywrapClient(config)
```

Expand All @@ -32,9 +46,6 @@ args = {
"prop1": "1000", # multiply the base number by this factor
},
}
options: InvokerOptions[UriPackageOrWrapper] = InvokerOptions(
uri=uri, method="method", args=args, encode_result=False
)
result = await client.invoke(options)
result = client.invoke(uri=uri, method="method", args=args, encode_result=False)
assert result == "123000"
```
1 change: 0 additions & 1 deletion packages/polywrap-client/tests/test_plugin_wrapper.py

This file was deleted.

Empty file.
12 changes: 6 additions & 6 deletions packages/polywrap-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Python implementation of the plugin wrapper runtime.
from typing import Any, Dict, List, Union, Optional
from polywrap_manifest import AnyWrapManifest
from polywrap_plugin import PluginModule
from polywrap_core import Invoker, Uri, InvokerOptions, UriPackageOrWrapper, Env
from polywrap_core import InvokerClient, Uri, InvokerOptions, UriPackageOrWrapper, Env

class GreetingModule(PluginModule[None]):
def __init__(self, config: None):
Expand All @@ -24,13 +24,13 @@ wrapper = PluginWrapper(greeting_module, manifest)
args = {
"name": "Joe"
}
options: InvokeOptions[UriPackageOrWrapper] = InvokeOptions(
client: InvokerClient = ...

result = await wrapper.invoke(
uri=Uri.from_str("ens/greeting.eth"),
method="greeting",
args=args
args=args,
client=client
)
invoker: Invoker = ...

result = await wrapper.invoke(options, invoker)
assert result, "Greetings from: Joe"
```
37 changes: 2 additions & 35 deletions packages/polywrap-test-cases/README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
# polywrap-wasm
# polywrap-test-cases

Python implementation of the plugin wrapper runtime.

## Usage

### Invoke Plugin Wrapper

```python
from typing import Any, Dict, List, Union, Optional
from polywrap_manifest import AnyWrapManifest
from polywrap_plugin import PluginModule
from polywrap_core import Invoker, Uri, InvokerOptions, UriPackageOrWrapper, Env

class GreetingModule(PluginModule[None]):
def __init__(self, config: None):
super().__init__(config)

def greeting(self, args: Dict[str, Any], client: Invoker[UriPackageOrWrapper], env: Optional[Env] = None):
return f"Greetings from: {args['name']}"

manifest = cast(AnyWrapManifest, {})
wrapper = PluginWrapper(greeting_module, manifest)
args = {
"name": "Joe"
}
options: InvokeOptions[UriPackageOrWrapper] = InvokeOptions(
uri=Uri.from_str("ens/greeting.eth"),
method="greeting",
args=args
)
invoker: Invoker = ...

result = await wrapper.invoke(options, invoker)
assert result, "Greetings from: Joe"
```
This package allows fetching wrap test-cases from the wrap-test-harness.
12 changes: 7 additions & 5 deletions packages/polywrap-wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,23 @@ Python implementation of the Wasm wrapper runtime.
```python
from typing import cast
from polywrap_manifest import AnyWrapManifest
from polywrap_core import FileReader, Invoker
from polywrap_core import FileReader, InvokerClient
from polywrap_wasm import WasmWrapper

file_reader: FileReader = ... # any valid file_reader, pass NotImplemented for mocking
wasm_module: bytes = bytes("<wrapper wasm module bytes read from file or http>")
wrap_manifest: AnyWrapManifest = ...
wrapper = WasmWrapper(file_reader, wasm_module, wrap_manifest)
invoker: Invoker = ... # any valid invoker, mostly PolywrapClient
client: InvokerClient = ... # any valid invoker client, mostly PolywrapClient

message = "hey"
args = {"arg": message}
options: InvokeOptions[UriPackageOrWrapper] = InvokeOptions(
uri=Uri.from_str("fs/./build"), method="simpleMethod", args=args
result = wrapper.invoke(
uri=Uri.from_str("fs/./build"),
method="simpleMethod",
args=args,
client=client
)
result = await wrapper.invoke(options, invoker)
assert result.encoded is True
assert msgpack_decode(cast(bytes, result.result)) == message
```