Repository navigation
[ENH] Use hatch - #1553
[ENH] Use hatch#1553
Conversation
|
I am not opposed, but I am not familiar with hatch. Moving to pyproject is definitely worthwhile, but other projects I work on (dask-awkward aside) use setuptools_scm (no longer versioneer, which should certainly be removed). Is there anything in particular I need to know. |
|
(if someone would like to implement retries throughout the flaky SMB implementation and tests, I would be grateful) |
| dev = [ "black", "pre-commit"] | ||
| test = ["pytest", "pytest-cov", 'numpy', "pytest-mock", "requests", "aiohttp !=4.0.0a0, !=4.0.0a1", 'urllib3 <=1.26.18', 'tqdm'] | ||
| dropbox = ["dropbox", "dropboxdrivefs", "requests"] | ||
| entrypoints = [] |
There was a problem hiding this comment.
I tried to do something with setuptools a while back, but couldn't figure out how to avoid replicating 'full' list pyproject properly.
What advantage does hatchling have over setuptools btw?
There was a problem hiding this comment.
also had some trouble getting versioneer to play nicely with it.
There was a problem hiding this comment.
(happy to ditch versioneer. It used to be the only solution, but not any more)
There was a problem hiding this comment.
What advantage does hatchling have over setuptools btw?
Personally I find Hatch easy to use. see also: https://hatch.pypa.io/latest/why/#build-backend.
The default settings in Hatch mean that editable installs normally just work (including type hints). I find it makes it easier to editable install multiple packages into the same Python environment.
I think hatch-vcs is compatible with setuptools-scm. |
|
Yes, I certainly expect VCS versioning to work, I've just never done it with hatch |
|
So, an appropriate test run would be to build and install the wheel, and check that the installed version and |
|
Did you see the CI error, which I would imagine is indeed due to the new build backend: |
|
changes:
The downstream test is still failing at Dask. Will investigate this later. |
|
You might need to download and -e install dask in a different directory not under fsspec to prevent pytest from getting confused. |
…' optional dependency.
… running docker).
Changes
Workflows
Tests
s3fss3fs depends on a specific version eg In fsspec, when installing as editable, the version number is something like the latest tag plus a diff eg: The current workaround is to:
This ensures the tests are being run against the dev version of fsspec. It'd be better if the 3sfs tests are moved to s3fs. They can still be run as a downstream test. DownstreamThe downstream tests import from s3fs tests, for some reason the tests can't be access correctly using a standard install and require the source to be installed. It'd be better if the s3fs could be less strict on fsspec version. eg: DaskPreviously the dask repo was cloned and the bleeding edge tests run. Now Dask is installed as a module and the tests run directly in the module. dask_test_path=$(python -c "import dask.bytes;print(dask.bytes.__path__[0])")
pytest -v $dask_test_pathAll downstream tests could be run this way. This would mean that a released version of the tests are run rather than an unknown version. |
|
Thanks! There's a lot of work here, so it will take me some time to look through it. |
|
On the whole this looks very reasonable. Since we have a question on VCS integration, we should have a specific check that the dev install of fsspec has a version (both in importlib.metadata and in
This is not possible, the two must always be released together and match versions, as they are so closely linked. However, the version could be like
To be sure, which tests are we talking about? s3fs's own tests are run both in its own repo (to see if a change in s3fs broke anything) and here (to see if a change in fsspec broe s3fs); but are there also s3fs tests within fsspec's test suite??
This may be OK, since dask should not merge PRs which break their own tests; but it's not uncommon to want to test the current "dev" versions of releated packages against each other. Also note that I haven't explicitly checked that dask includes all the test code in its release (there's not really a reason that it should!). |
Sorry I don't understand what you mean.
I think I tried doing
In that case, we can just leave it as is.
Specifically the downstream tests, that currently require the s3fs repo to be cloned: try:
from s3fs.tests.test_s3fs import ( # noqa: E402,F401
endpoint_uri,
s3,
s3_base,
test_bucket_name,
)
except ImportError:
pytest.skip("s3 tests not available.")
so = {"anon": False, "client_kwargs": {"endpoint_url": endpoint_uri}}
def test_pandas(s3):
pd = pytest.importorskip("pandas")
df = pd.DataFrame({"a": [1, 2], "b": [3, 4]})
df.to_csv(f"s3://{test_bucket_name}/a.csv", storage_options=so)
df2 = pd.read_csv(f"s3://{test_bucket_name}/a.csv", storage_options=so)
assert df.a.equals(df2.a)
def test_xarray_zarr(s3):
xr = pytest.importorskip("xarray")
pytest.importorskip("zarr")
import numpy as np
x = np.arange(5)
xarr = xr.DataArray(x)
ds = xr.Dataset({"x": xarr})
ds.to_zarr(f"s3://{test_bucket_name}/a.zarr", storage_options=so)
ds2 = xr.open_zarr(f"s3://{test_bucket_name}/a.zarr", storage_options=so)
assert (ds.x == ds2.x).all()If the tests are moved (or the tests accessible from a normal install) then we'd no longer need to clone s3fs to run the tests.
The original issue was that we were having was that Dask (and s3fs) were cloned as a sub-folder inside fsspec. I didn't look deeply into fixing because I thought it better to test against a known version rather than a potentially dynamic version downstream. Happy for you push any further changes you wish to make. |
Essentially I verified this locally by going through the build-install-import flow.
There's a pretty good argument that these belong here, since they are not actually testing s3 functionality. They could use any fsspec backend, but in practice s3 is the most likely storage for these third-party libraries to want to use.
I'll try to make some time to do a little experimentation. As it is, the install step downloads a whole load of dependencies, and it seems to be risky to reply on pip getting this right (although there were no problems) compared to conda. You could reasonably say that the test set of deps is simply too big ... |
|
Looks good to me. Regarding the number optional dependencies installed: They've almost entirely been shifted from the The advantage in using pip install is that it works 'everywhere'. I agree that the optional dependencies could be rationalized. |
For consideration: Switch to using hatchling as the build backend. This PR removes the setup.py file and maintains versioneer as the vcs.
Why hatch: https://hatch.pypa.io/latest/why/
Feel free to modify as you wish or reject if it doesn't suit.