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

Make loggers accessible from a create GridWorld #268

Closed
jwaa opened this issue Feb 10, 2021 · 3 comments
Closed

Make loggers accessible from a create GridWorld #268

jwaa opened this issue Feb 10, 2021 · 3 comments
Assignees
Labels
core Work related to the core functionality feature Work for a new feature

Comments

@jwaa
Copy link
Member

jwaa commented Feb 10, 2021

Is your feature request related to a problem? Please describe.
When you created and ran a world with loggers, you often want to do some post-processing. For this it is handy that you can access the loggers that world used. However, this is not possible. Because 1) you pass a class of a logger to the grid world which instantiates a new one for every created world, and 2) because GridWorld does contain the logger instances but as a private object requiring the ugly work around of doing GridWorld._GridWorld__loggers

Describe the solution you would like
I want GridWorld.__loggers to be a Python property that makes it accessible to the public but without a setter so they cannot be altered.

Describe alternatives you have considered
The ugly workaround of acessing a private attribute using GridWorld._GridWorld__loggers

Additional context
Originally identified by @Wouter1 while working on the TuD version of BW4T (see question #267)

@jwaa jwaa added core Work related to the core functionality request A request for a new feature labels Feb 10, 2021
@Wouter1
Copy link

Wouter1 commented Feb 10, 2021

@jwaa Thanks for picking this up!
I'd like to add a few things

  1. I in particular need the log filename that was created, so that I can read the log file contents. Even if I have the logger (I can get it with gridworld.loggers[0]) I still can not get to the filename
  2. You can not access private instance variables. Yes internally they seem to get the name _GridWorld__file_name etc, but python does not allow accessing them from outside. Or maybe I need another trick for this to get around this

@Wouter1
Copy link

Wouter1 commented Feb 10, 2021

And one more thing, maybe relevant. I'm processing after every builder.run so it's not a real problem that the builder creates the loggers. As long as I can get the log file(s) that are made I think I can manage.

@jwaa
Copy link
Member Author

jwaa commented Feb 10, 2021

The builder creates the loggers yes, but does not store them. This is done by the GridWorld in GridWorld.__loggers. Hence the request to make them accessible as GridWorld.loggers so you don't have the hassle of the double underscore.

Regarding your two bullets; see my suggestion in #267 to make the file name a publicly acessible property. If you are opting to do that by default; good idea that would be a different feature request :)

@jwaa jwaa added this to the Release v2.1.0 milestone May 1, 2021
@jwaa jwaa self-assigned this May 14, 2021
@jwaa jwaa added feature Work for a new feature and removed request A request for a new feature labels May 14, 2021
@jwaa jwaa closed this as completed May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Work related to the core functionality feature Work for a new feature
Projects
None yet
Development

No branches or pull requests

2 participants