Skip to content

Commit 0a85b2a

Browse files
authored
refactor: polywrap-core package (#182)
1 parent 508392b commit 0a85b2a

39 files changed

+727
-556
lines changed

packages/polywrap-core/poetry.lock

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

packages/polywrap-core/polywrap_core/types/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
"""This module contains all the core types used in the various polywrap packages."""
22
from .client import *
33
from .config import *
4-
from .env import *
54
from .errors import *
65
from .file_reader import *
76
from .invocable import *
8-
from .invoke_args import *
97
from .invoker import *
108
from .invoker_client import *
11-
from .options import *
129
from .uri import *
13-
from .uri_like import *
1410
from .uri_package import *
1511
from .uri_package_wrapper import *
1612
from .uri_resolution_context import *
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,84 @@
11
"""This module contains the Client interface."""
22
from __future__ import annotations
33

4-
from abc import abstractmethod
5-
from typing import Dict, List, Optional, Union
4+
from typing import Any, Dict, List, Optional, Protocol, Union
65

7-
from polywrap_manifest import AnyWrapManifest
6+
from polywrap_manifest import AnyWrapManifest, DeserializeManifestOptions
87

9-
from .env import Env
108
from .invoker_client import InvokerClient
11-
from .options.file_options import GetFileOptions
12-
from .options.manifest_options import GetManifestOptions
139
from .uri import Uri
14-
from .uri_package_wrapper import UriPackageOrWrapper
1510
from .uri_resolver import UriResolver
1611

1712

18-
class Client(InvokerClient[UriPackageOrWrapper]):
13+
class Client(InvokerClient, Protocol):
1914
"""Client interface defines core set of functionalities\
2015
for interacting with a wrapper."""
2116

22-
@abstractmethod
2317
def get_interfaces(self) -> Dict[Uri, List[Uri]]:
2418
"""Get dictionary of interfaces and their implementations.
2519
2620
Returns:
2721
Dict[Uri, List[Uri]]: Dictionary of interfaces and their implementations where\
2822
key is interface URI and value is list of implementation uris.
2923
"""
24+
...
3025

31-
@abstractmethod
32-
def get_envs(self) -> Dict[Uri, Env]:
26+
def get_envs(self) -> Dict[Uri, Any]:
3327
"""Get dictionary of environments.
3428
3529
Returns:
36-
Dict[Uri, Env]: Dictionary of environments where key is URI and value is env.
30+
Dict[Uri, Any]: Dictionary of environments where key is URI and value is env.
3731
"""
32+
...
3833

39-
@abstractmethod
40-
def get_env_by_uri(self, uri: Uri) -> Union[Env, None]:
34+
def get_env_by_uri(self, uri: Uri) -> Union[Any, None]:
4135
"""Get environment by URI.
4236
4337
Args:
4438
uri (Uri): URI of the Wrapper.
4539
4640
Returns:
47-
Union[Env, None]: env if found, otherwise None.
41+
Union[Any, None]: env if found, otherwise None.
4842
"""
43+
...
4944

50-
@abstractmethod
5145
def get_uri_resolver(self) -> UriResolver:
5246
"""Get URI resolver.
5347
5448
Returns:
55-
IUriResolver: URI resolver.
49+
UriResolver: URI resolver.
5650
"""
51+
...
5752

58-
@abstractmethod
59-
async def get_file(self, uri: Uri, options: GetFileOptions) -> Union[bytes, str]:
53+
def get_file(
54+
self, uri: Uri, path: str, encoding: Optional[str] = "utf-8"
55+
) -> Union[bytes, str]:
6056
"""Get file from URI.
6157
6258
Args:
6359
uri (Uri): URI of the wrapper.
64-
options (GetFileOptions): Options for getting file from the wrapper.
60+
path (str): Path to the file.
61+
encoding (Optional[str]): Encoding of the file.
6562
6663
Returns:
6764
Union[bytes, str]]: file contents.
6865
"""
66+
...
6967

70-
@abstractmethod
71-
async def get_manifest(
72-
self, uri: Uri, options: Optional[GetManifestOptions] = None
68+
def get_manifest(
69+
self, uri: Uri, options: Optional[DeserializeManifestOptions] = None
7370
) -> AnyWrapManifest:
7471
"""Get manifest from URI.
7572
7673
Args:
7774
uri (Uri): URI of the wrapper.
78-
options (Optional[GetManifestOptions]): \
75+
options (Optional[DeserializeManifestOptions]): \
7976
Options for getting manifest from the wrapper.
8077
8178
Returns:
8279
AnyWrapManifest: Manifest of the wrapper.
8380
"""
81+
...
82+
83+
84+
__all__ = ["Client"]

packages/polywrap-core/polywrap_core/types/config.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
from __future__ import annotations
33

44
from dataclasses import dataclass, field
5-
from typing import Dict, List
5+
from typing import Any, Dict, List
66

7-
from .env import Env
87
from .uri import Uri
98
from .uri_resolver import UriResolver
109

@@ -14,14 +13,17 @@ class ClientConfig:
1413
"""Client configuration.
1514
1615
Attributes:
17-
envs (Dict[Uri, Env]): Dictionary of environments \
16+
envs (Dict[Uri, Any]): Dictionary of environments \
1817
where key is URI and value is env.
1918
interfaces (Dict[Uri, List[Uri]]): Dictionary of interfaces \
2019
and their implementations where key is interface URI \
2120
and value is list of implementation URIs.
2221
resolver (UriResolver): URI resolver.
2322
"""
2423

25-
envs: Dict[Uri, Env] = field(default_factory=dict)
24+
envs: Dict[Uri, Any] = field(default_factory=dict)
2625
interfaces: Dict[Uri, List[Uri]] = field(default_factory=dict)
2726
resolver: UriResolver
27+
28+
29+
__all__ = ["ClientConfig"]

packages/polywrap-core/polywrap_core/types/env.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)