-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Closed
Labels
bugIssue describes a potential bug in ml-agents.Issue describes a potential bug in ml-agents.staleIssues that have been idle for a while. Automatically closed by a bot if idle for too long.Issues that have been idle for a while. Automatically closed by a bot if idle for too long.
Description
I am using Python 3.7.4
and gym_unity==0.23.0
In gym_unity/envs/__init__.py
, the logging level is set globally:
https://github.com/Unity-Technologies/ml-agents/blob/master/gym-unity/gym_unity/envs/__init__.py#L22
This causes the logging settings to be overwritten for loggers defined by the users simply by importing the UnityToGymWrapper
and leads to double printing (in red) in the console. Here is a minimal example to reproduce the issue:
import logging
import sys
from gym_unity.envs import UnityToGymWrapper
def create_logger(name, loglevel):
logger = logging.getLogger(name)
logger.setLevel(loglevel)
handler = logging.StreamHandler(stream=sys.stdout)
formatter = logging.Formatter(fmt=f'%(asctime)s - {name} - %(message)s', datefmt='%d/%m/%Y %H:%M:%S')
handler.setFormatter(formatter)
logger.addHandler(handler)
return logger
if __name__ == "__main__":
logger = create_logger(name="USER LOGGER", loglevel=logging.INFO)
for i in range(10):
logger.info(f"i={i}")
Which outputs:
(commenting out from gym_unity.envs import UnityToGymWrapper
resolves the issue)
Suggested fix:
By simply setting the logging level for the logger instance only seem to solve the issue (Line 22 of gym_unity/envs/__init__.py
):
logger.setLevel(logging.INFO)
Metadata
Metadata
Assignees
Labels
bugIssue describes a potential bug in ml-agents.Issue describes a potential bug in ml-agents.staleIssues that have been idle for a while. Automatically closed by a bot if idle for too long.Issues that have been idle for a while. Automatically closed by a bot if idle for too long.