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
fsspec/tests/test_compression.py
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import pathlib
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
|
|
5
|
-
import fsspec.core
|
|
6
|
-
from fsspec.compression import compr, register_compression
|
|
7
|
-
from fsspec.utils import compressions, infer_compression
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def test_infer_custom_compression():
|
|
11
|
-
"""Inferred compression gets values from fsspec.compression.compr."""
|
|
12
|
-
assert infer_compression("fn.zip") == "zip"
|
|
13
|
-
assert infer_compression("fn.gz") == "gzip"
|
|
14
|
-
assert infer_compression("fn.unknown") is None
|
|
15
|
-
assert infer_compression("fn.test_custom") is None
|
|
16
|
-
assert infer_compression("fn.tst") is None
|
|
17
|
-
|
|
18
|
-
register_compression("test_custom", lambda f, **kwargs: f, "tst")
|
|
19
|
-
|
|
20
|
-
try:
|
|
21
|
-
assert infer_compression("fn.zip") == "zip"
|
|
22
|
-
assert infer_compression("fn.gz") == "gzip"
|
|
23
|
-
assert infer_compression("fn.unknown") is None
|
|
24
|
-
assert infer_compression("fn.test_custom") is None
|
|
25
|
-
assert infer_compression("fn.tst") == "test_custom"
|
|
26
|
-
|
|
27
|
-
# Duplicate registration in name or extension raises a value error.
|
|
28
|
-
with pytest.raises(ValueError):
|
|
29
|
-
register_compression("test_custom", lambda f, **kwargs: f, "tst")
|
|
30
|
-
|
|
31
|
-
with pytest.raises(ValueError):
|
|
32
|
-
register_compression("test_conflicting", lambda f, **kwargs: f, "tst")
|
|
33
|
-
assert "test_conflicting" not in compr
|
|
34
|
-
|
|
35
|
-
# ...but can be forced.
|
|
36
|
-
register_compression(
|
|
37
|
-
"test_conflicting", lambda f, **kwargs: f, "tst", force=True
|
|
38
|
-
)
|
|
39
|
-
assert infer_compression("fn.zip") == "zip"
|
|
40
|
-
assert infer_compression("fn.gz") == "gzip"
|
|
41
|
-
assert infer_compression("fn.unknown") is None
|
|
42
|
-
assert infer_compression("fn.test_custom") is None
|
|
43
|
-
assert infer_compression("fn.tst") == "test_conflicting"
|
|
44
|
-
|
|
45
|
-
finally:
|
|
46
|
-
del compr["test_custom"]
|
|
47
|
-
del compr["test_conflicting"]
|
|
48
|
-
del compressions["tst"]
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def test_infer_uppercase_compression():
|
|
52
|
-
assert infer_compression("fn.ZIP") == "zip"
|
|
53
|
-
assert infer_compression("fn.GZ") == "gzip"
|
|
54
|
-
assert infer_compression("fn.UNKNOWN") is None
|
|
55
|
-
assert infer_compression("fn.TEST_UPPERCASE") is None
|
|
56
|
-
assert infer_compression("fn.TEST") is None
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def test_lzma_compression_name():
|
|
60
|
-
pytest.importorskip("lzma")
|
|
61
|
-
assert infer_compression("fn.xz") == "xz"
|
|
62
|
-
assert infer_compression("fn.lzma") == "lzma"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
def test_lz4_compression(tmpdir):
|
|
66
|
-
"""Infer lz4 compression for .lz4 files if lz4 is available."""
|
|
67
|
-
tmp_path = pathlib.Path(str(tmpdir))
|
|
68
|
-
|
|
69
|
-
lz4 = pytest.importorskip("lz4")
|
|
70
|
-
|
|
71
|
-
tmp_path.mkdir(exist_ok=True)
|
|
72
|
-
|
|
73
|
-
tdat = "foobar" * 100
|
|
74
|
-
|
|
75
|
-
with fsspec.core.open(
|
|
76
|
-
str(tmp_path / "out.lz4"), mode="wt", compression="infer"
|
|
77
|
-
) as outfile:
|
|
78
|
-
outfile.write(tdat)
|
|
79
|
-
|
|
80
|
-
compressed = (tmp_path / "out.lz4").open("rb").read()
|
|
81
|
-
assert lz4.frame.decompress(compressed).decode() == tdat
|
|
82
|
-
|
|
83
|
-
with fsspec.core.open(
|
|
84
|
-
str(tmp_path / "out.lz4"), mode="rt", compression="infer"
|
|
85
|
-
) as infile:
|
|
86
|
-
assert infile.read() == tdat
|
|
87
|
-
|
|
88
|
-
with fsspec.core.open(
|
|
89
|
-
str(tmp_path / "out.lz4"), mode="rt", compression="lz4"
|
|
90
|
-
) as infile:
|
|
91
|
-
assert infile.read() == tdat
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def test_zstd_compression(tmpdir):
|
|
95
|
-
"""Infer zstd compression for .zst files if zstandard is available."""
|
|
96
|
-
tmp_path = pathlib.Path(str(tmpdir))
|
|
97
|
-
|
|
98
|
-
zstd = pytest.importorskip("zstandard")
|
|
99
|
-
|
|
100
|
-
tmp_path.mkdir(exist_ok=True)
|
|
101
|
-
|
|
102
|
-
tdat = "foobar" * 100
|
|
103
|
-
|
|
104
|
-
with fsspec.core.open(
|
|
105
|
-
str(tmp_path / "out.zst"), mode="wt", compression="infer"
|
|
106
|
-
) as outfile:
|
|
107
|
-
outfile.write(tdat)
|
|
108
|
-
|
|
109
|
-
compressed = (tmp_path / "out.zst").open("rb").read()
|
|
110
|
-
assert zstd.ZstdDecompressor().decompress(compressed, len(tdat)).decode() == tdat
|
|
111
|
-
|
|
112
|
-
with fsspec.core.open(
|
|
113
|
-
str(tmp_path / "out.zst"), mode="rt", compression="infer"
|
|
114
|
-
) as infile:
|
|
115
|
-
assert infile.read() == tdat
|
|
116
|
-
|
|
117
|
-
with fsspec.core.open(
|
|
118
|
-
str(tmp_path / "out.zst"), mode="rt", compression="zstd"
|
|
119
|
-
) as infile:
|
|
120
|
-
assert infile.read() == tdat
|
|
121
|
-
|
|
122
|
-
# fails in https://github.com/fsspec/filesystem_spec/issues/725
|
|
123
|
-
infile = fsspec.core.open(
|
|
124
|
-
str(tmp_path / "out.zst"), mode="rb", compression="infer"
|
|
125
|
-
).open()
|
|
126
|
-
|
|
127
|
-
infile.close()
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def test_snappy_compression(tmpdir):
|
|
131
|
-
"""No registered compression for snappy, but can be specified."""
|
|
132
|
-
tmp_path = pathlib.Path(str(tmpdir))
|
|
133
|
-
|
|
134
|
-
snappy = pytest.importorskip("snappy")
|
|
135
|
-
|
|
136
|
-
tmp_path.mkdir(exist_ok=True)
|
|
137
|
-
|
|
138
|
-
tdat = "foobar" * 100
|
|
139
|
-
|
|
140
|
-
# Snappy isn't inferred.
|
|
141
|
-
with fsspec.core.open(
|
|
142
|
-
str(tmp_path / "out.snappy"), mode="wt", compression="infer"
|
|
143
|
-
) as outfile:
|
|
144
|
-
outfile.write(tdat)
|
|
145
|
-
assert (tmp_path / "out.snappy").open("rb").read().decode() == tdat
|
|
146
|
-
|
|
147
|
-
# but can be specified.
|
|
148
|
-
with fsspec.core.open(
|
|
149
|
-
str(tmp_path / "out.snappy"), mode="wt", compression="snappy"
|
|
150
|
-
) as outfile:
|
|
151
|
-
outfile.write(tdat)
|
|
152
|
-
|
|
153
|
-
compressed = (tmp_path / "out.snappy").open("rb").read()
|
|
154
|
-
assert snappy.StreamDecompressor().decompress(compressed).decode() == tdat
|
|
155
|
-
|
|
156
|
-
with fsspec.core.open(
|
|
157
|
-
str(tmp_path / "out.snappy"), mode="rb", compression="infer"
|
|
158
|
-
) as infile:
|
|
159
|
-
assert infile.read() == compressed
|
|
160
|
-
|
|
161
|
-
with fsspec.core.open(
|
|
162
|
-
str(tmp_path / "out.snappy"), mode="rt", compression="snappy"
|
|
163
|
-
) as infile:
|
|
164
|
-
assert infile.read() == tdat
|
fsspec/tests/test_config.py
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from warnings import catch_warnings
|
|
3
|
-
|
|
4
|
-
import pytest
|
|
5
|
-
|
|
6
|
-
import fsspec
|
|
7
|
-
from fsspec.config import conf, set_conf_env, set_conf_files
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@pytest.fixture
|
|
11
|
-
def clean_conf():
|
|
12
|
-
"""Tests should start and end with clean config dict"""
|
|
13
|
-
conf.clear()
|
|
14
|
-
yield
|
|
15
|
-
conf.clear()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def test_from_env_ignored(clean_conf):
|
|
19
|
-
env = {
|
|
20
|
-
"FSSPEC": "missing_protocol",
|
|
21
|
-
"FSSPEC_": "missing_protocol",
|
|
22
|
-
"FSSPEC__INVALID_KEY": "invalid_protocol",
|
|
23
|
-
"FSSPEC_INVALID1": "not_json_dict",
|
|
24
|
-
"FSSPEC_INVALID2": '["not_json_dict"]',
|
|
25
|
-
}
|
|
26
|
-
cd = {}
|
|
27
|
-
with catch_warnings(record=True) as w:
|
|
28
|
-
set_conf_env(conf_dict=cd, envdict=env)
|
|
29
|
-
assert len(w) == 5
|
|
30
|
-
assert "unexpected name" in str(w[0].message)
|
|
31
|
-
assert "unexpected name" in str(w[1].message)
|
|
32
|
-
assert "unexpected name" in str(w[2].message)
|
|
33
|
-
assert "parse failure" in str(w[3].message)
|
|
34
|
-
assert "not being a dict" in str(w[4].message)
|
|
35
|
-
assert cd == {}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def test_from_env_kwargs(clean_conf):
|
|
39
|
-
env = {
|
|
40
|
-
"FSSPEC_PROTO_KEY": "value",
|
|
41
|
-
"FSSPEC_PROTO_LONG_KEY": "othervalue",
|
|
42
|
-
"FSSPEC_MALFORMED": "novalue",
|
|
43
|
-
}
|
|
44
|
-
cd = {}
|
|
45
|
-
with catch_warnings(record=True) as w:
|
|
46
|
-
set_conf_env(conf_dict=cd, envdict=env)
|
|
47
|
-
assert len(w) == 1
|
|
48
|
-
assert "parse failure" in str(w[0].message)
|
|
49
|
-
assert cd == {"proto": {"key": "value", "long_key": "othervalue"}}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def test_from_env_protocol_dict(clean_conf):
|
|
53
|
-
env = {
|
|
54
|
-
"FSSPEC_PROTO": '{"int": 1, "float": 2.3, "bool": true, "dict": {"key": "val"}}'
|
|
55
|
-
}
|
|
56
|
-
cd = {}
|
|
57
|
-
set_conf_env(conf_dict=cd, envdict=env)
|
|
58
|
-
assert cd == {
|
|
59
|
-
"proto": {"int": 1, "float": 2.3, "bool": True, "dict": {"key": "val"}}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def test_from_env_kwargs_override_protocol_dict(clean_conf):
|
|
64
|
-
env = {
|
|
65
|
-
"FSSPEC_PROTO_LONG_KEY": "override1",
|
|
66
|
-
"FSSPEC_PROTO": '{"key": "value1", "long_key": "value2", "otherkey": "value3"}',
|
|
67
|
-
"FSSPEC_PROTO_KEY": "override2",
|
|
68
|
-
}
|
|
69
|
-
cd = {}
|
|
70
|
-
set_conf_env(conf_dict=cd, envdict=env)
|
|
71
|
-
assert cd == {
|
|
72
|
-
"proto": {"key": "override2", "long_key": "override1", "otherkey": "value3"}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def test_from_file_ini(clean_conf, tmpdir):
|
|
77
|
-
file1 = os.path.join(tmpdir, "1.ini")
|
|
78
|
-
file2 = os.path.join(tmpdir, "2.ini")
|
|
79
|
-
with open(file1, "w") as f:
|
|
80
|
-
f.write(
|
|
81
|
-
"""[proto]
|
|
82
|
-
key=value
|
|
83
|
-
other_key:othervalue
|
|
84
|
-
overwritten=dont_see
|
|
85
|
-
"""
|
|
86
|
-
)
|
|
87
|
-
with open(file2, "w") as f:
|
|
88
|
-
f.write(
|
|
89
|
-
"""[proto]
|
|
90
|
-
overwritten=see
|
|
91
|
-
"""
|
|
92
|
-
)
|
|
93
|
-
cd = {}
|
|
94
|
-
set_conf_files(tmpdir, cd)
|
|
95
|
-
assert cd == {
|
|
96
|
-
"proto": {"key": "value", "other_key": "othervalue", "overwritten": "see"}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
def test_from_file_json(clean_conf, tmpdir):
|
|
101
|
-
file1 = os.path.join(tmpdir, "1.json")
|
|
102
|
-
file2 = os.path.join(tmpdir, "2.json")
|
|
103
|
-
with open(file1, "w") as f:
|
|
104
|
-
f.write(
|
|
105
|
-
"""{"proto":
|
|
106
|
-
{"key": "value",
|
|
107
|
-
"other_key": "othervalue",
|
|
108
|
-
"overwritten": false}}
|
|
109
|
-
"""
|
|
110
|
-
)
|
|
111
|
-
with open(file2, "w") as f:
|
|
112
|
-
f.write(
|
|
113
|
-
"""{"proto":
|
|
114
|
-
{"overwritten": true}}
|
|
115
|
-
"""
|
|
116
|
-
)
|
|
117
|
-
cd = {}
|
|
118
|
-
set_conf_files(tmpdir, cd)
|
|
119
|
-
assert cd == {
|
|
120
|
-
"proto": {"key": "value", "other_key": "othervalue", "overwritten": True}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def test_apply(clean_conf):
|
|
125
|
-
conf["file"] = {"auto_mkdir": "test"}
|
|
126
|
-
fs = fsspec.filesystem("file")
|
|
127
|
-
assert fs.auto_mkdir == "test"
|
|
128
|
-
fs = fsspec.filesystem("file", auto_mkdir=True)
|
|
129
|
-
assert fs.auto_mkdir is True
|