Skip to content

Commit 8bdc524

Browse files
Merge pull request #2 from Quansight/flit-config
add python install and github actions
2 parents 5011ca5 + cc75770 commit 8bdc524

File tree

6 files changed

+129
-22
lines changed

6 files changed

+129
-22
lines changed

.github/workflows/python.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Python package
2+
on: push
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
python-version: [3.7, 3.8]
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Python ${{ matrix.python-version }}
13+
uses: actions/setup-python@v1
14+
with:
15+
python-version: ${{ matrix.python-version }}
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip nox
19+
nox -s install
20+
- name: Test with pytest
21+
run: |
22+
nox -s smoke
23+
24+
- name: Publish package
25+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
26+
uses: pypa/gh-action-pypi-publish@master
27+
with:
28+
user: andrewfulton9
29+
password: ${{ secrets.PYPI_API_TOKEN }}

noxfile.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import nox
2+
3+
4+
@nox.session(python=False)
5+
def develop(session):
6+
session.install("flit")
7+
session.run(*"flit install -s".split())
8+
9+
10+
@nox.session(python=False)
11+
def install(session):
12+
session.install(".")
13+
14+
15+
@nox.session(python=False)
16+
def smoke(session):
17+
session.install(*"pytest".split())
18+
session.run(*"pytest --skiphdfs upath".split())

pyproject.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[build-system]
2+
build-backend = "flit_core.buildapi"
3+
requires = ["flit_core>=2,<4"]
4+
5+
[tool]
6+
[tool.flit]
7+
[tool.flit.metadata]
8+
author = "Andrew Fulton"
9+
author-email = "[email protected]"
10+
classifiers = []
11+
home-page = "https://github.com/Quansight/universal_pathlib"
12+
keywords = ""
13+
license = ""
14+
maintainer = "Andrew Fulton"
15+
maintainer-email = "[email protected]"
16+
module = "upath"
17+
requires = ["fsspec"]
18+
requires-python = ">=3.7"
19+
20+
[tool.flit.metadata.urls]
21+
22+
[tool.flit.metadata.requires-extra]
23+
dev = []
24+
doc = []
25+
test = [
26+
"requests",
27+
"s3fs",
28+
"jupyter ",
29+
"ipython",
30+
"pytest",
31+
"pylint",
32+
"flake8",
33+
"pyarrow",
34+
"moto",
35+
"hadoop-test-cluster",
36+
]
37+
38+
[tool.flit.scripts]
39+
40+
[tool.flit.sdist]
41+
include = []
42+
43+
[tool.flit.entrypoints]

upath/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
"""pathlib with fsspec"""
2+
__version__ = "0.0.3"
3+
14
from upath.core import UPath

upath/tests/conftest.py

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,35 @@
88

99

1010
import pytest
11-
from fsspec import filesystem
1211
from fsspec.implementations.local import LocalFileSystem
1312
from fsspec.registry import (
1413
register_implementation,
1514
_registry
1615
)
1716

1817

18+
def pytest_addoption(parser):
19+
parser.addoption(
20+
"--skiphdfs",
21+
action="store_true",
22+
default=False,
23+
help="skip hdfs tests"
24+
)
25+
26+
27+
def pytest_configure(config):
28+
config.addinivalue_line("markers", "hdfs: mark test as hdfs")
29+
30+
31+
def pytest_collection_modifyitems(config, items):
32+
if not config.getoption("--skiphdfs"):
33+
return
34+
skip_hdfs = pytest.mark.skip(reason="skipping hdfs")
35+
for item in items:
36+
if "hdfs" in item.keywords:
37+
item.add_marker(skip_hdfs)
38+
39+
1940
class DummyTestFS(LocalFileSystem):
2041
protocol = "mock"
2142

@@ -28,25 +49,16 @@ def clear_registry():
2849
finally:
2950
_registry.clear()
3051

31-
32-
# folder_structure = {
33-
# 'folders': {'folder1': {'folders': {},
34-
# 'files': {'file1.txt': 'file1.txt',
35-
# 'file2.txt': 'file2.txt'}}
36-
# 'files': {'file1.txt': 'hello_world',
37-
# 'file2.txt': 'hello_world'}
38-
39-
40-
# }
4152

4253
@pytest.fixture()
4354
def tempdir(clear_registry):
4455
tempdir = tempfile.TemporaryDirectory()
4556
tempdir = tempdir.name
4657
return tempdir
4758

59+
4860
@pytest.fixture()
49-
def local_testdir(tempdir, clear_registry):
61+
def local_testdir(tempdir, clear_registry):
5062
tmp = Path(tempdir)
5163
tmp.mkdir()
5264
folder1 = tmp.joinpath('folder1')
@@ -66,26 +78,28 @@ def local_testdir(tempdir, clear_registry):
6678
yield tempdir
6779
shutil.rmtree(tempdir)
6880

81+
6982
@pytest.fixture(scope='session')
7083
def htcluster():
7184
proc = subprocess.Popen(shlex.split("htcluster startup"),
72-
stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
85+
stderr=subprocess.DEVNULL,
86+
stdout=subprocess.DEVNULL)
7387
time.sleep(30)
7488
yield
7589
proc.terminate()
7690
proc.wait()
7791
proc1 = subprocess.Popen(shlex.split("htcluster shutdown"),
78-
stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
92+
stderr=subprocess.DEVNULL,
93+
stdout=subprocess.DEVNULL)
7994
proc1.terminate()
8095
proc1.wait()
8196
time.sleep(10)
82-
97+
98+
8399
@pytest.fixture()
84100
def hdfs(htcluster, tempdir, local_testdir):
85-
86101
pyarrow = pytest.importorskip('pyarrow')
87102
host, user, port = '0.0.0.0', 'hdfs', 9000
88-
#hdfs = filesystem('hdfs', host=host, user=user, port=port, driver='libhdfs3')
89103
hdfs = pyarrow.hdfs.connect(host='0.0.0.0', port=9000, user=user)
90104
hdfs.mkdir(tempdir, create_parents=True)
91105
for x in Path(local_testdir).glob('**/*'):
@@ -96,10 +110,10 @@ def hdfs(htcluster, tempdir, local_testdir):
96110
with hdfs.open(str(x), 'wb') as f:
97111
f.write(text)
98112
else:
99-
hdfs.mkdir(str(x))
113+
hdfs.mkdir(str(x))
100114
hdfs.close()
101115
yield host, user, port
102-
116+
103117

104118
@pytest.fixture(scope='session')
105119
def s3_server():
@@ -131,8 +145,7 @@ def s3_server():
131145
time.sleep(0.1) # pragma: no cover
132146
anon = False
133147
s3so = dict(client_kwargs={'endpoint_url': endpoint_uri},
134-
use_listings_cache=False)
135-
148+
use_listings_cache=False)
136149
yield anon, s3so
137150
proc.terminate()
138151
proc.wait()

upath/tests/test_core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def test_write_text(self, pathlib_base):
194194
path.write_text(s)
195195
assert path.read_text() == s
196196

197-
197+
@pytest.mark.hdfs
198198
class TestUPathHDFS(TestUpath):
199199

200200
@pytest.fixture(autouse=True)
@@ -254,6 +254,7 @@ def test_touch_unlink(self):
254254
# file doesn't exists, but missing_ok is True
255255
path.unlink(missing_ok=True)
256256

257+
@pytest.mark.hdfs
257258
def test_multiple_backend_paths(local_testdir, s3, hdfs):
258259
anon, s3so = s3
259260
path = f's3:{local_testdir}'

0 commit comments

Comments
 (0)