Skip to content

Commit

Permalink
fix scenario notebook 042-data review
Browse files Browse the repository at this point in the history
- use logger instead of print
  • Loading branch information
shubham3121 committed Sep 4, 2024
1 parent 05838e4 commit fb8465c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
21 changes: 7 additions & 14 deletions notebooks/scenarios/bigquery/042-data_review.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"metadata": {},
"outputs": [],
"source": [
"high_client.requests.get_all_pending()"
"high_client.requests"
]
},
{
Expand All @@ -143,7 +143,7 @@
"metadata": {},
"outputs": [],
"source": [
"for request in high_client.requests.get_all_pending():\n",
"for request in high_client.requests:\n",
" if request.code.service_func_name.startswith(\"wrong_syntax_query\"):\n",
" bad_request = request\n",
" if request.code.service_func_name.startswith(\"simple_query\"):\n",
Expand All @@ -168,15 +168,6 @@
"good_job.wait()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"good_request.deposit_result(good_job.info, approve=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -232,7 +223,7 @@
"metadata": {},
"outputs": [],
"source": [
"retry_good_job = good_request.code(blocking=False)"
"bad_job.wait()"
]
},
{
Expand All @@ -241,15 +232,17 @@
"metadata": {},
"outputs": [],
"source": [
"retry_good_job.wait()"
"retry_good_job = good_request.code(blocking=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"retry_good_job.wait()"
]
},
{
"cell_type": "code",
Expand Down
9 changes: 5 additions & 4 deletions packages/syft/src/syft/service/code/user_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from io import StringIO
import json
import keyword
import logging
import random
import re
import sys
Expand Down Expand Up @@ -102,6 +103,8 @@
from .utils import parse_code
from .utils import submit_subjobs_code

logger = logging.getLogger(name=__name__)

if TYPE_CHECKING:
# relative
from ...service.sync.diff_state import AttrDiff
Expand Down Expand Up @@ -1871,13 +1874,11 @@ def to_str(arg: Any) -> str:

if context.job is not None:
time = datetime.datetime.now().strftime("%d/%m/%y %H:%M:%S")
original_print(
f"{time} EXCEPTION LOG ({job_id}):\n{error_msg}", file=sys.stderr
)
logger.error(f"{time} EXCEPTION LOG ({job_id}):\n{error_msg}")
else:
# for local execution
time = datetime.datetime.now().strftime("%d/%m/%y %H:%M:%S")
original_print(f"{time} EXCEPTION LOG:\n{error_msg}\n", file=sys.stderr)
logger.error(f"{time} EXCEPTION LOG:\n{error_msg}\n")

if (
context.server is not None
Expand Down
1 change: 0 additions & 1 deletion packages/syft/src/syft/service/notifier/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def send(
return SyftSuccess(message="Email sent successfully!")
except Exception as e:
message = f"> Error sending email: {subject} to {receiver_email} from: {sender}. {e}"
print(message)
logger.error(message)
return SyftError(message="Failed to send an email.")
# raise SyftException.from_exception(
Expand Down
5 changes: 4 additions & 1 deletion packages/syft/src/syft/store/linked_obj.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# stdlib
import logging
from typing import Any

# third party
Expand All @@ -16,6 +17,8 @@
from ..types.syft_object import SyftObject
from ..types.uid import UID

logger = logging.getLogger(__name__)


@serializable()
class LinkedObject(SyftObject):
Expand Down Expand Up @@ -47,7 +50,7 @@ def resolve(self) -> SyftObject:
self._resolve_cache = resolve
return resolve
except Exception as e:
print(">>> Failed to resolve object", type(api), e)
logger.error(">>> Failed to resolve object", type(api), e)
raise e

@as_result(SyftException)
Expand Down

0 comments on commit fb8465c

Please sign in to comment.