Skip to content

Commit

Permalink
fix is_link loading action_data_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
eelcovdw committed Apr 17, 2024
1 parent be83bcf commit 7d58b45
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/syft/src/syft/service/action/action_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ def __getattribute__(self, name: str) -> Any:

@property
def is_link(self) -> bool:
return isinstance(self.syft_action_data, ActionDataLink)
return self.syft_action_data_type is ActionDataLink

def __setattr__(self, name: str, value: Any) -> Any:
defined_on_self = name in self.__dict__ or name in self.__private_attributes__
Expand Down
9 changes: 3 additions & 6 deletions packages/syft/src/syft/service/action/action_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,11 @@ def is_resolved(
) -> Result[Ok[bool], Err[str]]:
"""Get an object from the action store"""
# relative
from .action_data_empty import ActionDataLink

result = self._get(context, uid)
if result.is_ok():
obj = result.ok()
if isinstance(obj.syft_action_data, ActionDataLink):
if obj.is_link:
result = self.resolve_links(
context, obj.syft_action_data.action_object_id.id
)
Expand Down Expand Up @@ -177,15 +176,14 @@ def resolve_links(
) -> Result[Ok[ActionObject], Err[str]]:
"""Get an object from the action store"""
# relative
from .action_data_empty import ActionDataLink

result = self.store.get(uid=uid, credentials=context.credentials)
# If user has permission to get the object / object exists
if result.is_ok():
obj = result.ok()

# If it's not a leaf
if isinstance(obj.syft_action_data, ActionDataLink):
if obj.is_link:
nested_result = self.resolve_links(
context, obj.syft_action_data.action_object_id.id, twin_mode
)
Expand Down Expand Up @@ -219,7 +217,6 @@ def _get(
# stdlib

# relative
from .action_data_empty import ActionDataLink

result = self.store.get(
uid=uid, credentials=context.credentials, has_permission=has_permission
Expand All @@ -234,7 +231,7 @@ def _get(
if (
not isinstance(obj, TwinObject) # type: ignore[unreachable]
and resolve_nested
and isinstance(obj.syft_action_data, ActionDataLink)
and obj.is_link
):
if not self.is_resolved( # type: ignore[unreachable]
context, obj.syft_action_data.action_object_id.id
Expand Down
3 changes: 1 addition & 2 deletions packages/syft/src/syft/service/job/job_stash.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from ...util.markdown import as_markdown_code
from ...util.telemetry import instrument
from ...util.util import prompt_warning_message
from ..action.action_data_empty import ActionDataLink
from ..action.action_object import Action
from ..action.action_object import ActionObject
from ..action.action_permissions import ActionObjectPermission
Expand Down Expand Up @@ -487,7 +486,7 @@ def wait(
result_obj = api.services.action.get(
self.result.id, resolve_nested=False
)
if isinstance(result_obj.syft_action_data, ActionDataLink) and job_only:
if result_obj.is_link and job_only:
print(
"You're trying to wait on a job that has a link as a result."
"This means that the job may be ready but the linked result may not."
Expand Down

0 comments on commit 7d58b45

Please sign in to comment.