-
Notifications
You must be signed in to change notification settings - Fork 84
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
Use temp .netrc file for integration tests and support NETRC environment variable #808
Conversation
2f1bd8a
to
98ba9bb
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #808 +/- ##
==========================================
- Coverage 73.88% 70.08% -3.80%
==========================================
Files 31 31
Lines 2003 2123 +120
==========================================
+ Hits 1480 1488 +8
- Misses 523 635 +112 ☔ View full report in Codecov by Sentry. |
98ba9bb
to
9fea543
Compare
# | ||
# ORNLDAAC no longer has any on-prem collections. This returns 0 collections: | ||
# https://cmr.earthdata.nasa.gov/search/collections?data_center=ORNL_DAAC&cloud_hosted=false | ||
# The following is commented out because the test in this file will now always fail | ||
# because there are no longer any on-prem collections. | ||
# | ||
# { | ||
# "short_name": "ORNLDAAC", | ||
# "collections_count": 100, | ||
# "collections_sample_size": 3, | ||
# "granules_count": 100, | ||
# "granules_sample_size": 2, | ||
# "granules_max_size_mb": 50, | ||
# }, |
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.
Do we want to remove this completely?
# | ||
# ORNLDAAC no longer has any on-prem collections. This returns 0 collections: | ||
# https://cmr.earthdata.nasa.gov/search/collections?data_center=ORNL_DAAC&cloud_hosted=false | ||
# The following is commented out because the test in this file will now always fail | ||
# because there are no longer any on-prem collections. | ||
# | ||
# { | ||
# "short_name": "ORNLDAAC", | ||
# "collections_count": 100, | ||
# "collections_sample_size": 2, | ||
# "granules_count": 100, | ||
# "granules_sample_size": 2, | ||
# "granules_max_size_mb": 50, | ||
# }, |
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.
Do we want to remove this completely?
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.
IMO, yeah. This is ringing a bell, and if I wrote this, I dislike past-me's decision to leave anything here 😆 We can put the details in a commit message.
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.
What details would you like in the commit message? Just something that indicates that ORNLDAAC no longer has any on-prem collections?
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.
Sorry, I meant to say that (if this comment were my doing, which I think it was but haven't git blame
d yet) I should have included the details in this comment in the commit message instead, and deleted the comment :)
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.
Gotcha. I commented out that code, specifically so anybody reviewing this PR would see it and could comment on it. It worked :-)
I'll update the PR by now removing the commented out code and putting the details into the commit message.
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.
Oh, my bad. I didn't even look at the full diff yet and did a drive-by on the "conversation" tab 😆 I ran in to the same problem in a past hackathon, which is why I think it looked so familiar :) Sorry for adding confusion! 😆
Apologies for the relatively large PR. I could perhaps split out the changes for #743, if anybody feels this is too large. I would at least like to keep the changes addressing both #480 and #806 together since the changes for #806 effectively necessitate the changes for #480. This also now fixes #815. It made sense for me to add the changes for that issue so that I could actually run integration tests locally since this issue is precisely for handling integration tests. Regardless, integration tests now run successfully on PRs from forks. For PRs from forks owned by those of use who are maintainers of this repo, the integration tests run successfully (barring actual failing tests, of course) without intervention, as we have write permission. For PRs from forks owned by anybody without write access to this repo, the integration tests job will now fail due to a permission check, not due to failure to read the necessary secrets, but now (once this PR is merged) it will be possible for a maintainer to check the PR, and if all looks safe, re-run the failed job. When this happens, the job re-runs with the maintainer's permissions, and thus the integration tests will run (and ideally succeed as well). |
6f645d3
to
d87a4bc
Compare
@mfisher87, @betolink, @jhkennedy, I've merged the recent changes from the main branch and resolved some conflicts and a broken integration test (previously hidden due to not being run previously). I've taken it out of draft, so please review when you have some time. |
I'm getting really busy in my last week at NSIDC, may not be able to make time until after 😬 I'll be at hack day though, maybe we can fit this in then! |
d87a4bc
to
9321919
Compare
I'll be at SatCamp during the Oct. 1 hack day, so I'll miss the hack day. Although I touched quite a few files, there's really not much to this PR, so I'm happy for us to continue through it async. There are no gnarly bits of code. |
Shoot, hope to catch you at the next one :)
👍 |
Looking through this PR, so far so good. @chuckwondo |
Thanks @betolink. Did you get a chance to finish reviewing? |
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.
Great PR!!! a lot of code simplification and quality improvements, I just left a few minor comments and some questions. My email is not a typo, I wanted the one with a K but someone had it already 😄. I really like what you did on the tests mocking the missing netrc etc. 🚀
@@ -78,8 +83,6 @@ jobs: | |||
env: | |||
EARTHDATA_USERNAME: ${{ secrets.EDL_USERNAME }} | |||
EARTHDATA_PASSWORD: ${{ secrets.EDL_PASSWORD }} | |||
EARTHACCESS_TEST_USERNAME: ${{ secrets.EDL_USERNAME }} |
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 don't remember why this was here, a meta test about environment variables being present I think.
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.
Yeah, I searched through the code and found where this appeared, and the logic did not appear to be doing anything in this regard, so I eliminated its code use as well. I suspect this was perhaps originally a way to configure 2 sets of creds locally, where 1 set was someone's "real" creds (the vars without TEST
in the names), and a second set for "test" creds, so that when running integration tests locally, you could avoid using your "real" creds. However, I don't see any real value in that.
docs/howto/authenticate.md
Outdated
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.
Amazing work on the docs!
@@ -46,7 +47,9 @@ | |||
"download", | |||
"auth_environ", | |||
# search.py | |||
"DataGranule", |
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.
Is this for testing purposes or we want users use these classes?
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.
Since we return a list of them to the user from the public function search_data
, the user should have access to the type.
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.
To clarify, the user could import from the search
module, but for consistency with the plural names being at the top level, along with the functions themselves, it makes sense to include this as well.
otherwise, the path of the platform-specific default location: | ||
`~/_netrc` on Windows systems, `~/.netrc` on non-Windows systems. | ||
""" | ||
sys_netrc_name = "_netrc" if platform.system() == "Windows" else ".netrc" |
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.
This distinction is a good catch! I've never used the library on Windows, I wonder if someone could share an example with us.
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.
Search for _netrc
in the requests
code shown here: https://requests.readthedocs.io/en/latest/_modules/requests/utils/#get_netrc_auth
if not urs_cookies_path.exists(): | ||
urs_cookies_path.write_text("") | ||
|
||
# Create and write to .dodsrc file | ||
dodsrc_path = Path.home() / ".dodsrc" | ||
|
||
if not dodsrc_path.exists(): |
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.
Is this for OPeNDAP? amazing!
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 suppose so, but this was existing code. I just added a bit of whitespace for readability.
) -> List[EarthAccessFile]: | ||
def multi_thread_open(data: tuple) -> EarthAccessFile: | ||
urls, granule = data |
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 think urls
is correct on this one, the relation is a granule can have many files/urls.
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.
The tuple is of type tuple[str, Optional[DataGranule]]
, so the str is a singular url. It comes from the mapping returned by _get_url_granule_mapping (as well as a couple of other places using Mapping[str, Optional[DataGranule]]
).
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 refined the type of the data
argument to reflect this.
pyproject.toml
Outdated
description = "Client library for NASA Earthdata APIs" | ||
authors = [ | ||
{name = "earthaccess contributors"} | ||
] | ||
maintainers = [ | ||
{name = "Luis Lopez", email = "betolin@gmail.com"}, |
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.
Not a typo
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.
Oops! I'll restore it.
@@ -29,3 +33,31 @@ def pytest_sessionfinish(session, exitstatus): | |||
failure_rate = (100.0 * session.testsfailed) / session.testscollected | |||
if failure_rate <= ACCEPTABLE_FAILURE_RATE: | |||
session.exitstatus = 99 | |||
|
|||
|
|||
@pytest.fixture |
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 see, yeah this is better.
if "podaac-tools.jpl.nasa.gov/drive" in url: | ||
return False | ||
return True | ||
return all("podaac-tools.jpl.nasa.gov/drive" not in url for url in data_links) |
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.
Down the road I think we should create a regex dictionary with servers we know work without custom auth loops etc, related to this when we use S3://granule-url
users have to tell this is PODAC, maybe the same approach will work to get the credentials from whatever DAAC or mission endpoint controls access for the URL.
ORNLDAAC no longer has any on-prem collections. This returns no collections: https://cmr.earthdata.nasa.gov/search/collections?data_center=ORNL_DAAC&cloud_hosted=false
- Use present tense (e.g., "add," not "added") - Order Remove section before Fixed section - Surround authors list with parentheses
This PR also fixes nsidc#815
9321919
to
1fe472c
Compare
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 reviewed the PR again, great refactoring and code improvements!
``` | ||
|
||
Nox handles everything for you, including setting up a temporary virtual | ||
environment for each run. | ||
|
||
**NOTE:** In order to run integration tests locally, you must set the |
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.
Great!
This primary intent for the PR was to address #806. Because the changes required for #806 also produced at least partial completion of #743 and #480, it also includes the full set of changes for them as well. All 3 issues are very closely related, so it didn't make much sense to attempt to separate them out.
As a result,
~/.netrc
file, if they have one.netrc
file location, it made sense to do so by setting aNETRC
environment variable for this purpose, so users may now also set this environment variable, if they need to specify a different location for their.netrc
fileFixes #806
Fixes #743
Fixes #480
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
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.
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--808.org.readthedocs.build/en/808/