fsspec 2024.5.0__py3-none-any.whl → 2024.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fsspec/_version.py +2 -2
- fsspec/caching.py +3 -2
- fsspec/compression.py +1 -1
- fsspec/implementations/cached.py +1 -13
- fsspec/implementations/github.py +12 -0
- fsspec/implementations/reference.py +6 -0
- fsspec/implementations/smb.py +10 -0
- fsspec/json.py +81 -0
- fsspec/registry.py +24 -18
- fsspec/spec.py +76 -34
- fsspec/utils.py +1 -1
- {fsspec-2024.5.0.dist-info → fsspec-2024.6.0.dist-info}/METADATA +11 -5
- fsspec-2024.6.0.dist-info/RECORD +55 -0
- fsspec/implementations/tests/__init__.py +0 -0
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_file_listing.yaml +0 -112
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_mkdir.yaml +0 -582
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_read_pyarrow_non_partitioned.yaml +0 -873
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_read_range.yaml +0 -458
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_read_range_chunked.yaml +0 -1355
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_write_and_read.yaml +0 -795
- fsspec/implementations/tests/cassettes/test_dbfs/test_dbfs_write_pyarrow_non_partitioned.yaml +0 -613
- fsspec/implementations/tests/conftest.py +0 -39
- fsspec/implementations/tests/local/__init__.py +0 -0
- fsspec/implementations/tests/local/local_fixtures.py +0 -18
- fsspec/implementations/tests/local/local_test.py +0 -14
- fsspec/implementations/tests/memory/__init__.py +0 -0
- fsspec/implementations/tests/memory/memory_fixtures.py +0 -27
- fsspec/implementations/tests/memory/memory_test.py +0 -14
- fsspec/implementations/tests/out.zip +0 -0
- fsspec/implementations/tests/test_archive.py +0 -382
- fsspec/implementations/tests/test_arrow.py +0 -259
- fsspec/implementations/tests/test_cached.py +0 -1306
- fsspec/implementations/tests/test_common.py +0 -35
- fsspec/implementations/tests/test_dask.py +0 -29
- fsspec/implementations/tests/test_data.py +0 -20
- fsspec/implementations/tests/test_dbfs.py +0 -268
- fsspec/implementations/tests/test_dirfs.py +0 -588
- fsspec/implementations/tests/test_ftp.py +0 -178
- fsspec/implementations/tests/test_git.py +0 -76
- fsspec/implementations/tests/test_http.py +0 -577
- fsspec/implementations/tests/test_jupyter.py +0 -57
- fsspec/implementations/tests/test_libarchive.py +0 -33
- fsspec/implementations/tests/test_local.py +0 -1285
- fsspec/implementations/tests/test_memory.py +0 -382
- fsspec/implementations/tests/test_reference.py +0 -720
- fsspec/implementations/tests/test_sftp.py +0 -233
- fsspec/implementations/tests/test_smb.py +0 -139
- fsspec/implementations/tests/test_tar.py +0 -243
- fsspec/implementations/tests/test_webhdfs.py +0 -197
- fsspec/implementations/tests/test_zip.py +0 -134
- fsspec/tests/__init__.py +0 -0
- fsspec/tests/conftest.py +0 -188
- fsspec/tests/data/listing.html +0 -1
- fsspec/tests/test_api.py +0 -498
- fsspec/tests/test_async.py +0 -230
- fsspec/tests/test_caches.py +0 -255
- fsspec/tests/test_callbacks.py +0 -89
- fsspec/tests/test_compression.py +0 -164
- fsspec/tests/test_config.py +0 -129
- fsspec/tests/test_core.py +0 -466
- fsspec/tests/test_downstream.py +0 -40
- fsspec/tests/test_file.py +0 -200
- fsspec/tests/test_fuse.py +0 -147
- fsspec/tests/test_generic.py +0 -90
- fsspec/tests/test_gui.py +0 -23
- fsspec/tests/test_mapping.py +0 -228
- fsspec/tests/test_parquet.py +0 -140
- fsspec/tests/test_registry.py +0 -134
- fsspec/tests/test_spec.py +0 -1167
- fsspec/tests/test_utils.py +0 -478
- fsspec-2024.5.0.dist-info/RECORD +0 -111
- {fsspec-2024.5.0.dist-info → fsspec-2024.6.0.dist-info}/WHEEL +0 -0
- {fsspec-2024.5.0.dist-info → fsspec-2024.6.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import subprocess
|
|
3
|
-
import sys
|
|
4
|
-
import time
|
|
5
|
-
|
|
6
|
-
import pytest
|
|
7
|
-
|
|
8
|
-
import fsspec
|
|
9
|
-
from fsspec import open_files
|
|
10
|
-
from fsspec.implementations.ftp import FTPFileSystem
|
|
11
|
-
|
|
12
|
-
ftplib = pytest.importorskip("ftplib")
|
|
13
|
-
here = os.path.dirname(os.path.abspath(__file__))
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@pytest.fixture()
|
|
17
|
-
def ftp():
|
|
18
|
-
pytest.importorskip("pyftpdlib")
|
|
19
|
-
P = subprocess.Popen(
|
|
20
|
-
[sys.executable, "-m", "pyftpdlib", "-d", here],
|
|
21
|
-
stderr=subprocess.STDOUT,
|
|
22
|
-
stdout=subprocess.PIPE,
|
|
23
|
-
)
|
|
24
|
-
try:
|
|
25
|
-
time.sleep(1)
|
|
26
|
-
yield "localhost", 2121
|
|
27
|
-
finally:
|
|
28
|
-
P.terminate()
|
|
29
|
-
P.wait()
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def test_basic(ftp):
|
|
33
|
-
host, port = ftp
|
|
34
|
-
fs = FTPFileSystem(host, port)
|
|
35
|
-
assert fs.ls("/", detail=False) == sorted(os.listdir(here))
|
|
36
|
-
out = fs.cat(f"/{os.path.basename(__file__)}")
|
|
37
|
-
assert out == open(__file__, "rb").read()
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def test_not_cached(ftp):
|
|
41
|
-
host, port = ftp
|
|
42
|
-
fs = FTPFileSystem(host, port)
|
|
43
|
-
fs2 = FTPFileSystem(host, port)
|
|
44
|
-
assert fs is not fs2
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
@pytest.mark.parametrize("cache_type", ["bytes", "mmap"])
|
|
48
|
-
def test_complex(ftp_writable, cache_type):
|
|
49
|
-
from fsspec.core import BytesCache
|
|
50
|
-
|
|
51
|
-
host, port, user, pw = ftp_writable
|
|
52
|
-
files = open_files(
|
|
53
|
-
"ftp:///ou*",
|
|
54
|
-
host=host,
|
|
55
|
-
port=port,
|
|
56
|
-
username=user,
|
|
57
|
-
password=pw,
|
|
58
|
-
block_size=10000,
|
|
59
|
-
cache_type=cache_type,
|
|
60
|
-
)
|
|
61
|
-
assert len(files) == 1
|
|
62
|
-
with files[0] as fo:
|
|
63
|
-
assert fo.read(10) == b"hellohello"
|
|
64
|
-
if isinstance(fo.cache, BytesCache):
|
|
65
|
-
assert len(fo.cache.cache) == 10010
|
|
66
|
-
assert fo.read(2) == b"he"
|
|
67
|
-
assert fo.tell() == 12
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def test_write_small(ftp_writable):
|
|
71
|
-
host, port, user, pw = ftp_writable
|
|
72
|
-
fs = FTPFileSystem(host, port, user, pw)
|
|
73
|
-
with fs.open("/out2", "wb") as f:
|
|
74
|
-
f.write(b"oi")
|
|
75
|
-
assert fs.cat("/out2") == b"oi"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def test_with_url(ftp_writable):
|
|
79
|
-
host, port, user, pw = ftp_writable
|
|
80
|
-
fo = fsspec.open(f"ftp://{user}:{pw}@{host}:{port}/out", "wb")
|
|
81
|
-
with fo as f:
|
|
82
|
-
f.write(b"hello")
|
|
83
|
-
fo = fsspec.open(f"ftp://{user}:{pw}@{host}:{port}/out", "rb")
|
|
84
|
-
with fo as f:
|
|
85
|
-
assert f.read() == b"hello"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
@pytest.mark.parametrize("cache_type", ["bytes", "mmap"])
|
|
89
|
-
def test_write_big(ftp_writable, cache_type):
|
|
90
|
-
host, port, user, pw = ftp_writable
|
|
91
|
-
fs = FTPFileSystem(host, port, user, pw, block_size=1000, cache_type=cache_type)
|
|
92
|
-
fn = "/bigger"
|
|
93
|
-
with fs.open(fn, "wb") as f:
|
|
94
|
-
f.write(b"o" * 500)
|
|
95
|
-
assert not fs.exists(fn)
|
|
96
|
-
f.write(b"o" * 1000)
|
|
97
|
-
fs.invalidate_cache()
|
|
98
|
-
assert fs.exists(fn)
|
|
99
|
-
f.write(b"o" * 200)
|
|
100
|
-
f.flush()
|
|
101
|
-
|
|
102
|
-
assert fs.info(fn)["size"] == 1700
|
|
103
|
-
assert fs.cat(fn) == b"o" * 1700
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def test_transaction(ftp_writable):
|
|
107
|
-
host, port, user, pw = ftp_writable
|
|
108
|
-
fs = FTPFileSystem(host, port, user, pw)
|
|
109
|
-
fs.mkdir("/tmp")
|
|
110
|
-
fn = "/tr"
|
|
111
|
-
with fs.transaction:
|
|
112
|
-
with fs.open(fn, "wb") as f:
|
|
113
|
-
f.write(b"not")
|
|
114
|
-
assert not fs.exists(fn)
|
|
115
|
-
assert fs.exists(fn)
|
|
116
|
-
assert fs.cat(fn) == b"not"
|
|
117
|
-
|
|
118
|
-
fs.rm(fn)
|
|
119
|
-
assert not fs.exists(fn)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
def test_transaction_with_cache(ftp_writable, tmpdir):
|
|
123
|
-
host, port, user, pw = ftp_writable
|
|
124
|
-
fs = FTPFileSystem(host, port, user, pw)
|
|
125
|
-
fs.mkdir("/tmp")
|
|
126
|
-
fs.mkdir("/tmp/dir")
|
|
127
|
-
assert "dir" in fs.ls("/tmp", detail=False)
|
|
128
|
-
|
|
129
|
-
with fs.transaction:
|
|
130
|
-
fs.rmdir("/tmp/dir")
|
|
131
|
-
|
|
132
|
-
assert "dir" not in fs.ls("/tmp", detail=False)
|
|
133
|
-
assert not fs.exists("/tmp/dir")
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def test_cat_get(ftp_writable, tmpdir):
|
|
137
|
-
host, port, user, pw = ftp_writable
|
|
138
|
-
fs = FTPFileSystem(host, port, user, pw, block_size=500)
|
|
139
|
-
fs.mkdir("/tmp")
|
|
140
|
-
data = b"hello" * 500
|
|
141
|
-
fs.pipe("/tmp/myfile", data)
|
|
142
|
-
assert fs.cat_file("/tmp/myfile") == data
|
|
143
|
-
|
|
144
|
-
fn = os.path.join(tmpdir, "lfile")
|
|
145
|
-
fs.get_file("/tmp/myfile", fn)
|
|
146
|
-
assert open(fn, "rb").read() == data
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
def test_mkdir(ftp_writable):
|
|
150
|
-
host, port, user, pw = ftp_writable
|
|
151
|
-
fs = FTPFileSystem(host, port, user, pw)
|
|
152
|
-
with pytest.raises(ftplib.error_perm):
|
|
153
|
-
fs.mkdir("/tmp/not/exist", create_parents=False)
|
|
154
|
-
fs.mkdir("/tmp/not/exist")
|
|
155
|
-
assert fs.exists("/tmp/not/exist")
|
|
156
|
-
fs.makedirs("/tmp/not/exist", exist_ok=True)
|
|
157
|
-
with pytest.raises(FileExistsError):
|
|
158
|
-
fs.makedirs("/tmp/not/exist", exist_ok=False)
|
|
159
|
-
fs.makedirs("/tmp/not/exist/inner/inner")
|
|
160
|
-
assert fs.isdir("/tmp/not/exist/inner/inner")
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def test_rm_get_recursive(ftp_writable, tmpdir):
|
|
164
|
-
tmpdir = str(tmpdir)
|
|
165
|
-
host, port, user, pw = ftp_writable
|
|
166
|
-
fs = FTPFileSystem(host, port, user, pw)
|
|
167
|
-
fs.mkdir("/tmp/topdir")
|
|
168
|
-
fs.mkdir("/tmp/topdir/underdir")
|
|
169
|
-
fs.touch("/tmp/topdir/afile")
|
|
170
|
-
fs.touch("/tmp/topdir/underdir/afile")
|
|
171
|
-
|
|
172
|
-
fs.get("/tmp/topdir", tmpdir, recursive=True)
|
|
173
|
-
|
|
174
|
-
with pytest.raises(ftplib.error_perm):
|
|
175
|
-
fs.rmdir("/tmp/topdir")
|
|
176
|
-
|
|
177
|
-
fs.rm("/tmp/topdir", recursive=True)
|
|
178
|
-
assert not fs.exists("/tmp/topdir")
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import shutil
|
|
3
|
-
import subprocess
|
|
4
|
-
import tempfile
|
|
5
|
-
|
|
6
|
-
import pytest
|
|
7
|
-
|
|
8
|
-
import fsspec
|
|
9
|
-
from fsspec.implementations.local import make_path_posix
|
|
10
|
-
|
|
11
|
-
pygit2 = pytest.importorskip("pygit2")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@pytest.fixture()
|
|
15
|
-
def repo():
|
|
16
|
-
orig_dir = os.getcwd()
|
|
17
|
-
d = tempfile.mkdtemp()
|
|
18
|
-
try:
|
|
19
|
-
os.chdir(d)
|
|
20
|
-
subprocess.call("git init -b master", shell=True, cwd=d)
|
|
21
|
-
subprocess.call("git init -b master", shell=True, cwd=d)
|
|
22
|
-
subprocess.call('git config user.email "you@example.com"', shell=True, cwd=d)
|
|
23
|
-
subprocess.call('git config user.name "Your Name"', shell=True, cwd=d)
|
|
24
|
-
open(os.path.join(d, "file1"), "wb").write(b"data0")
|
|
25
|
-
subprocess.call("git add file1", shell=True, cwd=d)
|
|
26
|
-
subprocess.call('git commit -m "init"', shell=True, cwd=d)
|
|
27
|
-
sha = open(os.path.join(d, ".git/refs/heads/master"), "r").read().strip()
|
|
28
|
-
open(os.path.join(d, "file1"), "wb").write(b"data00")
|
|
29
|
-
subprocess.check_output('git commit -a -m "tagger"', shell=True, cwd=d)
|
|
30
|
-
subprocess.call('git tag -a thetag -m "make tag"', shell=True, cwd=d)
|
|
31
|
-
open(os.path.join(d, "file2"), "wb").write(b"data000")
|
|
32
|
-
subprocess.call("git add file2", shell=True)
|
|
33
|
-
subprocess.call('git commit -m "master tip"', shell=True, cwd=d)
|
|
34
|
-
subprocess.call("git checkout -b abranch", shell=True, cwd=d)
|
|
35
|
-
os.mkdir("inner")
|
|
36
|
-
open(os.path.join(d, "inner", "file1"), "wb").write(b"data3")
|
|
37
|
-
subprocess.call("git add inner/file1", shell=True, cwd=d)
|
|
38
|
-
subprocess.call('git commit -m "branch tip"', shell=True, cwd=d)
|
|
39
|
-
os.chdir(orig_dir)
|
|
40
|
-
yield d, sha
|
|
41
|
-
finally:
|
|
42
|
-
os.chdir(orig_dir)
|
|
43
|
-
shutil.rmtree(d)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def test_refs(repo):
|
|
47
|
-
d, sha = repo
|
|
48
|
-
with fsspec.open("git://file1", path=d, ref=sha) as f:
|
|
49
|
-
assert f.read() == b"data0"
|
|
50
|
-
|
|
51
|
-
with fsspec.open("git://file1", path=d, ref="thetag") as f:
|
|
52
|
-
assert f.read() == b"data00"
|
|
53
|
-
|
|
54
|
-
with fsspec.open("git://file2", path=d, ref="master") as f:
|
|
55
|
-
assert f.read() == b"data000"
|
|
56
|
-
|
|
57
|
-
with fsspec.open("git://file2", path=d, ref=None) as f:
|
|
58
|
-
assert f.read() == b"data000"
|
|
59
|
-
|
|
60
|
-
with fsspec.open("git://inner/file1", path=d, ref="abranch") as f:
|
|
61
|
-
assert f.read() == b"data3"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def test_url(repo):
|
|
65
|
-
d, sha = repo
|
|
66
|
-
fs, _, paths = fsspec.core.get_fs_token_paths(f"git://file1::file://{d}")
|
|
67
|
-
assert make_path_posix(d) in make_path_posix(fs.repo.path)
|
|
68
|
-
assert paths == ["file1"]
|
|
69
|
-
with fsspec.open(f"git://file1::file://{d}") as f:
|
|
70
|
-
assert f.read() == b"data00"
|
|
71
|
-
|
|
72
|
-
fs, _, paths = fsspec.core.get_fs_token_paths(f"git://{d}:master@file1")
|
|
73
|
-
assert make_path_posix(d) in make_path_posix(fs.repo.path)
|
|
74
|
-
assert paths == ["file1"]
|
|
75
|
-
with fsspec.open(f"git://{d}:master@file1") as f:
|
|
76
|
-
assert f.read() == b"data00"
|