diff --git a/.copier-answers.yml b/.copier-answers.yml index 813f431..7cf8f67 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,10 +1,10 @@ # Do not edit - changes here will be overwritten by Copier -_commit: v0.3.0 +_commit: v0.4.2 _src_path: gh:fractal-analytics-platform/fractal-tasks-template author_email: lorenzo.cerrone@uzh.ch author_name: Lorenzo Cerrone package_name: plantseg_tasks project_name: fractal-plantseg-tasks -project_short_description: Package description. -project_url: '' +project_short_description: A collection of fractal tasks to run plantseg workflows. +project_url: https://github.com/fractal-analytics-platform/fractal-plantseg-tasks diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml new file mode 100644 index 0000000..f43ba77 --- /dev/null +++ b/.github/workflows/build_and_test.yml @@ -0,0 +1,92 @@ +# name: CI (build and test) + +# on: +# push: +# branches: ["main"] +# tags: +# - "*" +# pull_request: +# branches: ["main"] + + +# jobs: +# tests: +# strategy: +# matrix: +# os: [ubuntu-22.04, macos-latest] +# python-version: ["3.9", "3.10", "3.11"] +# exclude: +# - os: macos-latest +# python-version: '3.9' +# - os: macos-latest +# python-version: '3.10' +# name: "Core, Python ${{ matrix.python-version }}, ${{ matrix.os }}" +# runs-on: ${{ matrix.os }} +# timeout-minutes: 10 + +# steps: +# - uses: actions/checkout@v4 +# with: +# fetch-depth: 1 + +# - name: Set up Python ${{ matrix.python-version }} +# uses: actions/setup-python@v5 +# with: +# python-version: ${{ matrix.python-version }} +# cache: "pip" + +# - name: Install package +# run: python -m pip install -e .[dev] + +# - name: Regenerate the manifest +# run: python src/plantseg_tasks/dev/create_manifest.py + +# - name: Check if manifest has changed +# run: | +# if [ -n "$(git diff --exit-code ./src/plantseg_tasks/__FRACTAL_MANIFEST__.json)" ]; then +# echo "__FRACTAL_MANIFEST__.json has changed. Please run 'python src/plantseg_tasks/dev/create_manifest.py' and commit the changes." +# exit 1 +# else +# echo "__FRACTAL_MANIFEST__.json has not changed." +# fi + +# - name: Test core library with pytest +# run: python -m pytest tests + +# deploy: +# name: Deploy +# needs: tests +# if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule' +# runs-on: ubuntu-latest + +# permissions: +# # IMPORTANT: this permission is mandatory for trusted publishing on PyPi +# # see https://docs.pypi.org/trusted-publishers/ +# id-token: write +# # This permission allows writing releases +# contents: write + +# steps: +# - uses: actions/checkout@v4 +# with: +# fetch-depth: 0 + +# - name: 🐍 Set up Python +# uses: actions/setup-python@v5 +# with: +# python-version: "3.x" + +# - name: 👷 Build +# run: | +# python -m pip install build +# python -m build + +# - name: 🚢 Publish to PyPI +# # TODO remove the "if: false" line when the package is ready for pypi release +# if: false +# uses: pypa/gh-action-pypi-publish@release/v1 + +# - uses: softprops/action-gh-release@v2 +# with: +# generate_release_notes: true +# files: './dist/*' \ No newline at end of file diff --git a/.gitignore b/.gitignore index b61e568..36b5e77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +# Git ignored is sourced from https://github.com/pydev-guide/pyrepo-copier/blob/main/LICENSE # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] @@ -8,6 +9,7 @@ __pycache__/ # Distribution / packaging .Python +env/ build/ develop-eggs/ dist/ @@ -20,11 +22,11 @@ parts/ sdist/ var/ wheels/ -share/python-wheels/ *.egg-info/ .installed.cfg *.egg -MANIFEST + +.DS_Store # PyInstaller # Usually these files are written by a python script from a template @@ -39,17 +41,14 @@ pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ -.nox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover -*.py,cover .hypothesis/ .pytest_cache/ -cover/ # Translations *.mo @@ -58,8 +57,6 @@ cover/ # Django stuff: *.log local_settings.py -db.sqlite3 -db.sqlite3-journal # Flask stuff: instance/ @@ -72,63 +69,27 @@ instance/ docs/_build/ # PyBuilder -.pybuilder/ target/ # Jupyter Notebook .ipynb_checkpoints -# IPython -profile_default/ -ipython_config.py - # pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/latest/usage/project/#working-with-version-control -.pdm.toml -.pdm-python -.pdm-build/ - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff +.python-version + +# celery beat schedule file celerybeat-schedule -celerybeat.pid # SageMath parsed files *.sage.py -# Environments +# dotenv .env + +# virtualenv .venv -env/ venv/ ENV/ -env.bak/ -venv.bak/ # Spyder project settings .spyderproject @@ -142,26 +103,10 @@ venv.bak/ # mypy .mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ -# Cython debug symbols -cython_debug/ +# ruff +.ruff_cache/ -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ -.vscode -*.ipynb - -# MacOS files -.DS_Store +# IDE settings +.vscode/ +.idea/ \ No newline at end of file diff --git a/create_env_script.sh b/create_env_script.sh index 2a0ff4d..f01d91b 100644 --- a/create_env_script.sh +++ b/create_env_script.sh @@ -34,4 +34,4 @@ $COMMMAND run --name $ENVNAME pip install git+https://github.com/fractal-analyti echo "Downloading the __FRACTAL_MANIFEST__.json file file" -curl -O https://raw.githubusercontent.com/fractal-analytics-platform/fractal-plantseg-tasks/$VERSION/__FRACTAL_MANIFEST__.json +curl -O https://raw.githubusercontent.com/fractal-analytics-platform/fractal-plantseg-tasks/$VERSION/src/plantseg_tasks/__FRACTAL_MANIFEST__.json diff --git a/pyproject.toml b/pyproject.toml index 9d08b7f..3b9d1e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,25 +5,19 @@ build-backend = "hatchling.build" # https://hatch.pypa.io/latest/config/metadata/ [tool.hatch.version] -#path = "src/plantseg_tasks/__init__.py" source = "vcs" # read more about configuring hatch at: # https://hatch.pypa.io/latest/config/build/ [tool.hatch.build.targets.wheel] -only-include = ["src"] -sources = ["src"] - -# Always include the __FRACTAL_MANIFEST__.json file in the package -[tool.hatch.build] -include = ["__FRACTAL_MANIFEST__.json"] +packages = ["src/plantseg_tasks"] # Project metadata (see https://peps.python.org/pep-0621) [project] name = "fractal-plantseg-tasks" dynamic = ["version"] -description = "Package description." +description = "A collection of fractal tasks to run plantseg workflows." readme = "README.md" license = { text = "BSD-3-Clause" } authors = [ @@ -32,7 +26,7 @@ authors = [ # Required Python version and dependencies requires-python = ">=3.9" -dependencies = ["fractal-tasks-core == 1.2.1"] +dependencies = ["fractal-tasks-core == 1.3.3"] # Optional dependencies (e.g. for `pip install -e ".[dev]"`, see # https://peps.python.org/pep-0621/#dependencies-optional-dependencies) diff --git a/src/plantseg_tasks/__FRACTAL_MANIFEST__.json b/src/plantseg_tasks/__FRACTAL_MANIFEST__.json index e4587f5..6aad503 100644 --- a/src/plantseg_tasks/__FRACTAL_MANIFEST__.json +++ b/src/plantseg_tasks/__FRACTAL_MANIFEST__.json @@ -2,7 +2,12 @@ "manifest_version": "2", "task_list": [ { - "name": "H5 Converter Task", + "name": "Convert H5 to OME-Zarr", + "category": "Conversion", + "tags": [ + "H5", + "HDF5" + ], "executable_non_parallel": "convert_h5_to_ome_zarr.py", "meta_non_parallel": { "cpus_per_task": 1, @@ -250,7 +255,8 @@ "docs_info": "## convert_h5_to_ome_zarr\nH5 to OME-Zarr converter task.\n" }, { - "name": "Tiff Converter Task", + "name": "Convert Tiff to OME-Zarr", + "category": "Conversion", "executable_non_parallel": "convert_tiff_to_ome_zarr.py", "meta_non_parallel": { "cpus_per_task": 1, @@ -494,7 +500,13 @@ "docs_info": "## convert_tiff_to_ome_zarr\nTIFF to OME-Zarr converter task.\n" }, { - "name": "PlantSeg Workflow Task", + "name": "PlantSeg Segmentation", + "category": "Segmentation", + "tags": [ + "Neural Network Segmentation", + "Deep Learning", + "Instance Segmentation" + ], "executable_parallel": "plantseg_workflow.py", "meta_parallel": { "cpus_per_task": 1, @@ -712,5 +724,6 @@ } ], "has_args_schemas": true, - "args_schema_version": "pydantic_v2" + "args_schema_version": "pydantic_v2", + "authors": "Lorenzo Cerrone" } diff --git a/src/plantseg_tasks/__init__.py b/src/plantseg_tasks/__init__.py index 28919eb..de80e1f 100644 --- a/src/plantseg_tasks/__init__.py +++ b/src/plantseg_tasks/__init__.py @@ -1,4 +1,4 @@ -"""Package description.""" +"""A collection of fractal tasks to run plantseg workflows.""" from importlib.metadata import PackageNotFoundError, version diff --git a/src/plantseg_tasks/dev/create_manifest.py b/src/plantseg_tasks/dev/create_manifest.py index 20a8d88..8143b15 100644 --- a/src/plantseg_tasks/dev/create_manifest.py +++ b/src/plantseg_tasks/dev/create_manifest.py @@ -33,4 +33,7 @@ ] if __name__ == "__main__": PACKAGE = "plantseg_tasks" - create_manifest(package=PACKAGE, custom_pydantic_models=custom_pydantic_models) + AUTHORS = "Lorenzo Cerrone" + create_manifest( + package=PACKAGE, authors=AUTHORS, custom_pydantic_models=custom_pydantic_models + ) diff --git a/src/plantseg_tasks/dev/task_list.py b/src/plantseg_tasks/dev/task_list.py index 3c741e5..4e5f4fd 100644 --- a/src/plantseg_tasks/dev/task_list.py +++ b/src/plantseg_tasks/dev/task_list.py @@ -7,15 +7,24 @@ name="Convert H5 to OME-Zarr", executable="convert_h5_to_ome_zarr.py", meta={"cpus_per_task": 1, "mem": 8000}, + category="Conversion", + tags=["H5", "HDF5"], ), NonParallelTask( name="Convert Tiff to OME-Zarr", executable="convert_tiff_to_ome_zarr.py", meta={"cpus_per_task": 1, "mem": 8000}, + category="Conversion", ), ParallelTask( name="PlantSeg Segmentation", executable="plantseg_workflow.py", meta={"cpus_per_task": 1, "mem": 32000, "needs_gpu": True}, + category="Segmentation", + tags=[ + "Neural Network Segmentation", + "Deep Learning", + "Instance Segmentation", + ], ), ] diff --git a/tests/data/ngff_example/my_image/0/0/0/0/0 b/tests/data/ngff_example/my_image/0/0/0/0/0 new file mode 100644 index 0000000..df7bd46 Binary files /dev/null and b/tests/data/ngff_example/my_image/0/0/0/0/0 differ diff --git a/tests/data/ngff_example/my_image/0/0/1/0/0 b/tests/data/ngff_example/my_image/0/0/1/0/0 new file mode 100644 index 0000000..e608647 Binary files /dev/null and b/tests/data/ngff_example/my_image/0/0/1/0/0 differ diff --git a/tests/data/ngff_example/my_image/1/0/0/0/0 b/tests/data/ngff_example/my_image/1/0/0/0/0 new file mode 100644 index 0000000..36c0313 Binary files /dev/null and b/tests/data/ngff_example/my_image/1/0/0/0/0 differ diff --git a/tests/data/ngff_example/my_image/1/0/1/0/0 b/tests/data/ngff_example/my_image/1/0/1/0/0 new file mode 100644 index 0000000..ec2558d Binary files /dev/null and b/tests/data/ngff_example/my_image/1/0/1/0/0 differ diff --git a/tests/data/ngff_example/my_image/tables/FOV_ROI_table/X/0.0 b/tests/data/ngff_example/my_image/tables/FOV_ROI_table/X/0.0 new file mode 100644 index 0000000..8b09985 Binary files /dev/null and b/tests/data/ngff_example/my_image/tables/FOV_ROI_table/X/0.0 differ diff --git a/tests/data/ngff_example/my_image/tables/FOV_ROI_table/obs/FieldIndex/0 b/tests/data/ngff_example/my_image/tables/FOV_ROI_table/obs/FieldIndex/0 new file mode 100644 index 0000000..a114ea0 Binary files /dev/null and b/tests/data/ngff_example/my_image/tables/FOV_ROI_table/obs/FieldIndex/0 differ diff --git a/tests/data/ngff_example/my_image/tables/well_ROI_table/X/0.0 b/tests/data/ngff_example/my_image/tables/well_ROI_table/X/0.0 new file mode 100644 index 0000000..bd67d97 Binary files /dev/null and b/tests/data/ngff_example/my_image/tables/well_ROI_table/X/0.0 differ diff --git a/tests/data/ngff_example/my_image/tables/well_ROI_table/obs/FieldIndex/0 b/tests/data/ngff_example/my_image/tables/well_ROI_table/obs/FieldIndex/0 new file mode 100644 index 0000000..338e5b7 Binary files /dev/null and b/tests/data/ngff_example/my_image/tables/well_ROI_table/obs/FieldIndex/0 differ