Skip to content

Commit b6e46d4

Browse files
authored
Merge pull request #27 from polywrap/nk/add-manifest-support
feat: add support for wrap manifest in client
2 parents 16fb46d + ffe5c5a commit b6e46d4

34 files changed

Lines changed: 637 additions & 148 deletions

File tree

packages/polywrap-client/poetry.lock

Lines changed: 102 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/polywrap-client/polywrap_client/client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
ClientConfig,
99
Env,
1010
GetEnvsOptions,
11+
GetManifestOptions,
1112
GetFileOptions,
1213
GetUriResolversOptions,
1314
InvokeResult,
@@ -23,6 +24,7 @@
2324
)
2425
from polywrap_msgpack import msgpack_decode, msgpack_encode
2526
from polywrap_uri_resolvers import FsUriResolver, SimpleFileReader
27+
from polywrap_manifest import AnyWrapManifest
2628
from result import Err, Ok, Result
2729

2830

@@ -58,7 +60,11 @@ def get_env_by_uri(
5860

5961
async def get_file(self, uri: Uri, options: GetFileOptions) -> Union[bytes, str]:
6062
loaded_wrapper = (await self.load_wrapper(uri)).unwrap()
61-
return await loaded_wrapper.get_file(options=options, client=self)
63+
return await loaded_wrapper.get_file(options)
64+
65+
async def get_manifest(self, uri: Uri, options: Optional[GetManifestOptions] = None) -> AnyWrapManifest:
66+
loaded_wrapper = (await self.load_wrapper(uri)).unwrap()
67+
return loaded_wrapper.get_manifest()
6268

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

9298
if isinstance(uri_package_or_wrapper, UriPackage):
93-
return Ok(uri_package_or_wrapper.package.create_wrapper())
99+
return Ok(await uri_package_or_wrapper.package.create_wrapper())
94100

95101
return Ok(uri_package_or_wrapper.wrapper)
96102

packages/polywrap-client/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ python = "^3.10"
1414
wasmtime = "^1.0.1"
1515
unsync = "^1.4.0"
1616
polywrap-core = { path = "../polywrap-core", develop = true }
17+
polywrap-msgpack = { path = "../polywrap-msgpack", develop = true }
18+
polywrap-manifest = { path = "../polywrap-manifest", develop = true }
1719
polywrap-uri-resolvers = { path = "../polywrap-uri-resolvers", develop = true }
1820
result = "^0.8.0"
1921

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

packages/polywrap-client/tests/cases/subinvoke/wrap-invoke.wasm renamed to packages/polywrap-client/tests/cases/simple-subinvoke/invoke/wrap.wasm

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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

packages/polywrap-client/tests/cases/subinvoke/wrap-subinvoke.wasm renamed to packages/polywrap-client/tests/cases/simple-subinvoke/subinvoke/wrap.wasm

File renamed without changes.

packages/polywrap-client/tests/test_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
async def test_invoke():
1111
client = PolywrapClient()
1212
uri = Uri(
13-
f'fs/{Path(__file__).parent.joinpath("cases", "simple-invoke", "wrap.wasm").absolute()}'
13+
f'fs/{Path(__file__).parent.joinpath("cases", "simple-invoke").absolute()}'
1414
)
1515
args = {"arg": "hello polywrap"}
1616
options = InvokerOptions(
@@ -26,7 +26,7 @@ async def test_subinvoke():
2626
file_reader=SimpleFileReader(),
2727
redirects={
2828
Uri("ens/add.eth"): Uri(
29-
f'fs/{Path(__file__).parent.joinpath("cases", "subinvoke", "wrap-subinvoke.wasm").absolute()}'
29+
f'fs/{Path(__file__).parent.joinpath("cases", "simple-subinvoke", "subinvoke").absolute()}'
3030
),
3131
},
3232
)
@@ -35,7 +35,7 @@ async def test_subinvoke():
3535
envs=[], resolver=uri_resolver
3636
))
3737
uri = Uri(
38-
f'fs/{Path(__file__).parent.joinpath("cases", "subinvoke", "wrap-invoke.wasm").absolute()}'
38+
f'fs/{Path(__file__).parent.joinpath("cases", "simple-subinvoke", "invoke").absolute()}'
3939
)
4040
args = b'\x82\xa1a\x01\xa1b\x02'
4141
options = InvokerOptions(

0 commit comments

Comments
 (0)