diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 0e1f62833..fa581b97d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,25 +1,37 @@ name: Test -on: [push, pull_request] +on: + pull_request: + branches: + - main + push: + branches: + - main + workflow_dispatch: jobs: test: - runs-on: ubuntu-latest + name: ${{ matrix.platform }} py${{ matrix.python-version }} + runs-on: ${{ matrix.platform }} strategy: fail-fast: false matrix: - python-version: ["3.10","3.11"] + platform: [ubuntu-latest, windows-latest, macos-latest] + python-version: ['3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install . - pip install -r requirements-dev.txt - - name: Test with pytest - run: | - pytest tests + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e . + pip install -r requirements-dev.txt + + - name: Test + run: pytest tests -s -v --color=yes diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..169439dd2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,38 @@ +ci: + autoupdate_schedule: monthly + autofix_commit_msg: "style(pre-commit.ci): auto fixes [...]" + autoupdate_commit_msg: "ci(pre-commit.ci): autoupdate" + +default_install_hook_types: [pre-commit, commit-msg] + +repos: + # - repo: https://github.com/compilerla/conventional-pre-commit + # rev: v2.1.1 + # hooks: + # - id: conventional-pre-commit + # stages: [commit-msg] + + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.2.1 + hooks: + - id: ruff + args: [--fix] + + - repo: https://github.com/psf/black + rev: 24.2.0 + hooks: + - id: black + + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.16 + hooks: + - id: validate-pyproject + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.8.0 + hooks: + - id: mypy + files: "^src/" + # # you have to add the things you want to type check against here + # additional_dependencies: + # - numpy diff --git a/CONTRIBUTOR.md b/CONTRIBUTOR.md new file mode 100644 index 000000000..a6c0c11c1 --- /dev/null +++ b/CONTRIBUTOR.md @@ -0,0 +1,22 @@ +# Contributor Guide + +## Development Installation +- currently, pip install -r requirements-dev.txt +and then pip install -e . +TODO: set up pip install -e .[dev] + +## Style and Pre-Commit +- TODO: pre-commit with black mypy +- do use ruff and black +- do have typing, developers should supply types + +## Testing +- Unittest your functions +- Pytest run automatically on PR, and so is codcov (maybe) +TODO: codecov + + +## Branching and PRs +- Users that have been added to the CellMap organization and the DaCapo project should be able to develop directly into the CellMap fork of DaCapo. Other users will need to create a fork. +- For a completely new feature, make a branch off of the `main` branch of CellMap's fork of DaCapo with a name describing the feature. If you are collaborating on a feature that already has a branch, you can branch off that feature branch. +- Currently, you should make your PRs into the main branch of CellMap's fork, or the feature branch you branched off of. Once the PR is merged, the feature branch should be deleted. diff --git a/README.md b/README.md index 64d35064a..5902959e5 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,25 @@ on arbitrarily large volumes of multi-dimensional images. `dacapo` is not tied to a particular learning framework, but currently only supports [`torch`](https://pytorch.org/) with plans to support [`tensorflow`](https://www.tensorflow.org/). + +## Installation and Setup +Currently, only python 3.10 is supported. We recommend creating a new conda environment for dacapo with python 3.10. +``` +conda create -n dacapo python=3.10 +``` + +Then clone this repository, go into the directory, and install: +``` +git clone git@github.com:janelia-cellmap/dacapo.git +cd dacapo +pip install . +``` +This will install the minimum required dependencies. However, having acess to a MongoDB server for storing outputs is strongly recommended for smoothest performance. + +To install and run MongoDB locally, refer to the MongoDB documentation [here](https://www.mongodb.com/docs/manual/installation/). + +## Functionality Overview + +Tasks we support + +Networks we have for those tasks diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..ebbe10e94 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,162 @@ +# https://peps.python.org/pep-0517/ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +# https://peps.python.org/pep-0621/ +[project] +name = "dacapo-ml" +description = "Framework for easy composition of volumetric machine learning jobs." +readme = "README.md" +requires-python = ">=3.8" +# license = { text = "BSD 3-Clause License" } +authors = [ + { email = "rhoadesj@hhmi.org", name = "Jeff Rhoades" }, + { email = "pattonw@janelia.hhmi.org", name = "Will Patton" }, + { email = "zouinkhim@hhmi.org", name = "Marwan Zouinkhi" }, + { email = "funkej@janelia.hhmi.org", name = "Jan Funke" }, +] +classifiers = [ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: BSD License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Typing :: Typed", +] +dynamic = ["version"] +dependencies = [ + "numpy==1.22.3", + "pyyaml", + "zarr", + "cattrs", + "pymongo", + "tqdm", + "simpleitk", + "lazy-property", + "neuroglancer", + "torch", + "fibsem_tools", + "attrs", + "bokeh", + "numpy-indexed>=0.3.7", + "daisy>=1.0", + "funlib.math>=0.1", + "funlib.geometry>=0.2", + "mwatershed>=0.1", + "funlib.persistence @ git+https://github.com/janelia-cellmap/funlib.persistence", + "funlib.evaluate @ git+https://github.com/pattonw/funlib.evaluate", + "gunpowder>=1.3", + # "lsds>=0.1.3", + "lsds @ git+https://github.com/funkelab/lsd", + "xarray", + "cattrs", + "numpy-indexed", + "click",] + +# extras +# https://peps.python.org/pep-0621/#dependencies-optional-dependencies +[project.optional-dependencies] +test = ["pytest==7.4.4", "pytest-cov", "pytest-lazy-fixture"] +dev = [ + "black", + "ipython", + "mypy", + "pdbpp", + "rich", + "ruff", +] +docs = [ + "sphinx-autodoc-typehints", + "sphinx-material", +] + +[project.urls] +homepage = "https://github.com/janelia-cellmap/dacapo" +repository = "https://github.com/janelia-cellmap/dacapo" + +# https://hatch.pypa.io/latest/config/metadata/ +[tool.hatch.version] +source = "vcs" + +# https://hatch.pypa.io/latest/config/build/#file-selection +# [tool.hatch.build.targets.sdist] +# include = ["/src", "/tests"] +[tool.hatch.metadata] +allow-direct-references = true + +[tool.hatch.build.targets.wheel] +only-include = ["dacapo"] +sources = ["dacapo"] + +# https://github.com/charliermarsh/ruff +[tool.ruff] +line-length = 88 +target-version = "py38" +src = ["dacapo"] +# https://beta.ruff.rs/docs/rules/ +select = [ + "E", # style errors + "W", # style warnings + "F", # flakes + "D", # pydocstyle + "I", # isort + "UP", # pyupgrade + "C4", # flake8-comprehensions + "B", # flake8-bugbear + "A001", # flake8-builtins + "RUF", # ruff-specific rules +] + +[tool.ruff.per-file-ignores] +"tests/*.py" = ["D", "S"] + +# https://docs.pytest.org/en/6.2.x/customize.html +[tool.pytest.ini_options] +minversion = "6.0" +testpaths = ["tests"] +filterwarnings = [ + "error", + "ignore::DeprecationWarning", + ] + + +# https://mypy.readthedocs.io/en/stable/config_file.html +[tool.mypy] +files = "dacapo/**/" +strict = true +disallow_any_generics = false +disallow_subclassing_any = false +show_error_codes = true +pretty = true + +# # module specific overrides +# [[tool.mypy.overrides]] +# module = ["numpy.*",] +# ignore_errors = true + + +# https://coverage.readthedocs.io/en/6.4/config.html +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "if TYPE_CHECKING:", + "@overload", + "except ImportError", + "\\.\\.\\.", + "raise NotImplementedError()", +] +[tool.coverage.run] +source = ["dacapo"] + +# https://github.com/mgedmin/check-manifest#configuration +[tool.check-manifest] +ignore = [ + ".github_changelog_generator", + ".pre-commit-config.yaml", + ".ruff_cache/**/*", + "tests/**/*", +] diff --git a/setup.py b/setup.py deleted file mode 100644 index df27d5cae..000000000 --- a/setup.py +++ /dev/null @@ -1,45 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="dacapo-ml", - description="Framework for easy composition of volumetric machine learning jobs.", - long_description=open("README.md", "r").read(), - long_description_content_type="text/markdown", - version="0.2.0", - url="https://github.com/janelia-cellmap/dacapo", - author="Jan Funke, Will Patton, Jeff Rhoades, Marwan Zouinkhi", - author_email="funkej@janelia.hhmi.org, pattonw@janelia.hhmi.org, rhoadesj@hhmi.org, zouinkhim@hhmi.org", - license="MIT", - packages=find_packages(), - entry_points={"console_scripts": ["dacapo=dacapo.cli:cli"]}, - include_package_data=True, - install_requires=[ - "numpy", - "pyyaml", - "zarr", - "cattrs", - "pymongo", - "tqdm", - "simpleitk", - "lazy-property", - "neuroglancer", - "torch", - "fibsem_tools", - "attrs", - "bokeh", - "numpy-indexed>=0.3.7", - "daisy>=1.0", - "funlib.math>=0.1", - "funlib.geometry>=0.2", - "mwatershed>=0.1", - "funlib.persistence @ git+https://github.com/janelia-cellmap/funlib.persistence", - "funlib.evaluate @ git+https://github.com/pattonw/funlib.evaluate", - "gunpowder>=1.3", - # "lsds>=0.1.3", - "lsds @ git+https://github.com/funkelab/lsd", - "xarray", - "cattrs", - "numpy-indexed", - "click", - ], -)