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
98 changes: 25 additions & 73 deletions packages/polywrap-core/poetry.lock

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

4 changes: 0 additions & 4 deletions packages/polywrap-core/polywrap_core/types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
"""This module contains all the core types used in the various polywrap packages."""
from .client import *
from .config import *
from .env import *
from .errors import *
from .file_reader import *
from .invocable import *
from .invoke_args import *
from .invoker import *
from .invoker_client import *
from .options import *
from .uri import *
from .uri_like import *
from .uri_package import *
from .uri_package_wrapper import *
from .uri_resolution_context import *
Expand Down
49 changes: 25 additions & 24 deletions packages/polywrap-core/polywrap_core/types/client.py
Original file line number Diff line number Diff line change
@@ -1,83 +1,84 @@
"""This module contains the Client interface."""
from __future__ import annotations

from abc import abstractmethod
from typing import Dict, List, Optional, Union
from typing import Any, Dict, List, Optional, Protocol, Union

from polywrap_manifest import AnyWrapManifest
from polywrap_manifest import AnyWrapManifest, DeserializeManifestOptions

from .env import Env
from .invoker_client import InvokerClient
from .options.file_options import GetFileOptions
from .options.manifest_options import GetManifestOptions
from .uri import Uri
from .uri_package_wrapper import UriPackageOrWrapper
from .uri_resolver import UriResolver


class Client(InvokerClient[UriPackageOrWrapper]):
class Client(InvokerClient, Protocol):
"""Client interface defines core set of functionalities\
for interacting with a wrapper."""

@abstractmethod
def get_interfaces(self) -> Dict[Uri, List[Uri]]:
"""Get dictionary of interfaces and their implementations.

Returns:
Dict[Uri, List[Uri]]: Dictionary of interfaces and their implementations where\
key is interface URI and value is list of implementation uris.
"""
...

@abstractmethod
def get_envs(self) -> Dict[Uri, Env]:
def get_envs(self) -> Dict[Uri, Any]:
"""Get dictionary of environments.

Returns:
Dict[Uri, Env]: Dictionary of environments where key is URI and value is env.
Dict[Uri, Any]: Dictionary of environments where key is URI and value is env.
"""
...

@abstractmethod
def get_env_by_uri(self, uri: Uri) -> Union[Env, None]:
def get_env_by_uri(self, uri: Uri) -> Union[Any, None]:
"""Get environment by URI.

Args:
uri (Uri): URI of the Wrapper.

Returns:
Union[Env, None]: env if found, otherwise None.
Union[Any, None]: env if found, otherwise None.
"""
...

@abstractmethod
def get_uri_resolver(self) -> UriResolver:
"""Get URI resolver.

Returns:
IUriResolver: URI resolver.
UriResolver: URI resolver.
"""
...

@abstractmethod
async def get_file(self, uri: Uri, options: GetFileOptions) -> Union[bytes, str]:
def get_file(
self, uri: Uri, path: str, encoding: Optional[str] = "utf-8"
) -> Union[bytes, str]:
"""Get file from URI.

Args:
uri (Uri): URI of the wrapper.
options (GetFileOptions): Options for getting file from the wrapper.
path (str): Path to the file.
encoding (Optional[str]): Encoding of the file.

Returns:
Union[bytes, str]]: file contents.
"""
...

@abstractmethod
async def get_manifest(
self, uri: Uri, options: Optional[GetManifestOptions] = None
def get_manifest(
self, uri: Uri, options: Optional[DeserializeManifestOptions] = None
) -> AnyWrapManifest:
"""Get manifest from URI.

Args:
uri (Uri): URI of the wrapper.
options (Optional[GetManifestOptions]): \
options (Optional[DeserializeManifestOptions]): \
Options for getting manifest from the wrapper.

Returns:
AnyWrapManifest: Manifest of the wrapper.
"""
...


__all__ = ["Client"]
10 changes: 6 additions & 4 deletions packages/polywrap-core/polywrap_core/types/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from __future__ import annotations

from dataclasses import dataclass, field
from typing import Dict, List
from typing import Any, Dict, List

from .env import Env
from .uri import Uri
from .uri_resolver import UriResolver

Expand All @@ -14,14 +13,17 @@ class ClientConfig:
"""Client configuration.

Attributes:
envs (Dict[Uri, Env]): Dictionary of environments \
envs (Dict[Uri, Any]): Dictionary of environments \
where key is URI and value is env.
interfaces (Dict[Uri, List[Uri]]): Dictionary of interfaces \
and their implementations where key is interface URI \
and value is list of implementation URIs.
resolver (UriResolver): URI resolver.
"""

envs: Dict[Uri, Env] = field(default_factory=dict)
envs: Dict[Uri, Any] = field(default_factory=dict)
interfaces: Dict[Uri, List[Uri]] = field(default_factory=dict)
resolver: UriResolver


__all__ = ["ClientConfig"]
4 changes: 0 additions & 4 deletions packages/polywrap-core/polywrap_core/types/env.py

This file was deleted.

Loading