Skip to content

Commit fba793c

Browse files
authored
Merge pull request #3 from martindurant/ci2
now ci runs
2 parents 53a84b1 + 0ac6f3d commit fba793c

File tree

7 files changed

+106
-31
lines changed

7 files changed

+106
-31
lines changed

.github/workflows/main.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
python-version: ${{ matrix.PY }}
2929
- name: Install
3030
run: |
31-
pip install ./fsspec-proxy
32-
pip install ./pyscript-fsspec-client[test]
31+
pip install -e ./fsspec-proxy
32+
pip install -e ./pyscript-fsspec-client[test]
3333
- name: test
34-
run: pytest -v
34+
run: pytest -v -s

fsspec-proxy/LICENSE

Lines changed: 0 additions & 1 deletion
This file was deleted.

fsspec-proxy/LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2024, Jupyter fsspec contributors
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

fsspec-proxy/fsspec_proxy/file_manager.py

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
11
from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper
22
import fsspec.utils
3+
import io
34
import os
4-
import sys
55
import yaml
66
import logging
77

8-
logging.basicConfig(level=logging.WARNING, stream=sys.stdout)
9-
logger = logging.getLogger(__name__)
10-
logger.setLevel(logging.INFO)
11-
fsspec.utils.setup_logging(logger_name="fsspec.memoryfs")
12-
this_dir = os.path.abspath(os.path.dirname(__file__))
13-
8+
logger = logging.getLogger("fsspec_proxy")
9+
default_config = b"""sources:
10+
- name: inmemory
11+
path: memory://mytests
12+
- name: local
13+
path: file:///Users
14+
readonly: true
15+
- name: "Conda Stats"
16+
path: "s3://anaconda-package-data/conda/hourly/"
17+
kwargs:
18+
anon: True
19+
- name: "MyAnaconda"
20+
path: "anaconda://my/"
21+
allow_reload: true
22+
"""
1423

1524
class FileSystemManager:
16-
def __init__(self):
25+
def __init__(self, config_path=None):
1726
self.filesystems = {}
18-
if "FSSPEC_PROXY_CONFIG" in os.environ:
19-
self.config = self.load_config(os.getenv("FSSPEC_PROXY_CONFIG"))
20-
else:
21-
self.config = self.load_config()
27+
config_path = config_path or os.getenv("FSSPEC_PROXY_CONFIG", None)
28+
self.config = self.load_config(config_path)
2229
self.initialize_filesystems()
2330

24-
def load_config(self, config_path=os.path.join(this_dir, "config.yaml")):
25-
if not os.path.exists(config_path):
31+
def load_config(self, config_path=None):
32+
if config_path is None:
33+
data = default_config
34+
elif not os.path.exists(config_path):
2635
return {}
27-
with open(config_path, "r") as file:
28-
config_content = yaml.safe_load(file)
36+
else:
37+
with open(config_path, "rb") as file:
38+
data = file.read()
39+
config_content = yaml.safe_load(io.BytesIO(data))
2940
logger.info("new config: %s", config_content)
3041
return config_content
3142

@@ -37,7 +48,12 @@ def initialize_filesystems(self):
3748
fs_path = fs_config["path"]
3849
kwargs = fs_config.get("kwargs", {})
3950

40-
fs, url2 = fsspec.url_to_fs(fs_path, **kwargs)
51+
try:
52+
fs, url2 = fsspec.url_to_fs(fs_path, **kwargs)
53+
except Exception:
54+
# or we could still list show their names but not the contents
55+
logger.error("Instantiating filesystem failed")
56+
continue
4157
if not fs.async_impl:
4258
fs = AsyncFileSystemWrapper(fs)
4359

fsspec-proxy/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors = [
88
{name = "martindurant"},
99
]
1010
readme = "../README.md"
11-
license = { file = "../LICENSE" }
11+
license = { file = "LICENSE" }
1212
requires-python = ">=3.9"
1313
classifiers = [
1414
# "Framework :: PyScript",
@@ -23,6 +23,7 @@ classifiers = [
2323
]
2424
dependencies = [
2525
"fsspec>=2025.3.0",
26+
"fastapi-cli",
2627
"fastapi"
2728
]
2829
dynamic = ["version", "description", "urls", "keywords"]

pyscript-fsspec-client/LICENSE

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyscript-fsspec-client/LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2024, Jupyter fsspec contributors
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pyscript-fsspec-client/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ requires = ["hatchling>=1.5.0", "hatch-vcs"]
33
build-backend = "hatchling.build"
44

55
[project]
6-
name = "pyscript-client"
6+
name = "pyscript-fsspec-client"
77
authors = [
88
{name = "martindurant"},
99
]
1010
readme = "../README.md"
11-
license = { file = "../LICENSE" }
11+
license = { file = "LICENSE" }
1212
requires-python = ">=3.9"
1313
classifiers = [
1414
"License :: OSI Approved :: BSD License",

tests/test_client.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77
from pyscript_fsspec_client import client
88

99

10-
@pytest.fixture()
10+
@pytest.fixture(scope="session")
1111
def server():
1212
# TODO: test config in "FSSPEC_PROXY_CONFIG" location
13-
P = subprocess.Popen(["fsspec-proxy", "dev"])
14-
s = "http://127.0.0.1:8000"
15-
count = 5
13+
P = subprocess.Popen(["fsspec-proxy"])
14+
s = "http://localhost:8000"
15+
count = 20
1616
while True:
1717
try:
1818
requests.get(f"{s}/health")
1919
break
20-
except OSError:
20+
except BaseException:
2121
if count < 0:
22+
P.terminate()
23+
P.wait()
2224
raise
2325
count -= 1
2426
time.sleep(0.1)
@@ -44,7 +46,7 @@ def test_file(fs):
4446

4547
def test_config(fs):
4648
out = fs.ls("", detail=False)
47-
assert out == ["Conda Stats", "MyAnaconda", "inmemory", "local"]
49+
assert "inmemory" in out and "local" in out # other spaces might fail
4850
fs.reconfigure({"sources": [{"name": "mem", "path": "memory://"}]})
4951
out = fs.ls("", detail=False)
5052
assert out == ["mem"]

0 commit comments

Comments
 (0)