-
Notifications
You must be signed in to change notification settings - Fork 96
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
Allow user to control behavior when login fails; warn by default #946
base: main
Are you sure you want to change the base?
Conversation
Better distinguish between a failed login attempt and a skipped strategy
I will automatically update this comment whenever this PR is modified
|
) | ||
except Exception: | ||
pass |
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 don't want to skip without regard for what type of error occurs; instead I'm using the exception type to communicate from the inner call whether we skip or not. There's a difference between "strategy unavailable", "something unexpected happened with strategy", and "login failed", and we want the user and programmer to be able to tell!
Any ideas why 3.13 integration tests are failing? I'm confused :) |
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 for picking up this issue.
Given that not raising an error is what creates confusion and issue/discussion posts, I suggest we make "error" the default instead.
I suspect this will not only eliminate the bulk (if not all) of the confusion around the current behavior, but will be more in line with what is common behavior in other libraries that preemptively attempt to auth.
I would also suggest simply using a boolean (perhaps, raise_on_failure: bool = True
). I think it would be a real stretch for there to be more than 2 ways to handle a failed login (i.e., either raise or don't).
I realize that making raising an error the default behavior qualifies as a breaking change, but in this case, I believe it would be the more familiar and less problematic default.
In other words, if we add this functionality with "warn" as the default, we're not breaking anything, but I would argue that we're perhaps not likely to reduce the number of questions about why things aren't working when login appears to have succeeded.
Further, either way, some folks are likely to need/want to change code. If we make "warn" the default, folks who want to end their confusion/frustration must change their code to set the option to "error" (and also continue to do so in future code). If we make "error" the default, the same users don't have to change code. Rather, they simply upgrade earthaccess.
Perhaps this is worthy of opening a discussion (unless I missed it).
I see this, but don't know why this would not be the case for the other runs:
However, there may be another problem (likely unrelated) with the int. tests. As far as I can tell, all of the int. tests are running Python 3.11, not their specific version, and I suspect that's because the "Install uv" step ends up using the same cache across all versioned runs of the int. tests. We likely need to use a cache suffix that at a minimum includes the matrix python version so that each version has its own cache. See https://github.com/astral-sh/setup-uv?tab=readme-ov-file#enable-caching |
Agreed with everything in your first post. Thank you for sharing your reasoning! |
For some reason the final change in this changeset was causing my editor to fail to parse markdown after that point, so I adjusted the line length and that fixed it.
#947 for your second comment @chuckwondo |
Co-authored-by: Chuck Daniels <chuck@developmentseed.org>
Co-authored-by: Chuck Daniels <chuck@developmentseed.org>
Co-authored-by: Chuck Daniels <chuck@developmentseed.org>
Co-authored-by: Chuck Daniels <chuck@developmentseed.org>
Co-authored-by: Chuck Daniels <chuck@developmentseed.org>
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Co-authored-by: Chuck Daniels <cjdaniels4@gmail.com>
315424c
to
5539a25
Compare
Co-authored-by: Joseph H Kennedy <me@jhkennedy.org>
Co-authored-by: Joseph H Kennedy <me@jhkennedy.org>
Co-authored-by: Joseph H Kennedy <me@jhkennedy.org>
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
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 good to me! @chuckwondo did you want to weigh in again?
@chuckwondo if you're good, go ahead and merge. Otherwise I'll merge it tomorrow before releasing! |
Looks good, but of course I have to throw another (minor) wrench into the works :-) I don't feel terribly strongly about the following, so I can likely be convinced to forget about it, but given that we are now raising an error by default, I'd actually suggest we not add the My reasoning is that the language already provides a familiar way to handle this: try/except. I'm taking a wild guess here, but I suspect nobody (or perhaps a nearly-zero percentage of users) check the result of the call to login to see if the Auth instance returned is authenticated (currently the only way to tell if login failed). For example, I suspect (nearly) nobody is doing this, but please correct me if you've seen otherwise: import earthaccess
auth = earthaccess.login()
if not auth.authenticated:
raise SomeException()
# do stuff requiring successful login
# ... Instead, I suspect this is the common coding pattern, given the number of people who report having the problem that a failed login does "nothing": import earthaccess
earthaccess.login()
# do stuff requiring successful login
# ... If the former pattern were common, (almost) nobody would be "complaining" about this issue. If my suspicion is current, then (almost) nobody would then bother to make the following code change, once this PR (as it stands) were to land: import earthaccess
earthaccess.login(raise_on_error=False)
# do stuff requiring successful login
# ... Conversely, if somebody does indeed use the latter approach (i.e., check the value of Bottom line: I don't believe there's a solid reason for us to bother adding a |
That's an excellent point. We don't need to clutter our API for this. Thanks for the 🧠 time Chuck ❤️ |
This is very rough and rushed, would love feedback!
Also, better distinguish in the code between a failed login attempt and an unavailable strategy.
Resolves #888
Pull Request (PR) draft checklist - click to expand
contributing documentation
before getting started.
title such as "Add testing details to the contributor section of the README".
Example PRs: #763
example
closes #1
. SeeGitHub docs - Linking a pull request to an issue.
CHANGELOG.md
with details about your change in a section titled## Unreleased
. If such a section does not exist, please create one. FollowCommon Changelog for your additions.
Example PRs: #763
README.md
with details of changes to theearthaccess interface, if any. Consider new environment variables, function names,
decorators, etc.
Click the "Ready for review" button at the bottom of the "Conversation" tab in GitHub
once these requirements are fulfilled. Don't worry if you see any test failures in
GitHub at this point!
Pull Request (PR) merge checklist - click to expand
Please do your best to complete these requirements! If you need help with any of these
requirements, you can ping the
@nsidc/earthaccess-support
team in a comment and wewill help you out!
Request containing "pre-commit.ci autofix" to automate this.
📚 Documentation preview 📚: https://earthaccess--946.org.readthedocs.build/en/946/