Skip to content

Commit

Permalink
Merge pull request #8700 from OpenMined/eelco/fix-accept-deposit-result
Browse files Browse the repository at this point in the history
bugfix: accept_deposit for non-job ActionObject
  • Loading branch information
teo-milea committed Apr 12, 2024
2 parents de2d17d + 0b836ba commit a697b8f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/syft/src/syft/service/request/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def _get_latest_or_create_job(self) -> Job | SyftError:

return job

def _is_action_object_from_job(self, action_object: ActionObject) -> Job | None: # type: ignore
def _get_job_from_action_object(self, action_object: ActionObject) -> Job | None: # type: ignore
api = APIRegistry.api_for(self.node_uid, self.syft_client_verify_key)
if api is None:
raise ValueError(f"Can't access the api. You must login to {self.node_uid}")
Expand All @@ -687,13 +687,19 @@ def accept_by_depositing_result(
elif isinstance(result, ActionObject):
# Do not allow accepting a result produced by a Job,
# This can cause an inconsistent Job state
if self._is_action_object_from_job(result):
action_object_job = self._is_action_object_from_job(result)
if action_object_job is not None:
return SyftError(
message=f"This ActionObject is the result of Job {action_object_job.id}, "
f"please use the `Job.info` instead."
)
action_object_job = self._get_job_from_action_object(result)
if action_object_job is not None:
return SyftError(
message=f"This ActionObject is the result of Job {action_object_job.id}, "
f"please use the `Job.info` instead."
)
else:
job_info = JobInfo(
includes_metadata=True,
includes_result=True,
status=JobStatus.COMPLETED,
resolved=True,
)
else:
# NOTE result is added at the end of function (once ActionObject is created)
job_info = JobInfo(
Expand Down

0 comments on commit a697b8f

Please sign in to comment.