Skip to content
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

[🐛 🔨 ] Fixing the GymWrapper Logging issue #5201

Merged
merged 1 commit into from
Mar 31, 2021

Conversation

vincentpierre
Copy link
Contributor

@vincentpierre vincentpierre commented Mar 30, 2021

Proposed change(s)

Fixing This bug

I made sure mlagents-learn was still printing the right things and made sure importing UnityToGymWrapper did not cause issues :

This code :

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}")

Now prints to console only once per logger.info calls.

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

@vincentpierre vincentpierre self-assigned this Mar 30, 2021
@vincentpierre vincentpierre merged commit 8457c5b into main Mar 31, 2021
@delete-merged-branch delete-merged-branch bot deleted the fix-logging-handler branch March 31, 2021 02:50
ervteng pushed a commit that referenced this pull request Apr 8, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants