-
Notifications
You must be signed in to change notification settings - Fork 3
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
get log file after session run #267
Comments
BTW I tried the _GridWorldLogger__file_name but it does not even work. |
@Wouter1 I will take a look at it in a moment. Is this for a custom logger class or one of those of MATRX? |
@jwaa This is for running after main call completed. |
@jwaa I'm using my own logger class for this. But it looks irrelevant, I'm extending the GridWorldLogger and I leave all file handling to the GridWorldLogger. |
Access with This will not contain anything that gets you the file name. A solution is, making use of your custom class, is to make the file name accessible through a Python Property decorator: class YourLogger(GridWorldLogger):
...
@property
def file_name():
return self.__file_name This makes it publicly acessible but not changeable: That is the easy part, but we still need a workaround to get access to the logger instance from the So the workaround is: builder = create_builder()
world = builder.get_world()
world.run()
loggers = world._GridWorld__loggers
fn_first_logger = loggers[0].file_name This assumes that the previous code segment is present in all of your custom loggers and that the world only contains your custom loggers. If this is not the case, we need to figure out a different solution. |
@Wouter1; To clarify, the workaround I provided can be done right now. I cannot guarantee that issue #268 will be implemented quick enough for you. So it might be an idea to implement the workaround now instead of waiting for #268. I assume here that you refer to #268, since #288 does not exist (yet). |
@jwaa Thanks!
needs to be (again hacking around private variable protection)
|
Yes, this is needed if you did not added the code segment I added; since you have your custom logger class, you can easily make class YourLogger(GridWorldLogger):
...
@property
def file_name():
return self.__file_name |
@jwaa Ah yes, but that would make the code dependent on the specific YourLogger. I prefer the more generally working code. It would be best though if file_name function were added to GridWorldLogger itself. |
I absolutely agree on this, I however wanted to suggest a workaround that works and does not look 'hacky'. I didn't found the time back then to make a feature request for it and forgot about it then. I now made one; #270 |
What is your question?
How do I get the filename of the log file after a session run.
Because after the run I need to analyze the log file and extract statistics.
At this moment I try to use
builder.loggers[0]._GridWorldLogger__file_name
This is very bad because this should be an anonymous internal variable.
Also I need to hard code the knowledge that it's in world_1.
The text was updated successfully, but these errors were encountered: