Explorar o código

Suppress asyncio error logs by default (#142)

Alexander Borzunov %!s(int64=2) %!d(string=hai) anos
pai
achega
84fec81543

+ 6 - 1
src/petals/client/remote_model.py

@@ -1,10 +1,11 @@
+import os
 from contextlib import contextmanager
 from typing import List, Optional
 
 import hivemind
 import torch
 import torch.nn as nn
-from hivemind import get_logger, use_hivemind_log_handler
+from hivemind.utils.logging import get_logger, loglevel, use_hivemind_log_handler
 from transformers.modeling_outputs import BaseModelOutputWithPastAndCrossAttentions
 
 from petals.bloom.model import (
@@ -23,6 +24,10 @@ from petals.utils.misc import DUMMY
 use_hivemind_log_handler("in_root_logger")
 logger = get_logger(__file__)
 
+# We suppress asyncio error logs by default since they are mostly not relevant for the end user
+asyncio_loglevel = os.getenv("PETALS_ASYNCIO_LOGLEVEL", "FATAL" if loglevel != "DEBUG" else "DEBUG")
+get_logger("asyncio").setLevel(asyncio_loglevel)
+
 
 class DistributedBloomConfig(BloomConfig):
     """

+ 1 - 1
src/petals/client/routing/sequence_manager.py

@@ -118,7 +118,7 @@ class RemoteSequenceManager:
             current_index = chosen_span.end
 
         route_repr = " => ".join([f"{span.start}:{span.end} via …{str(span.peer_id)[-6:]}" for span in span_sequence])
-        logger.info(f"Route found: {route_repr}")
+        logger.debug(f"Route found: {route_repr}")
         return span_sequence
 
     def __getitem__(self, ix: Union[int, slice]) -> RemoteSequenceManager: