-
Notifications
You must be signed in to change notification settings - Fork 90
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
Replace print statements with logger #566
Conversation
I didn't update the notebooks which also contain |
Good question! I think the notebooks should probably stay the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks wonderful, thank you for taking this on! 🤩
A couple nitpicks :) What do you think?
Oo, also, what do you think of enabling ruff ruleset T20 to prevent us from re-introducing print statements? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @botanical! Glad to see your PR! Just a couple of tweaks, please, but otherwise, great start to your getting involved here!
earthaccess/search.py
Outdated
logger.info("Class components: \n") | ||
logger.info([method for method in dir(self) if method.startswith("_") is False]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should actually remain print
calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3fadd28 fixed!
Good call. We would just want to disable this check for the lines in |
@botanical, if you can add this to the PR, that would be great. Note that at a minimum you'll have to pull in the latest changes from |
try: | ||
print(f"Testing S3 credentials for {daac['short-name']}") | ||
logger.info(f"Testing S3 credentials for {daac['short-name']}") | ||
credentials = earthaccess.get_s3_credentials(daac["short-name"]) | ||
assertions.assertIsInstance(credentials, dict) | ||
assertions.assertTrue("accessKeyId" in credentials) | ||
except Exception as e: | ||
print( | ||
logger.error( | ||
f"An error occured while trying to fetch S3 credentials for {daac['short-name']}: {e}" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be logging messages from test functions. In fact, I suspect the try
/except
should be removed. If an exception occurs during the test, the test should fail. However, I don't know if this is an exception to that rule (no pun intended).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
botanical@64ec135 it seems intentional to me according to this commit 😯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, I suspect the try/except should be removed.
it seems intentional to me according to this commit 😯
It does still seem weird. But let's be intentional about the scope of this PR :) Can we take this to an issue / discussion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, I suspect the try/except should be removed.
it seems intentional to me according to this commit 😯
It does still seem weird. But let's be intentional about the scope of this PR :) Can we take this to an issue / discussion?
Sounds good to me. @botanical, would you mind opening a separate issue for this? Also, would you open yet another issue about refactoring loops in tests to instead be parametrized tests (pytest.parametrize
, and yes, that is how it's spelled, which is apparently a valid variant of parameterize).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, that is how it's spelled, which is apparently a valid variant of parameterize
Gets me every time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@botanical, sorry, I made a number of individual comments rather than unified review comments.
Co-authored-by: Matt Fisher <[email protected]>
Co-authored-by: Matt Fisher <[email protected]>
Co-authored-by: Matt Fisher <[email protected]>
Co-authored-by: Chuck Daniels <[email protected]>
Co-authored-by: Chuck Daniels <[email protected]>
Co-authored-by: Chuck Daniels <[email protected]>
Co-authored-by: Chuck Daniels <[email protected]>
Co-authored-by: Chuck Daniels <[email protected]>
Co-authored-by: Chuck Daniels <[email protected]>
pyproject.toml
Outdated
@@ -127,6 +127,9 @@ src = ["earthaccess", "stubs", "tests"] | |||
[tool.ruff.lint] | |||
extend-select = ["I", "T20"] | |||
|
|||
[tool.ruff.lint.per-file-ignores] | |||
"earthaccess/search.py" = ["T20"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know if this is necessarily what we want but I didn't know how to ignore that we have intentional print statements
earthaccess/search.py:312:9: T201
earthaccess/search.py:313:9: T201
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On those lines, you can append a comment like # noqa: T201
:) https://docs.astral.sh/ruff/linter/#error-suppression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@botanical, thanks for the cleanup of the print
calls and adding the ruff
rule. All looks good, except that I see numerous changes that have already landed on main
, so it seems perhaps that your attempt to merge things from main
went awry somewhere. For example, .codespellignore
already exists on main
, but shows up in this PR as an addition (among several other existing changes on main
). Can you perhaps rebase your changes onto main
? Happy to jump on a call to help sort it out if wrangling the commits gets gnarly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @botanical 🤩
@chuckwondo (or anyone else) if you don't have any last thoughts I'll merge tomorrow!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
@mfisher87, I'd like for us to use "Squash and merge" as a matter of habit. That's what I've been doing for PRs, as it keep the commit history much cleaner, unless there's an objection to that approach. |
I think we can call this mergeable, and squash it is! Thanks again @botanical 🙇 I don't have strong feelings about merge strategy, but I do feel strongly let's take it over here #348 :) |
Addresses #511
📚 Documentation preview 📚: https://earthaccess--566.org.readthedocs.build/en/566/