-
Notifications
You must be signed in to change notification settings - Fork 60
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 fsspec for all non-local urls #1906
Conversation
68be063
to
0dc4de3
Compare
0dc4de3
to
4688ad6
Compare
On this sad day in history our hero was defeated by the great moto. The combination of moto mocking s3, boto to talk to the mocked s3 and fsspec being used for http tests makes the s3 tests a rather large wrench to throw into the unit tests. The issues are: - s3 tests must be setup before http tests so that the mock s3 configuration is setup before fsspec is imported. This complicates otherwise simple http tests. - moto boto and s3fs often result in conflicting dependencies (looking at you aiobotocore) which in the past created impossible environments and currently results in installing and uninstalling certain versions to find one that works. Since we already have "compatibility_tests" I figured we could make "integration_tests" which now include: - compability tests (same as before) - s3 tests (to run s3 tests in isolation for 1 environment) If we assume fsspec is doing what it says on the tin then testing http should be enough. I am in favor of doing some sort of s3 test since that's the main target fsspec backend (and not hadoop, arrow, etc). We're not testing the other backends so I'm ok with just having minimal s3 tests and relying on fsspec to test that it supports the backends it claims.
@@ -402,7 +403,8 @@ def close(self): | |||
""" | |||
if self._close: | |||
self._fd.close() | |||
self._fix_permissions() | |||
if hasattr(self, "_fix_permissions"): |
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 is a minor bugfix that I found when allowing fsspec to natively handle http urls. The _fix_permissions
method is only present in the RealFile subclass.
"asdf[lz4]", | ||
"asdf[http]", | ||
] | ||
lz4 = [ |
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.
Although not required for this PR since I was changing optional-dependencies
I figured I'd separate out the lz4 one so that downstream users (like roman_datamodels) could use asdf[lz4]
.
"psutil", | ||
"pytest>=8", | ||
"pytest-remotedata", | ||
] | ||
test = [ |
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 snuck this in because I often type pip install asdf[test]
then it complains that tests
was expected. I figured we could just make both work.
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 this too 😅
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.
LGTM, good isolation solution
Testing on the roman research nexus (which has some ASDF files on s3) with this PR and roman_datamodels (post spacetelescope/roman_datamodels#453) I was able to run: m = rdm.open("s3://...") successfully. |
Description
This PR uses fsspec for all non-local urls (including
http
). As fsspec is an optional dependency this PR:http
urls stating that in a future version fsspec will be required and then the existing http handling code is usedhttp
topyproject.toml
that installs fsspec with http support (and adds this dependency group toall
)The above change allows for native handling of
s3
urls (instead of requiring opening the url first ins3fs
) allowing the following to work:Adding a test for this behavior was complicated by:
boto
(the aws client), adding these as test dependencies for all runs seemed like it would make the test runs brittleThe s3 tests were added to
integration_tests/s3
to:Since the
compatibility_tests
are sort ofintegration_tests
I moved them into the same subdirectory (so they're now atintegration_tests/compatibility
.I'll call out a couple other changes inline.
Tasks
pre-commit
on your machinepytest
on your machineno-changelog-entry-needed
)changes/
:echo "changed something" > changes/<PR#>.<changetype>.rst
(see below for change types)docs/
pagenews fragment change types...
changes/<PR#>.feature.rst
: new featurechanges/<PR#>.bugfix.rst
: bug fixchanges/<PR#>.doc.rst
: documentation changechanges/<PR#>.removal.rst
: deprecation or removal of public APIchanges/<PR#>.general.rst
: infrastructure or miscellaneous change