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

Prints to loggers #684

Merged
merged 23 commits into from Mar 14, 2014
Merged

Prints to loggers #684

merged 23 commits into from Mar 14, 2014

Conversation

Menerve
Copy link
Contributor

@Menerve Menerve commented Mar 10, 2014

I replaced prints statements by logging in some parts of Pylearn2 (work in progress) to resolve the issue #41

I tried to keep the form of what the author wanted to print but I also keep the technic used to print the string (some use str('string') and concatenation, others the modulo operator). The modulo operator can be a problem when I can't know the type of the value at first glance, so it might be interesting to avoid it.

There isn't a lot of logger.debug and I put it where it seems obvious, but maybe, at some place, logger.debug is better than logger.info. Let me know.

@memimo
Copy link
Member

memimo commented Mar 11, 2014

Overall looks good. But the tests are failing because of PEP8 formatting errors. Perhaps it would be too much work to enforce PEP8 style on all the files you're touching. But I beleive right now only the file length limit is enforced. So you should be good only by breaking the lines longer than 79 characters.
You can detect those using autopep8

@memimo
Copy link
Member

memimo commented Mar 11, 2014

One more comment. No need to add logger to test files, please ignore them.

@Menerve
Copy link
Contributor Author

Menerve commented Mar 12, 2014

So, do you want me to undo what I've done in these files or just ignore the next test files?

@memimo
Copy link
Member

memimo commented Mar 12, 2014

Just ignore the next test files.

@Menerve
Copy link
Contributor Author

Menerve commented Mar 12, 2014

Ok! One more question: Ian used stuff like self.verbose and debug in his files, since we can control these levels with logging, should I remove them?

@memimo
Copy link
Member

memimo commented Mar 12, 2014

Yeah, it make sense to remove them. Just in case, @goodfeli do you agree?

@Menerve
Copy link
Contributor Author

Menerve commented Mar 13, 2014

Just a message to say that I went through all the files.

"the try/catch so you can see whatever error it prints on "
"its own.")
logger.error("Couldn't open '%s' and exception has no string. " +
"Opening it again outside the try/catch " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe logger exception would be better here, since the code is not halting yet.

For example,
pkl_inspector.py foo.pkl .my_field [my_key] 3
will load an object obj from foo.pkl and analyze obj.my_field["my_key"][3]
"""
""")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't all these be Indented?

@Menerve
Copy link
Contributor Author

Menerve commented Mar 13, 2014

About the indentation of multiline strings: I wanted to keep the formatting and there weren't indented originally. If we indent them, the text will be indented in terminal too.
I can use textwrap.dedent to indent correctly the strings in source files and to avoid indenting when printing the string.

"may randomly fail later")
logger.error("the fact that somebody is using this doesn't bode well "
"since it's unlikely that the "
"covariance matrix is sparse")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here again, the code is not halting, so maybe exception or warning

@memimo
Copy link
Member

memimo commented Mar 13, 2014

About indention, I personally usually do something like:
"xxxx"
"xxxx"
But seems actually the current format is compatible with PEP8 https://pypi.python.org/pypi/autopep8/
So, it's fine in current format. My mistake.
Except few other comments, everything looks good, thanks a lot. I'll try to skim through it one more time, then it should be ready for merge.

@Menerve
Copy link
Contributor Author

Menerve commented Mar 13, 2014

I corrected what you mentioned (the training error confused me!).
I didn't use the critical level at all but it could be use in some situation (before a quit call maybe?).

@memimo
Copy link
Member

memimo commented Mar 13, 2014

I mistakenly deleted my last commit.
It's rather subjective, but in my opinion critical should be for cases when we know there is a bug or results are invalid and wants to notify the user regardless of the log report level. So it should be fine for quit to have log.error
LGTM, will merge after passes the test.

memimo added a commit that referenced this pull request Mar 14, 2014
@memimo memimo merged commit 4419ac5 into lisa-lab:master Mar 14, 2014
memimo added a commit to memimo/pylearn that referenced this pull request Mar 14, 2014
memimo added a commit that referenced this pull request Mar 14, 2014
Revert "Merge pull request #684 from Menerve/prints_to_loggers"
@Menerve Menerve deleted the prints_to_loggers branch March 28, 2014 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants