-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
import os | ||
import stat | ||
import sys | ||
import time | ||
import urllib | ||
from typing import Dict, IO, Iterable, Optional, Union | ||
|
@@ -19,6 +20,38 @@ | |
|
||
|
||
class FSSpecMountSource(MountSource): | ||
""" | ||
Generic wrapper around fsspec-based filesystems. | ||
At least as "generic" as it gets given that many details are inconsistent between the implementations. | ||
Note also that many implementations are rather experimental, utterly slow, or unstable. | ||
""" | ||
# TODO implement some of the most rudimentarily implemented filesystems myself instead of via fsspec. | ||
# wc -l 'fsspec/implementations/'*.py | sort -n | ||
# 0 fsspec/implementations/__init__.py | ||
# 58 fsspec/implementations/data.py | ||
# 75 fsspec/implementations/cache_mapper.py | ||
# 124 fsspec/implementations/jupyter.py | ||
# 124 fsspec/implementations/tar.py -> SQLiteIndexedTar | ||
# 127 fsspec/implementations/git.py -> TODO | ||
# 152 fsspec/implementations/dask.py | ||
# 176 fsspec/implementations/zip.py -> ZipMountSource | ||
# 180 fsspec/implementations/sftp.py -> fsspec/sshfs | ||
# 213 fsspec/implementations/libarchive.py -> LibarchiveMountSource | ||
# 232 fsspec/implementations/cache_metadata.py | ||
# 239 fsspec/implementations/github.py | ||
# 303 fsspec/implementations/memory.py | ||
# 304 fsspec/implementations/arrow.py | ||
# 372 fsspec/implementations/dirfs.py -> FolderMountSource + chdir | ||
# 395 fsspec/implementations/ftp.py | ||
# 416 fsspec/implementations/smb.py | ||
# 467 fsspec/implementations/dbfs.py | ||
# 471 fsspec/implementations/local.py -> FolderMountSource | ||
# 484 fsspec/implementations/webhdfs.py | ||
# 872 fsspec/implementations/http.py | ||
# 929 fsspec/implementations/cached.py | ||
# 1173 fsspec/implementations/reference.py | ||
# I guess git is the most obvious candidate because it is the most interesting and most barebone implementation. | ||
|
||
def __init__(self, urlOrOpenFile, **options) -> None: | ||
""" | ||
urlOrOpenFile : Take a URL or an already opened fsspec Filesystem object. | ||
|
@@ -179,7 +212,6 @@ def _getFileInfoHTTP(self, path: str) -> Optional[FileInfo]: | |
|
||
@overrides(MountSource) | ||
def getFileInfo(self, path: str, fileVersion: int = 0) -> Optional[FileInfo]: | ||
print("[getFileInfo]", path, "->", self._getPath(path), "exists:", self.exists(path)) | ||
if self._isHTTP: | ||
return self._getFileInfoHTTP(path) | ||
|
||
|
@@ -204,6 +236,11 @@ def getFileInfo(self, path: str, fileVersion: int = 0) -> Optional[FileInfo]: | |
# asyncssh.sftp.SFTPNoSuchFile: No such file | ||
return self.rootFileInfo.clone() | ||
|
||
# ftp://$user:[email protected]:8021/ -> times out!? | ||
# ftp://$user:[email protected]:8021/tests -> works fine!? | ||
# -> Cannot reproduce this anymore. May have been pyftpdlib problem. | ||
if not self.fileSystem.lexists(path): | ||
return None | ||
return FSSpecMountSource._convertToFileInfo(self.fileSystem.info(path), path) | ||
|
||
@overrides(MountSource) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters