Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Fixing mypy issues of syft/ #8523

Merged
merged 45 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
09df3cf
[refactor] done fixing mypy issues of `syft/client`
khoaguin Feb 22, 2024
81d06d4
[refactor] done fixing mypy issues for `syft/node`
khoaguin Feb 22, 2024
2604b1c
[refactor] done fixing mypy issues of `syft/exceptions`
khoaguin Feb 22, 2024
30ff73f
[refactor] fix mypy issues of `syft/custom_worker`
khoaguin Feb 23, 2024
0f557f4
[refactor] fix mypy issues for `syft/store`
khoaguin Feb 23, 2024
542f83a
[refactor] fixing mypy issues of `syft/client`, `syft/types`
khoaguin Feb 24, 2024
6843c33
Merge branch 'dev' into fix-mypy-issues-syft
khoaguin Feb 26, 2024
5264f9c
[refactor] fix container notebooks not passing due to
khoaguin Feb 26, 2024
00d8b85
[refactor] fixing various mypy issues in `syft/`
khoaguin Feb 27, 2024
a0f6fce
[refactor] fixing mypy issues for `syft/`
khoaguin Feb 27, 2024
622a362
[refactor] continue fixing mypy issues
khoaguin Feb 27, 2024
3c99f15
Merge branch 'dev' into fix-mypy-issues-syft
khoaguin Feb 28, 2024
f2b01bc
Merge branch 'dev' into fix-mypy-issues-syft
khoaguin Feb 29, 2024
0b1c487
[refactor] fix some simple mypy issues
khoaguin Feb 29, 2024
cca706a
[refactor] fix mypy issues in `migrations.py`
khoaguin Feb 29, 2024
1a3a0c7
[refactor] fix `syft/client` related mypy issues
khoaguin Feb 29, 2024
6279bfd
[refactor] fix unmatched function definitions
khoaguin Feb 29, 2024
ded369a
[refactor] fixing `service/action` related mypy issues
khoaguin Feb 29, 2024
afea420
[refactor] remove some classes' attribute type
khoaguin Feb 29, 2024
1c15076
[refactor] add some `type: ignore` in
khoaguin Feb 29, 2024
5291d06
[refactor] fix mypy issues related to code
khoaguin Mar 1, 2024
7ebbadf
[refactor] fix dataset service related mypy issues
khoaguin Mar 1, 2024
daab8a7
[refactor] fix mypy issues for job stash
khoaguin Mar 1, 2024
2f0b8f1
[refactor] fix mypy issues for network service
khoaguin Mar 1, 2024
e896ae1
[refactor] fix mypy issues for policy service
khoaguin Mar 1, 2024
1acd815
[refactor] fix mypy issues for project service
khoaguin Mar 1, 2024
880f6c4
[refactor] fix mypy issues for queue service
khoaguin Mar 1, 2024
49adb35
[refactor] fix mypy issues for request service
khoaguin Mar 1, 2024
eb1c1d1
[refactor] fix mypy issues for `service/service.py`
khoaguin Mar 1, 2024
9f93c5b
[refactor] fix mypy issues for user service
khoaguin Mar 1, 2024
c2bbc28
[refactor] fix mypy issues for worker service
khoaguin Mar 1, 2024
e801b7c
[refactor] fix the rest of mypy issues in `syft`
khoaguin Mar 1, 2024
111eac0
Merge branch 'dev' into fix-mypy-issues-syft
shubham3121 Mar 1, 2024
1f6d381
Merge branch 'dev' into fix-mypy-issues-syft
kiendang Mar 2, 2024
a7c6f95
Merge branch 'dev' into fix-mypy-issues-syft
khoaguin Mar 4, 2024
f5543da
Merge branch 'dev' into fix-mypy-issues-syft
khoaguin Mar 4, 2024
0596219
fix not reachable mypy errors in upload_files
shubham3121 Mar 4, 2024
331dd92
type cast typing for metadata in enclave client exchange routes
shubham3121 Mar 4, 2024
b9e53ce
remove type ignore from search results
shubham3121 Mar 4, 2024
f5c50a6
return early is context.node or context.output is None in transforms
shubham3121 Mar 4, 2024
5a9a3b2
Merge branch 'dev' into fix-mypy-issues-syft
khoaguin Mar 4, 2024
6b5d33d
Merge branch 'dev' into fix-mypy-issues-syft
khoaguin Mar 5, 2024
8822a0a
Merge branch 'dev' into fix-mypy-issues-syft
khoaguin Mar 5, 2024
77658a0
[refactor] fix mypy issues post merge with `node-state-sync`
khoaguin Mar 5, 2024
79ffa8c
[test] skip `test_sync_flow` on windows
khoaguin Mar 5, 2024
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ repos:
- id: mypy
name: "mypy: syft"
always_run: true
files: "^packages/syft/src/syft/serde|^packages/syft/src/syft/util|^packages/syft/src/syft/service"
# files: "^packages/syft/src/syft/"
files: "^packages/syft/src/syft/"
exclude: "packages/syft/src/syft/types/dicttuple.py|^packages/syft/src/syft/service/action/action_graph.py|^packages/syft/src/syft/external/oblv/"
args: [
"--follow-imports=skip",
"--ignore-missing-imports",
Expand Down
3 changes: 3 additions & 0 deletions packages/syft/src/syft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
logger.start()

try:
# third party
from IPython import get_ipython

get_ipython() # noqa: F821
# TODO: add back later or auto detect
# display(
Expand Down
7 changes: 6 additions & 1 deletion packages/syft/src/syft/abstract_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
from enum import Enum
from typing import Callable
from typing import Optional
from typing import TYPE_CHECKING
from typing import Union

# relative
from .serde.serializable import serializable
from .types.uid import UID

if TYPE_CHECKING:
# relative
from .service.service import AbstractService


@serializable()
class NodeType(str, Enum):
Expand Down Expand Up @@ -37,5 +42,5 @@ class AbstractNode:
node_side_type: Optional[NodeSideType]
in_memory_workers: bool

def get_service(self, path_or_func: Union[str, Callable]) -> Callable:
def get_service(self, path_or_func: Union[str, Callable]) -> "AbstractService":
raise NotImplementedError
44 changes: 25 additions & 19 deletions packages/syft/src/syft/client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from typing import Tuple
from typing import Union
from typing import _GenericAlias
from typing import cast
from typing import get_args
from typing import get_origin

Expand Down Expand Up @@ -240,8 +241,8 @@ def __ipython_inspector_signature_override__(self) -> Optional[Signature]:
return self.signature

def prepare_args_and_kwargs(
self, args: List[Any], kwargs: Dict[str, Any]
) -> Union[SyftError, Tuple[List[Any], Dict[str, Any]]]:
self, args: Union[list, tuple], kwargs: dict[str, Any]
) -> Union[SyftError, tuple[tuple, dict[str, Any]]]:
# Validate and migrate args and kwargs
res = validate_callable_args_and_kwargs(args, kwargs, self.signature)
if isinstance(res, SyftError):
Expand Down Expand Up @@ -278,7 +279,7 @@ def __call__(self, *args: Any, **kwargs: Any) -> Any:
api_call = SyftAPICall(
node_uid=self.node_uid,
path=self.path,
args=_valid_args,
args=list(_valid_args),
kwargs=_valid_kwargs,
blocking=blocking,
)
Expand All @@ -303,8 +304,8 @@ class RemoteUserCodeFunction(RemoteFunction):
api: SyftAPI

def prepare_args_and_kwargs(
self, args: List[Any], kwargs: Dict[str, Any]
) -> Union[SyftError, Tuple[List[Any], Dict[str, Any]]]:
self, args: Union[list, tuple], kwargs: Dict[str, Any]
) -> Union[SyftError, tuple[tuple, dict[str, Any]]]:
# relative
from ..service.action.action_object import convert_to_pointers

Expand Down Expand Up @@ -505,9 +506,12 @@ def _repr_html_(self) -> Any:
results = self.get_all()
return results._repr_html_()

def __call__(self, *args: Any, **kwargs: Any) -> Any:
return NotImplementedError


def debox_signed_syftapicall_response(
signed_result: SignedSyftAPICall,
signed_result: Union[SignedSyftAPICall, Any],
) -> Union[Any, SyftError]:
if not isinstance(signed_result, SignedSyftAPICall):
return SyftError(message="The result is not signed")
Expand Down Expand Up @@ -824,16 +828,16 @@ def build_endpoint_tree(
)

@property
def services(self) -> Optional[APIModule]:
def services(self) -> APIModule:
if self.api_module is None:
self.generate_endpoints()
return self.api_module
return cast(APIModule, self.api_module)

@property
def lib(self) -> Optional[APIModule]:
def lib(self) -> APIModule:
if self.libs is None:
self.generate_endpoints()
return self.libs
return cast(APIModule, self.libs)

def has_service(self, service_name: str) -> bool:
return hasattr(self.services, service_name)
Expand Down Expand Up @@ -939,19 +943,21 @@ class NodeIdentity(Identity):
node_name: str

@staticmethod
def from_api(api: SyftAPI) -> Optional[NodeIdentity]:
def from_api(api: SyftAPI) -> NodeIdentity:
# stores the name root verify key of the domain node
if api.connection is not None:
node_metadata = api.connection.get_node_metadata(api.signing_key)
return NodeIdentity(
node_name=node_metadata.name,
node_id=api.node_uid,
verify_key=SyftVerifyKey.from_string(node_metadata.verify_key),
)
return None
if api.connection is None:
raise ValueError("{api}'s connection is None. Can't get the node identity")
node_metadata = api.connection.get_node_metadata(api.signing_key)
return NodeIdentity(
node_name=node_metadata.name,
node_id=api.node_uid,
verify_key=SyftVerifyKey.from_string(node_metadata.verify_key),
)

@classmethod
def from_change_context(cls, context: ChangeContext) -> NodeIdentity:
if context.node is None:
raise ValueError(f"{context}'s node is None")
return cls(
node_name=context.node.name,
node_id=context.node.id,
Expand Down
Loading
Loading