Skip to content

Commit a32b8b8

Browse files
committed
feat: add proper docs
1 parent 8c2615d commit a32b8b8

1 file changed

Lines changed: 81 additions & 12 deletions

File tree

  • packages/polywrap-client/polywrap_client

packages/polywrap-client/polywrap_client/client.py

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,49 +58,102 @@ def __init__(self, config: PolywrapClientConfig):
5858
"""
5959
self._config = config
6060

61-
def get_config(self):
62-
"""Get the client configuration."""
61+
def get_config(self) -> PolywrapClientConfig:
62+
"""Get the client configuration.
63+
64+
Returns:
65+
PolywrapClientConfig: The polywrap client configuration.
66+
"""
6367
return self._config
6468

6569
def get_uri_resolver(self) -> UriResolver:
66-
"""Get the URI resolver."""
70+
"""Get the URI resolver.
71+
72+
Returns:
73+
UriResolver: The URI resolver.
74+
"""
6775
return self._config.resolver
6876

6977
def get_envs(self) -> Dict[Uri, Env]:
70-
"""Get the dictionary of environment variables."""
78+
"""Get the dictionary of environment variables.
79+
80+
Returns:
81+
Dict[Uri, Env]: The dictionary of environment variables.
82+
"""
7183
envs: Dict[Uri, Env] = self._config.envs
7284
return envs
7385

7486
def get_interfaces(self) -> Dict[Uri, List[Uri]]:
75-
"""Get the interfaces."""
87+
"""Get the interfaces.
88+
89+
Returns:
90+
Dict[Uri, List[Uri]]: The dictionary of interface-implementations.
91+
"""
7692
interfaces: Dict[Uri, List[Uri]] = self._config.interfaces
7793
return interfaces
7894

7995
def get_implementations(self, uri: Uri) -> Union[List[Uri], None]:
80-
"""Get the implementations for the given interface URI."""
96+
"""Get the implementations for the given interface URI.
97+
98+
Args:
99+
uri (Uri): The interface URI.
100+
101+
Returns:
102+
Union[List[Uri], None]: The list of implementation URIs.
103+
"""
81104
interfaces: Dict[Uri, List[Uri]] = self.get_interfaces()
82105
return interfaces.get(uri)
83106

84107
def get_env_by_uri(self, uri: Uri) -> Union[Env, None]:
85-
"""Get the environment variables for the given URI."""
108+
"""Get the environment variables for the given URI.
109+
110+
Args:
111+
uri (Uri): The URI of the wrapper.
112+
113+
Returns:
114+
Union[Env, None]: The environment variables.
115+
"""
86116
return self._config.envs.get(uri)
87117

88118
async def get_file(self, uri: Uri, options: GetFileOptions) -> Union[bytes, str]:
89-
"""Get the file from the given wrapper URI."""
119+
"""Get the file from the given wrapper URI.
120+
121+
Args:
122+
uri (Uri): The wrapper URI.
123+
options (GetFileOptions): The options for getting the file.
124+
125+
Returns:
126+
Union[bytes, str]: The file contents.
127+
"""
90128
loaded_wrapper = await self.load_wrapper(uri)
91129
return await loaded_wrapper.get_file(options)
92130

93131
async def get_manifest(
94132
self, uri: Uri, options: Optional[GetManifestOptions] = None
95133
) -> AnyWrapManifest:
96-
"""Get the manifest from the given wrapper URI."""
134+
"""Get the manifest from the given wrapper URI.
135+
136+
Args:
137+
uri (Uri): The wrapper URI.
138+
options (Optional[GetManifestOptions]): The options for getting the manifest.
139+
140+
Returns:
141+
AnyWrapManifest: The manifest.
142+
"""
97143
loaded_wrapper = await self.load_wrapper(uri)
98144
return loaded_wrapper.get_manifest()
99145

100146
async def try_resolve_uri(
101147
self, options: TryResolveUriOptions[UriPackageOrWrapper]
102148
) -> UriPackageOrWrapper:
103-
"""Try to resolve the given URI."""
149+
"""Try to resolve the given URI.
150+
151+
Args:
152+
options (TryResolveUriOptions[UriPackageOrWrapper]): The options for resolving the URI.
153+
154+
Returns:
155+
UriPackageOrWrapper: The resolved URI, package or wrapper.
156+
"""
104157
uri = options.uri
105158
uri_resolver = self._config.resolver
106159
resolution_context = options.resolution_context or UriResolutionContext()
@@ -112,7 +165,16 @@ async def load_wrapper(
112165
uri: Uri,
113166
resolution_context: Optional[IUriResolutionContext[UriPackageOrWrapper]] = None,
114167
) -> Wrapper[UriPackageOrWrapper]:
115-
"""Load the wrapper for the given URI."""
168+
"""Load the wrapper for the given URI.
169+
170+
Args:
171+
uri (Uri): The wrapper URI.
172+
resolution_context (Optional[IUriResolutionContext[UriPackageOrWrapper]]):\
173+
The resolution context.
174+
175+
Returns:
176+
Wrapper[UriPackageOrWrapper]: initialized wrapper instance.
177+
"""
116178
resolution_context = resolution_context or UriResolutionContext()
117179

118180
uri_package_or_wrapper = await self.try_resolve_uri(
@@ -144,7 +206,14 @@ async def load_wrapper(
144206
)
145207

146208
async def invoke(self, options: InvokerOptions[UriPackageOrWrapper]) -> Any:
147-
"""Invoke the given wrapper URI."""
209+
"""Invoke the given wrapper URI.
210+
211+
Args:
212+
options (InvokerOptions[UriPackageOrWrapper]): The options for invoking the wrapper.
213+
214+
Returns:
215+
Any: The result of the invocation.
216+
"""
148217
resolution_context = options.resolution_context or UriResolutionContext()
149218
wrapper = await self.load_wrapper(
150219
options.uri, resolution_context=resolution_context

0 commit comments

Comments
 (0)