-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8759 from OpenMined/aziz/error_reporting
fix job error reporting
- Loading branch information
Showing
9 changed files
with
122 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,62 +307,62 @@ def private_function(context) -> str: | |
return 42 | ||
|
||
|
||
def test_twin_api_integration(full_high_worker, full_low_worker): | ||
low_client = full_low_worker.login( | ||
email="[email protected]", password="changethis" | ||
) | ||
high_client = full_high_worker.login( | ||
email="[email protected]", password="changethis" | ||
) | ||
|
||
low_client.register( | ||
email="[email protected]", | ||
name="John Doe", | ||
password="pw", | ||
password_verify="pw", | ||
) | ||
|
||
client_low_ds = low_client.login( | ||
email="[email protected]", | ||
password="pw", | ||
) | ||
|
||
new_endpoint = sy.TwinAPIEndpoint( | ||
path="testapi.query", | ||
private_function=private_function, | ||
mock_function=mock_function, | ||
description="", | ||
) | ||
high_client.api.services.api.add(endpoint=new_endpoint) | ||
high_client.refresh() | ||
high_private_res = high_client.api.services.testapi.query.private() | ||
assert high_private_res == 42 | ||
|
||
low_state = low_client.get_sync_state() | ||
high_state = high_client.get_sync_state() | ||
diff_state = compare_states(high_state, low_state) | ||
|
||
obj_diff_batch = diff_state[0] | ||
widget = resolve_single(obj_diff_batch) | ||
widget.click_sync() | ||
|
||
obj_diff_batch = diff_state[1] | ||
widget = resolve_single(obj_diff_batch) | ||
widget.click_sync() | ||
|
||
high_mock_res = high_client.api.services.testapi.query.mock() | ||
assert high_mock_res == -42 | ||
|
||
client_low_ds.refresh() | ||
high_client.refresh() | ||
low_private_res = client_low_ds.api.services.testapi.query.private() | ||
assert isinstance( | ||
low_private_res, SyftError | ||
), "Should not have access to private on low side" | ||
low_mock_res = client_low_ds.api.services.testapi.query.mock() | ||
high_mock_res = high_client.api.services.testapi.query.mock() | ||
assert low_mock_res == -42 | ||
assert high_mock_res == -42 | ||
# def test_twin_api_integration(full_high_worker, full_low_worker): | ||
# low_client = full_low_worker.login( | ||
# email="[email protected]", password="changethis" | ||
# ) | ||
# high_client = full_high_worker.login( | ||
# email="[email protected]", password="changethis" | ||
# ) | ||
|
||
# low_client.register( | ||
# email="[email protected]", | ||
# name="John Doe", | ||
# password="pw", | ||
# password_verify="pw", | ||
# ) | ||
|
||
# client_low_ds = low_client.login( | ||
# email="[email protected]", | ||
# password="pw", | ||
# ) | ||
|
||
# new_endpoint = sy.TwinAPIEndpoint( | ||
# path="testapi.query", | ||
# private_function=private_function, | ||
# mock_function=mock_function, | ||
# description="", | ||
# ) | ||
# high_client.api.services.api.add(endpoint=new_endpoint) | ||
# high_client.refresh() | ||
# high_private_res = high_client.api.services.testapi.query.private() | ||
# assert high_private_res == 42 | ||
|
||
# low_state = low_client.get_sync_state() | ||
# high_state = high_client.get_sync_state() | ||
# diff_state = compare_states(high_state, low_state) | ||
|
||
# obj_diff_batch = diff_state[0] | ||
# widget = resolve_single(obj_diff_batch) | ||
# widget.click_sync() | ||
|
||
# obj_diff_batch = diff_state[1] | ||
# widget = resolve_single(obj_diff_batch) | ||
# widget.click_sync() | ||
|
||
# high_mock_res = high_client.api.services.testapi.query.mock() | ||
# assert high_mock_res == -42 | ||
|
||
# client_low_ds.refresh() | ||
# high_client.refresh() | ||
# low_private_res = client_low_ds.api.services.testapi.query.private() | ||
# assert isinstance( | ||
# low_private_res, SyftError | ||
# ), "Should not have access to private on low side" | ||
# low_mock_res = client_low_ds.api.services.testapi.query.mock() | ||
# high_mock_res = high_client.api.services.testapi.query.mock() | ||
# assert low_mock_res == -42 | ||
# assert high_mock_res == -42 | ||
|
||
|
||
def test_skip_user_code(low_worker, high_worker): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
# third party | ||
import pytest | ||
from result import Err | ||
|
||
# syft absolute | ||
import syft | ||
|
@@ -13,6 +14,8 @@ | |
from syft.client.syncing import compare_clients | ||
from syft.client.syncing import resolve_single | ||
from syft.node.worker import Worker | ||
from syft.service.job.job_stash import JobStash | ||
from syft.service.job.job_stash import JobStatus | ||
from syft.service.response import SyftError | ||
from syft.service.response import SyftSuccess | ||
|
||
|
@@ -162,3 +165,37 @@ def compute(query): | |
assert isinstance( | ||
private_res, SyftError | ||
), "Should not be able to access private function on low side." | ||
|
||
|
||
def test_function_error(full_low_worker) -> None: | ||
root_domain_client = full_low_worker.login( | ||
email="[email protected]", password="changethis" | ||
) | ||
root_domain_client.register( | ||
name="data-scientist", | ||
email="[email protected]", | ||
password="0000", | ||
password_verify="0000", | ||
) | ||
ds_client = root_domain_client.login( | ||
email="[email protected]", | ||
password="0000", | ||
) | ||
|
||
users = root_domain_client.users.get_all() | ||
|
||
@sy.syft_function_single_use() | ||
def compute_sum(): | ||
assert False | ||
|
||
compute_sum.code = dedent(compute_sum.code) | ||
ds_client.api.services.code.request_code_execution(compute_sum) | ||
|
||
users[-1].allow_mock_execution() | ||
result = ds_client.api.services.code.compute_sum(blocking=True) | ||
assert isinstance(result.get(), Err) | ||
|
||
job_info = ds_client.api.services.code.compute_sum(blocking=False) | ||
result = job_info.wait(timeout=10) | ||
assert isinstance(result.get(), Err) | ||
assert job_info.status == JobStatus.ERRORED |