diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 94777446..26f78d98 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -10,7 +10,7 @@ ## :white_check_mark: Checklist before requesting a review (See the contributing guide for more details on these steps.) -- [ ] I have installed developer dependencies with `pip install -r requirements/requirements.dev.txt` and running `pre-commit install` (or alternatively, manually running `ruff format` before commiting) +- [ ] I have installed developer dependencies with `pip install .[dev]` and running `pre-commit install` (or alternatively, manually running `ruff format` before commiting) If changing or adding source code: - [ ] tests are included and are passing (run `pytest`). diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b4b88258..788adf77 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,9 +14,7 @@ jobs: - name: "Upgrade pip" run: pip install --upgrade pip - name: "Install dependencies" - run: pip install -r requirements/requirements.txt - - name: "Install jupyterbook" - run: pip install -r requirements/requirements.docs.txt + run: pip install .[docs] - name: "Run jupyterbook" run: jupyter-book build docs --all - name: "Deploy" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1e725232..0526fc75 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -31,11 +31,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -U setuptools wheel twine + pip install -U setuptools wheel twine build - name: Build and publish - run: | - python setup.py sdist bdist_wheel + run: python -m build - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c28d220b..e197f4a9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,8 +28,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements/requirements.txt - pip install -r requirements/requirements.dev.txt + pip install .[dev,testing] + pip install tox-gh-actions - name: Test with tox run: tox - name: Run coveralls diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5ecae1ed..12834172 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -96,7 +96,7 @@ command to edit previous commit messages, combine multiple commits into one, or commits that are no longer necessary. Make sure you're using the developer dependencies. -If you're working locally on the source code, *before* commiting, please run `pip install -r requirements/requirements.dev.txt` to install some useful dependencies just for development. +If you're working locally on the source code, *before* commiting, please run `pip install .[dev]` to install some useful dependencies just for development. This includes `pre-commit` and `ruff` which are used to check and format your code style when you run `git commit`, so that you don't have to. Using pre-commit: @@ -151,7 +151,7 @@ One easy way to contribute to the documentation is to provide feedback in [this Another way to contribute is to directly edit or add to the documentation and open a PR: * Follow all the forking instructions above -* Install the documentation requirements: `pip install -r requirements/requirements.docs.txt` +* Install the documentation requirements: `pip install deepsensor[docs]` * Option A: Editing a markdown file * Simply make your edits! * Option B: Editing a jupyter notebook file diff --git a/README.md b/README.md index 55b2c5f9..2343612f 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,7 @@ over the US. First, pip install the package. In this case we will use the PyTorc want GPU support). ```bash -pip install deepsensor -pip install torch +pip install deepsensor[torch] ``` We can go from imports to predictions with a trained model in less than 30 lines of code! diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md index 5baf884a..fb947fe5 100644 --- a/docs/getting-started/installation.md +++ b/docs/getting-started/installation.md @@ -37,6 +37,14 @@ This method will create a `DeepSensor` directory on your machine which will cont ```bash pip install -v -e . ``` + +```{note} +If you intend on contributing to the source code of DeepSensor, install DeepSensor with its development dependencies using +````{bash} +pip install -v -e .[dev] +```` +``` + ## Install PyTorch or TensorFlow The next step, if you intend to use any of DeepSensor's deep learning modelling functionality, @@ -60,3 +68,11 @@ To install `pytorch` via pip: ```bash pip install torch ``` + +To install DeepSensor as well as a deep learning library at the same time use: + +```bash +pip install deepsensor[tf] # for tensorflow and tensorflow_probability +# or +pip install deepsensor[torch] # for pytorch +``` \ No newline at end of file diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 7e821e45..00000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -jupyter-book -matplotlib -numpy diff --git a/pyproject.toml b/pyproject.toml index 8ca07d37..94836cf8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,75 @@ +[build-system] +requires = ["setuptools>=61"] +build-backend = "setuptools.build_meta" + +[project] +name = "deepsensor" +version = "0.4.2" +authors = [ + {name = "Tom R. Andersson", email="tomandersson3@gmail.com"}, +] +description = "A Python package for modelling xarray and pandas data with neural processes." +readme = "README.md" +license = {text="MIT"} +classifiers = [ + "Programming Language :: Python :: 3", + "Operating System :: OS Independent" +] +requires-python = ">=3.8" +dependencies = [ + "backends", + "backends-matrix", + "dask", + "distributed", + "gcsfs", + "matplotlib", + "neuralprocesses>=0.2.7", + "numpy", + "pandas", + "pooch", + "pyshp", + "seaborn", + "tqdm", + "xarray", + "zarr" +] + +[tool.setuptools] +packages = ["deepsensor"] + +[project.urls] +Source = "https://github.com/alan-turing-institute/deepsensor" +Bug_Tracker = "https://github.com/alan-turing-institute/deepsensor/issues" + +[project.optional-dependencies] +torch = ["torch>=2"] +tf = ["tensorflow", "tensorflow_probability[tf]"] +dev = [ + "coveralls", + "parameterized", + "pre-commit", + "pytest", + "ruff", +] +docs = [ + "jupyter-book", + "matplotlib", + "numpy", +] +testing = [ + "mypy", + "parameterized", + "pytest", + "pytest-cov", + "tox", +] +rioxarray = [ + "rioxarray" +] + +[tool.setuptools.package-data] +deepsensor = ["py.typed"] + [tool.pytest.ini_options] addopts = "--cov=deepsensor" testpaths = [ diff --git a/requirements/requirements.dev.txt b/requirements/requirements.dev.txt deleted file mode 100644 index c2cd7f0e..00000000 --- a/requirements/requirements.dev.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Additional requirements for development -coveralls -parameterized -pre-commit -pytest -pytest-cov -ruff -tox -tox-gh-actions diff --git a/requirements/requirements.docs.txt b/requirements/requirements.docs.txt deleted file mode 100644 index 2b475c56..00000000 --- a/requirements/requirements.docs.txt +++ /dev/null @@ -1,2 +0,0 @@ -jupyter-book==0.15.1 -sphinx diff --git a/requirements/requirements.txt b/requirements/requirements.txt deleted file mode 100644 index 8d440976..00000000 --- a/requirements/requirements.txt +++ /dev/null @@ -1,22 +0,0 @@ --e . -pandas -xarray -rioxarray -numpy -dask -distributed -neuralprocesses>=0.2.7 -tensorflow -tensorflow_probability[tf] -torch>=2 -backends-matrix -backends -matplotlib -shapely -pyshp -seaborn -tqdm -jupyter -pooch -gcsfs -zarr diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7f1d6ae9..00000000 --- a/setup.cfg +++ /dev/null @@ -1,49 +0,0 @@ -[metadata] -name = deepsensor -version = 0.4.2 -author = Tom R. Andersson -author_email = tomandersson3@gmail.com -description = A Python package for modelling xarray and pandas data with neural processes. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/alan-turing-institute/deepsensor -license = MIT -license_files = LICENCE.txt -platforms = unix, linux, osx - -packages = - deepsensor -package_dir = - =deepsensor - - -[options] -packages = find: -zip_safe = False # https://mypy.readthedocs.io/en/latest/installed_packages.html -include_package_data = True -python_requires = >=3.8 -install_requires = - neuralprocesses>=0.2.7 - backends-matrix - backends - numpy - pandas - xarray - dask - distributed - pyshp - tqdm - seaborn - pooch - gcsfs - zarr - -[options.extras_require] -testing = - pytest - pytest-cov - mypy - tox - -[options.package_data] -deepsensor = py.typed diff --git a/setup.py b/setup.py deleted file mode 100644 index 7f1a1763..00000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -from setuptools import setup - -if __name__ == "__main__": - setup() diff --git a/tox.ini b/tox.ini index 7dd23ab7..f21f4d9f 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,6 @@ python = setenv = PYTHONPATH = {toxinidir} deps = - -r{toxinidir}/requirements/requirements.txt - -r{toxinidir}/requirements/requirements.dev.txt + .[tf,torch,testing] commands = pytest --basetemp={envtmpdir} \ No newline at end of file