Skip to content

Commit 6fa4190

Browse files
removed extraneous logging imports and loggers
1 parent 53779ec commit 6fa4190

File tree

18 files changed

+17
-79
lines changed

18 files changed

+17
-79
lines changed

ml-agents-envs/mlagents_envs/communicator.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import logging
21
from typing import Optional
3-
42
from mlagents_envs.communicator_objects.unity_output_pb2 import UnityOutputProto
53
from mlagents_envs.communicator_objects.unity_input_pb2 import UnityInputProto
64

7-
logger = logging.getLogger("mlagents_envs")
8-
95

106
class Communicator(object):
117
def __init__(self, worker_id=0, base_port=5005):

ml-agents-envs/mlagents_envs/exception.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import logging
2-
3-
logger = logging.getLogger("mlagents_envs")
4-
5-
61
class UnityException(Exception):
72
"""
83
Any error related to ml-agents environment.

ml-agents-envs/mlagents_envs/rpc_communicator.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import logging
21
import grpc
32
from typing import Optional
43

@@ -16,8 +15,6 @@
1615
from mlagents_envs.communicator_objects.unity_output_pb2 import UnityOutputProto
1716
from .exception import UnityTimeOutException, UnityWorkerInUseException
1817

19-
logger = logging.getLogger("mlagents_envs")
20-
2118

2219
class UnityToExternalServicerImplementation(UnityToExternalProtoServicer):
2320
def __init__(self):

ml-agents-envs/mlagents_envs/rpc_utils.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77
NONE as COMPRESSION_NONE,
88
)
99
from mlagents_envs.communicator_objects.brain_parameters_pb2 import BrainParametersProto
10-
import logging
1110
import numpy as np
1211
import io
1312
from typing import cast, List, Tuple, Union, Collection, Optional, Iterable
1413
from PIL import Image
1514

16-
logger = logging.getLogger("mlagents_envs")
17-
1815

1916
def agent_group_spec_from_proto(
2017
brain_param_proto: BrainParametersProto, agent_info: AgentInfoProto

ml-agents/mlagents/logging_util.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@
33

44
def create_logger(name):
55
log_level = logging.INFO
6+
date_format = "%Y-%m-%d %H:%M:%S"
67
log_format = "%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] %(message)s"
7-
logging.basicConfig(level=log_level, format=log_format, datefmt="%Y-%m-%d %H:%M:%S")
8+
9+
logging.basicConfig(level=log_level, format=log_format, datefmt=date_format)
810
logger = logging.getLogger(name=name)
911
return logger
10-
11-
12-
# TODO
13-
"""
14-
1. change mlagents.trainers to mlagents_trainers
15-
2. logger should be in lowercase in all files
16-
3. if logger is not used in a file then it should be deleted
17-
"""

ml-agents/mlagents/trainers/brain.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import logging
2-
31
from mlagents_envs.communicator_objects.agent_info_pb2 import AgentInfoProto
42
from mlagents_envs.communicator_objects.brain_parameters_pb2 import BrainParametersProto
53
from typing import List, NamedTuple
64

7-
logger = logging.getLogger("mlagents.trainers")
8-
95

106
class CameraResolution(NamedTuple):
117
height: int

ml-agents/mlagents/trainers/components/reward_signals/gail/signal.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from typing import Any, Dict, List
2-
import logging
32
import numpy as np
43
from mlagents.tf_utils import tf
54

@@ -8,8 +7,6 @@
87
from .model import GAILModel
98
from mlagents.trainers.demo_loader import demo_to_buffer
109

11-
LOGGER = logging.getLogger("mlagents.trainers")
12-
1310

1411
class GAILRewardSignal(RewardSignal):
1512
def __init__(

ml-agents/mlagents/trainers/components/reward_signals/reward_signal_factory.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import logging
21
from typing import Any, Dict, Type
3-
42
from mlagents.trainers.exception import UnityTrainerException
53
from mlagents.trainers.components.reward_signals import RewardSignal
64
from mlagents.trainers.components.reward_signals.extrinsic.signal import (
@@ -12,8 +10,6 @@
1210
)
1311
from mlagents.trainers.policy.tf_policy import TFPolicy
1412

15-
logger = logging.getLogger("mlagents.trainers")
16-
1713

1814
NAME_TO_CLASS: Dict[str, Type[RewardSignal]] = {
1915
"extrinsic": ExtrinsicRewardSignal,

ml-agents/mlagents/trainers/demo_loader.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import logging
21
import os
32
from typing import List, Tuple
43
import numpy as np
@@ -22,9 +21,6 @@
2221
from google.protobuf.internal.decoder import _DecodeVarint32 # type: ignore
2322

2423

25-
logger = logging.getLogger("mlagents.trainers")
26-
27-
2824
@timed
2925
def make_demo_buffer(
3026
pair_infos: List[AgentInfoActionPairProto],

ml-agents/mlagents/trainers/ghost/trainer.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# # Unity ML-Agents Toolkit
22
# ## ML-Agent Learning (Ghost Trainer)
33

4-
# import logging
54
from typing import Deque, Dict, List, Any, cast
65

76
import numpy as np
@@ -15,7 +14,7 @@
1514
from mlagents.trainers.trajectory import Trajectory
1615
from mlagents.trainers.agent_processor import AgentManagerQueue
1716

18-
LOGGER = logging.getLogger("mlagents.trainers")
17+
logger = logging.getLogger("mlagents.trainers")
1918

2019

2120
class GhostTrainer(Trainer):
@@ -93,7 +92,7 @@ def _write_summary(self, step: int) -> None:
9392
Saves training statistics to Tensorboard.
9493
"""
9594
opponents = np.array(self.policy_elos, dtype=np.float32)
96-
LOGGER.info(
95+
logger.info(
9796
" Learning brain {} ELO: {:0.3f}\n"
9897
"Mean Opponent ELO: {:0.3f}"
9998
" Std Opponent ELO: {:0.3f}".format(
@@ -234,7 +233,7 @@ def _swap_snapshots(self) -> None:
234233
x = "current"
235234
self.policy_elos[-1] = self.current_elo
236235
self.current_opponent = -1 if x == "current" else x
237-
LOGGER.debug(
236+
logger.debug(
238237
"Step {}: Swapping snapshot {} to id {} with {} learning".format(
239238
self.get_step, x, name_behavior_id, self.learning_behavior_name
240239
)

0 commit comments

Comments
 (0)