8000 feat: mute many log.info and log.success by hanxiao · Pull Request #2771 · jina-ai/serve · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

feat: mute many log.info and log.success #2771

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

Merged
merged 1 commit into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 3 deletions jina/clients/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ def check_input(inputs: Optional[InputType] = None, **kwargs) -> None:
from ..request import request_generator

r = next(request_generator(**kwargs))
if isinstance(r, Request):
default_logger.success(f'inputs is valid')
else:
if not isinstance(r, Request):
raise TypeError(f'{typename(r)} is not a valid Request')
except Exception as ex:
default_logger.error(f'inputs is not valid!')
Expand Down
9 changes: 3 additions & 6 deletions jina/clients/base/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,13 @@ async def _get_results(
],
) as channel:
stub = jina_pb2_grpc.JinaRPCStub(channel)
self.logger.success(
self.logger.debug(
f'connected to {self.args.host}:{self.args.port_expose}'
)

if self.show_progress:
cm1, cm2 = ProgressBar(), TimeContext('')
else:
cm1, cm2 = nullcontext(), nullcontext()
cm1 = ProgressBar() if self.show_progress else nullcontext()

with cm1 as p_bar, cm2:
with cm1 as p_bar:
async for resp in stub.Call(req_iter):
resp.as_typed_request(resp.request_type)
resp = resp.as_response()
Expand Down
9 changes: 4 additions & 5 deletions jina/clients/base/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ async def _get_results(

req_iter = self._get_requests(**kwargs)
async with aiohttp.ClientSession() as session:
if self.show_progress:
cm1, cm2 = ProgressBar(), TimeContext('')
else:
cm1, cm2 = nullcontext(), nullcontext()

try:
with cm1 as p_bar, cm2:
cm1 = ProgressBar() if self.show_progress else nullcontext()

with cm1 as p_bar:
all_responses = []
for req in req_iter:
# fix the mismatch between pydantic model and Protobuf model
Expand Down
9 changes: 3 additions & 6 deletions jina/clients/base/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def _get_results(
) as websocket:
# To enable websockets debug logs
# https://websockets.readthedocs.io/en/stable/cheatsheet.html#debugging
self.logger.success(
self.logger.debug(
f'connected to {self.args.host}:{self.args.port_expose}'
)
self.num_requests = 0
Expand All @@ -67,12 +67,9 @@ async def _send_requests(request_iterator):
# There is nothing to send, disconnect gracefully
await websocket.close(reason='No data to send')

if self.show_progress:
cm1, cm2 = ProgressBar(), TimeContext('')
else:
cm1, cm2 = nullcontext(), nullcontext()
cm1 = ProgressBar() if self.show_progress else nullcontext()

with cm1 as p_bar, cm2:
with cm1 as p_bar:
# Unlike gRPC, any arbitrary function (generator) cannot be passed via websockets.
# Simply iterating through the `req_iter` makes the request-response sequential.
# To make client unblocking, :func:`send_requests` and `recv_responses` are separate tasks
Expand Down
6 changes: 3 additions & 3 deletions jina/flow/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
if GATEWAY_NAME in self._pod_nodes:
self._pod_nodes.pop(GATEWAY_NAME)
self._build_level = FlowBuildLevel.EMPTY
self.logger.success(f'Flow is closed!')
self.logger.debug(f'Flow is closed!')
self.logger.close()

def start(self):
Expand Down Expand Up @@ -961,7 +961,7 @@ def start(self):
self.close()
raise

self.logger.info(
self.logger.debug(
f'{self.num_pods} Pods (i.e. {self.num_peas} Peas) are running in this Flow'
)

Expand Down Expand Up @@ -1300,7 +1300,7 @@ def __iter__(self):

def _show_success_message(self):

self.logger.success(f'🎉 Flow is ready to use!')
self.logger.debug(f'🎉 Flow is ready to use!')

address_table = [
f'\t🔗 Protocol: \t\t{colored(self.protocol, attrs="bold")}',
Expand Down
2 changes: 1 addition & 1 deletion jina/helloworld/chatbot/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def hello_world(args):
except:
pass # intentional pass, browser support isn't cross-platform
finally:
default_logger.success(
default_logger.info(
f'You should see a demo page opened in your browser, '
f'if not, you may open {url_html_path} manually'
)
Expand Down
4 changes: 2 additions & 2 deletions jina/helloworld/fashion/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ def write_html(html_path):
except:
pass # intentional pass, browser support isn't cross-platform
finally:
default_logger.success(
default_logger.info(
f'You should see a "hello-world.html" opened in your browser, '
f'if not you may open {url_html_path} manually'
)

colored_url = colored('https://opensource.jina.ai', color='cyan', attrs='underline')
default_logger.success(
default_logger.info(
f'🤩 Intrigued? Play with "jina hello fashion --help" and learn more about Jina at {colored_url}'
)

Expand Down
2 changes: 1 addition & 1 deletion jina/helloworld/multimodal/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def hello_world(args):
except:
pass # intentional pass, browser support isn't cross-platform
finally:
default_logger.success(
default_logger.info(
f'You should see a demo page opened in your browser, '
f'if not, you may open {url_html_path} manually'
)
Expand Down
4 changes: 2 additions & 2 deletions jina/logging/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def update(self, progress: Optional[int] = None, *args, **kwargs) -> None:
self.num_docs += progress

sys.stdout.write(
'{:>10} |{:<{}}| ⏳ {:6d} ⏱️ {:3.1f}s 🐎 {:3.0f} QPS'.format(
'{:>10} |{:<{}}| ⏳ {:6d} ⏱️ {:3.1f}s 🐎 {:3.1f} RPS'.format(
colored(self.task_name, 'cyan'),
colored('█' * num_bars, 'green'),
self.bar_len + 9,
Expand All @@ -267,5 +267,5 @@ def _enter_msg(self):
def _exit_msg(self):
speed = self.num_reqs / self.duration
sys.stdout.write(
f'\t{colored(f"✅ done in ⏱ {self.readable_duration} 🐎 {speed:3.0f} QPS", "green")}\n'
f'\t{colored(f"✅ done in ⏱ {self.readable_duration} 🐎 {speed:3.1f} RPS", "green")}\n'
)
4 changes: 2 additions & 2 deletions jina/peapods/peas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def wait_start_success(self):
# return too early and the shutdown is set, means something fails!!
raise RuntimeFailToStart
else:
self.logger.success(__ready_msg__)
self.logger.debug(__ready_msg__)
else:
_timeout = _timeout or -1
self.logger.warning(
Expand Down Expand Up @@ -256,7 +256,7 @@ def close(self) -> None:
# if it fails to start, the process will hang at `join`
self.terminate()

self.logger.success(__stop_msg__)
self.logger.debug(__stop_msg__)
self.logger.close()

def _set_envs(self):
Expand Down
2 changes: 1 addition & 1 deletion jina/peapods/runtimes/asyncio/prefetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def prefetch_req(num_req, fetch_to):
onrecv_task = []
# the following code "interleaves" prefetch_task and onrecv_task, when one dries, it switches to the other
while prefetch_task:
self.logger.info(
self.logger.debug(
f'send: {self.zmqlet.msg_sent} '
f'recv: {self.zmqlet.msg_recv} '
f'pending: {self.zmqlet.msg_sent - self.zmqlet.msg_recv}'
Expand Down
4 changes: 2 additions & 2 deletions jina/peapods/runtimes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def __enter__(self):

def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type == RuntimeTerminated:
self.logger.info(f'{self!r} is ended')
self.logger.debug(f'{self!r} is ended')
elif exc_type == KeyboardInterrupt:
self.logger.info(f'{self!r} is interrupted by user')
self.logger.debug(f'{self!r} is interrupted by user')
elif exc_type in {Exception, SystemError}:
self.logger.error(
f'{exc_val!r} during {self.run_forever!r}'
Expand Down
4 changes: 2 additions & 2 deletions jina/peapods/runtimes/jinad/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def logstream(self, id: str):
f'log streaming is disabled, you won\'t see logs on the remote\n Reason: {e!r}'
)
except asyncio.CancelledError:
self.logger.info(f'log streaming is cancelled')
self.logger.warning(f'log streaming is cancelled')
finally:
for l in all_remote_loggers.values():
l.close()
Expand Down Expand Up @@ -197,7 +197,7 @@ def get(self, id: str) -> Dict:
timeout=self.timeout,
)
if r.status_code == requests.codes.not_found:
self.logger.info(f'couldn\'t find {id} in remote {self.kind} store')
self.logger.warning(f'couldn\'t find {id} in remote {self.kind} store')
return r.json()
except requests.exceptions.RequestException as ex:
self.logger.error(f'can\'t get status of {self.kind}: {ex!r}')
Expand Down
6 changes: 3 additions & 3 deletions jina/peapods/runtimes/zmq/zed.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _pre_hook(self, msg: 'Message') -> 'ZEDRuntime':
elif self.request_type == 'ControlRequest':
info_msg += f'({self.request.command}) '
info_msg += f'{part_str} from {msg.colored_route}'
self.logger.info(info_msg)
self.logger.debug(info_msg)

if self.expect_parts > 1 and self.expect_parts > len(self.partial_requests):
# NOTE: reduce priority is higher than chain exception
Expand Down Expand Up @@ -289,12 +289,12 @@ def _msg_callback(self, msg: 'Message') -> None:
self._zmqlet.close()
except KeyboardInterrupt as kbex:
# save executor
self.logger.info(f'{kbex!r} causes the breaking from the event loop')
self.logger.debug(f'{kbex!r} causes the breaking from the event loop')
self._zmqlet.send_message(msg)
self._zmqlet.close(flush=False)
except (SystemError, zmq.error.ZMQError) as ex:
# save executor
self.logger.info(f'{ex!r} causes the breaking from the event loop')
self.logger.debug(f'{ex!r} causes the breaking from the event loop')
self._zmqlet.send_message(msg)
self._zmqlet.close()
except MemoryOverHighWatermark:
Expand Down
8 changes: 4 additions & 4 deletions jina/peapods/zmq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _init_sockets(self) -> Tuple:
else:
out_sock, out_addr = None, None

self.logger.info(
self.logger.debug(
f'input {colored(in_addr, "yellow")} ({self.args.socket_in.name}) '
f'output {colored(out_addr, "yellow")} ({self.args.socket_out.name}) '
f'control over {colored(ctrl_addr, "yellow")} ({SocketType.PAIR_BIND.name})'
Expand Down Expand Up @@ -234,7 +234,7 @@ def close(self, *args, **kwargs):

def print_stats(self):
"""Print out the network stats of of itself """
self.logger.info(
self.logger.debug(
f'#sent: {self.msg_sent} '
f'#recv: {self.msg_recv} '
f'sent_size: {get_readable_size(self.bytes_sent)} '
Expand Down Expand Up @@ -454,8 +454,8 @@ def close(self, flush: bool = True, *args, **kwargs):
if not self.is_closed and self.in_sock_type == zmq.DEALER:
try:
self._send_cancel_to_router(raise_exception=True)
except zmq.error.ZMQError as e:
self.logger.info(
except zmq.error.ZMQError:
self.logger.debug(
f'The dealer {self.name} can not unsubscribe from the router. '
f'In case the router is down this is expected.'
)
Expand Down
0