Skip to content

Commit 6cc68c7

Browse files
authored
bits (#1828)
- make existence of entrypoints optional (for pyscript) - rename to asyncwrapper for use with URL chaining - add "pyscript:" known implementation
1 parent 8600919 commit 6cc68c7

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

docs/source/api.rst

+2
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ documentation carefully before using any particular package.
237237
- `p9fs`_ for 9P (Plan 9 Filesystem Protocol) servers
238238
- `PyAthena`_ for S3 access to Amazon Athena, with protocol "s3://" or "s3a://"
239239
- `PyDrive2`_ for Google Drive access
240+
- `fsspec-proxy`_ for "pyscript:" URLs via a proxy server
240241
- `s3fs`_ for Amazon S3 and other compatible stores, with protocol "s3://"
241242
- `sshfs`_ for access to SSH servers, with protocol "ssh://" or "sftp://"
242243
- `swiftspec`_ for OpenStack SWIFT, with protocol "swift://"
@@ -254,6 +255,7 @@ documentation carefully before using any particular package.
254255
.. _dropbox: https://github.com/fsspec/dropboxdrivefs
255256
.. _dvc: https://github.com/iterative/dvc
256257
.. _fsspec-encrypted: https://github.com/thevgergroup/fsspec-encrypted
258+
.. _fsspec-proxy: https://github.com/fsspec/fsspec-proxy
257259
.. _gcsfs: https://gcsfs.readthedocs.io/en/latest/
258260
.. _gdrive: https://github.com/fsspec/gdrivefs
259261
.. _git: https://github.com/iterative/scmrepo

fsspec/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from importlib.metadata import entry_points
2-
31
from . import caching
42
from ._version import __version__ # noqa: F401
53
from .callbacks import Callback
@@ -38,6 +36,10 @@
3836

3937

4038
def process_entries():
39+
try:
40+
from importlib.metadata import entry_points
41+
except ImportError:
42+
return
4143
if entry_points is not None:
4244
try:
4345
eps = entry_points()

fsspec/implementations/asyn_wrapper.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import functools
33
import inspect
44

5+
import fsspec
56
from fsspec.asyn import AsyncFileSystem, running_async
67

78

@@ -42,14 +43,24 @@ class AsyncFileSystemWrapper(AsyncFileSystem):
4243
The synchronous filesystem instance to wrap.
4344
"""
4445

45-
protocol = "async_wrapper"
46+
protocol = "asyncwrapper", "async_wrapper"
4647
cachable = False
4748

48-
def __init__(self, fs, *args, asynchronous=None, **kwargs):
49+
def __init__(
50+
self,
51+
fs=None,
52+
asynchronous=None,
53+
target_protocol=None,
54+
target_options=None,
55+
**kwargs,
56+
):
4957
if asynchronous is None:
5058
asynchronous = running_async()
51-
super().__init__(*args, asynchronous=asynchronous, **kwargs)
52-
self.sync_fs = fs
59+
super().__init__(asynchronous=asynchronous, **kwargs)
60+
if fs is not None:
61+
self.sync_fs = fs
62+
else:
63+
self.sync_fs = fsspec.filesystem(target_protocol, **target_options)
5364
self.protocol = self.sync_fs.protocol
5465
self._wrap_all_sync_methods()
5566

fsspec/registry.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ def register_implementation(name, cls, clobber=False, errtxt=None):
7272
"class": "fsspec.implementations.arrow.HadoopFileSystem",
7373
"err": "pyarrow and local java libraries required for HDFS",
7474
},
75-
"async_wrapper": {
76-
"class": "fsspec.asyn_wrapper.AsyncWrapperFileSystem",
77-
},
7875
"asynclocal": {
7976
"class": "morefs.asyn_local.AsyncLocalFileSystem",
8077
"err": "Install 'morefs[asynclocalfs]' to use AsyncLocalFileSystem",
8178
},
79+
"asyncwrapper": {
80+
"class": "fsspec.implementations.asyn_wrapper.AsyncFileSystemWrapper",
81+
},
8282
"az": {
8383
"class": "adlfs.AzureBlobFileSystem",
8484
"err": "Install adlfs to access Azure Datalake Gen2 and Azure Blob Storage",
@@ -180,6 +180,10 @@ def register_implementation(name, cls, clobber=False, errtxt=None):
180180
"class": "ossfs.OSSFileSystem",
181181
"err": "Install ossfs to access Alibaba Object Storage System",
182182
},
183+
"pyscript": {
184+
"class": "pyscript_fsspec_client.client.PyscriptFileSystem",
185+
"err": "Install requests (cpython) or run in pyscript",
186+
},
183187
"reference": {"class": "fsspec.implementations.reference.ReferenceFileSystem"},
184188
"root": {
185189
"class": "fsspec_xrootd.XRootDFileSystem",

0 commit comments

Comments
 (0)