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
119 changes: 102 additions & 17 deletions packages/polywrap-client/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions packages/polywrap-client/polywrap_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ClientConfig,
Env,
GetEnvsOptions,
GetManifestOptions,
GetFileOptions,
GetUriResolversOptions,
InvokeResult,
Expand All @@ -23,6 +24,7 @@
)
from polywrap_msgpack import msgpack_decode, msgpack_encode
from polywrap_uri_resolvers import FsUriResolver, SimpleFileReader
from polywrap_manifest import AnyWrapManifest
from result import Err, Ok, Result


Expand Down Expand Up @@ -58,7 +60,11 @@ def get_env_by_uri(

async def get_file(self, uri: Uri, options: GetFileOptions) -> Union[bytes, str]:
loaded_wrapper = (await self.load_wrapper(uri)).unwrap()
return await loaded_wrapper.get_file(options=options, client=self)
return await loaded_wrapper.get_file(options)

async def get_manifest(self, uri: Uri, options: Optional[GetManifestOptions] = None) -> AnyWrapManifest:
loaded_wrapper = (await self.load_wrapper(uri)).unwrap()
return loaded_wrapper.get_manifest()

async def try_resolve_uri(
self, options: TryResolveUriOptions
Expand Down Expand Up @@ -90,7 +96,7 @@ async def load_wrapper(
return Err(Exception(f'Error resolving URI "{uri.uri}"\nURI not found'))

if isinstance(uri_package_or_wrapper, UriPackage):
return Ok(uri_package_or_wrapper.package.create_wrapper())
return Ok(await uri_package_or_wrapper.package.create_wrapper())

return Ok(uri_package_or_wrapper.wrapper)

Expand Down
2 changes: 2 additions & 0 deletions packages/polywrap-client/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ python = "^3.10"
wasmtime = "^1.0.1"
unsync = "^1.4.0"
polywrap-core = { path = "../polywrap-core", develop = true }
polywrap-msgpack = { path = "../polywrap-msgpack", develop = true }
polywrap-manifest = { path = "../polywrap-manifest", develop = true }
polywrap-uri-resolvers = { path = "../polywrap-uri-resolvers", develop = true }
result = "^0.8.0"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��version�0.1�name�Simple�type�wasm�abi��version�0.1�moduleType��type�Module�kind̀�methods���name�simpleMethod�return��type�String�name�simpleMethod�requiredäkind"�scalar��name�simpleMethod�type�String�requiredäkind�type�Method�kind@�requiredéarguments���type�String�name�arg�requiredäkind"�scalar��name�arg�type�String�requiredäkind
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��version�0.1�name�Simple�type�wasm�abi��version�0.1�moduleType��type�Module�kind̀�methods���name�add�return��type�Int�name�add�requiredäkind"�scalar��name�add�type�Int�requiredäkind�type�Method�kind@�requiredéarguments���type�Int�name�a�requiredäkind"�scalar��name�a�type�Int�requiredäkind��type�Int�name�b�requiredäkind"�scalar��name�b�type�Int�requiredäkind
6 changes: 3 additions & 3 deletions packages/polywrap-client/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
async def test_invoke():
client = PolywrapClient()
uri = Uri(
f'fs/{Path(__file__).parent.joinpath("cases", "simple-invoke", "wrap.wasm").absolute()}'
f'fs/{Path(__file__).parent.joinpath("cases", "simple-invoke").absolute()}'
)
args = {"arg": "hello polywrap"}
options = InvokerOptions(
Expand All @@ -26,7 +26,7 @@ async def test_subinvoke():
file_reader=SimpleFileReader(),
redirects={
Uri("ens/add.eth"): Uri(
f'fs/{Path(__file__).parent.joinpath("cases", "subinvoke", "wrap-subinvoke.wasm").absolute()}'
f'fs/{Path(__file__).parent.joinpath("cases", "simple-subinvoke", "subinvoke").absolute()}'
),
},
)
Expand All @@ -35,7 +35,7 @@ async def test_subinvoke():
envs=[], resolver=uri_resolver
))
uri = Uri(
f'fs/{Path(__file__).parent.joinpath("cases", "subinvoke", "wrap-invoke.wasm").absolute()}'
f'fs/{Path(__file__).parent.joinpath("cases", "simple-subinvoke", "invoke").absolute()}'
)
args = b'\x82\xa1a\x01\xa1b\x02'
options = InvokerOptions(
Expand Down
Loading