From d2143a688ec6a0383b73ce17fc66c86d59cb90d0 Mon Sep 17 00:00:00 2001 From: Jianxu Chen Date: Wed, 2 Jul 2025 12:15:32 +0200 Subject: [PATCH 1/4] Create .flake8 --- .flake8 | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..3d7a970 --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +# .flake8 +[flake8] +exclude = docs/ +ignore = E501, W503, E203, E266 +max-line-length = 88 From 1e532cc61776932066ffa18b2998b86de7c3564f Mon Sep 17 00:00:00 2001 From: Jianxu Chen Date: Wed, 2 Jul 2025 12:20:46 +0200 Subject: [PATCH 2/4] fix linting error --- vessel_analysis_3d/__init__.py | 4 +--- vessel_analysis_3d/graph/stats_reporting.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/vessel_analysis_3d/__init__.py b/vessel_analysis_3d/__init__.py index 4e0158f..02cc030 100644 --- a/vessel_analysis_3d/__init__.py +++ b/vessel_analysis_3d/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """Top-level package for 3D Vascular Structure Analysis.""" +from .processing_pipeline import Pipeline3D # noqa: F401 __author__ = "Jianxu Chen" __email__ = "jianxuchen.ai@gmail.com" @@ -11,6 +12,3 @@ def get_module_version(): return __version__ - - -from .processing_pipeline import Pipeline3D # noqa: F401 diff --git a/vessel_analysis_3d/graph/stats_reporting.py b/vessel_analysis_3d/graph/stats_reporting.py index 4b56f03..95473c0 100644 --- a/vessel_analysis_3d/graph/stats_reporting.py +++ b/vessel_analysis_3d/graph/stats_reporting.py @@ -66,7 +66,7 @@ def getAllStats(dictionary: Dict, imgName: str) -> List: for segment in dictionary[filament]: final = [] for element in segment: - element= tuple(int(x) for x in element) + element = tuple(int(x) for x in element) final.append(element) segment = tuple(final) list_item = [imgName, filament, segment] From 5bd03615352f4a6dfdc12e73ab0f33e312d357f2 Mon Sep 17 00:00:00 2001 From: Jianxu Chen Date: Wed, 2 Jul 2025 12:33:06 +0200 Subject: [PATCH 3/4] re-formating with black --- vessel_analysis_3d/graph/core.py | 18 +++++++++--------- vessel_analysis_3d/graph/filament.py | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/vessel_analysis_3d/graph/core.py b/vessel_analysis_3d/graph/core.py index 00d3487..180fad4 100644 --- a/vessel_analysis_3d/graph/core.py +++ b/vessel_analysis_3d/graph/core.py @@ -217,15 +217,15 @@ def prune_and_analyze(self, return_final_skel: bool = True): # fill dictionaries containing all filament, segment and branch # point statistics self.segStatsDict[ithDisjointGraph] = filament.segmentStats - self.filStatsDict[ithDisjointGraph][ - "TerminalPoints" - ] = self.countEndPointsDict[ithDisjointGraph] - self.filStatsDict[ithDisjointGraph][ - "BranchPoints" - ] = self.countBranchPointsDict[ithDisjointGraph] - self.filStatsDict[ithDisjointGraph][ - "Segments" - ] = self.countSegmentsDict[ithDisjointGraph] + self.filStatsDict[ithDisjointGraph]["TerminalPoints"] = ( + self.countEndPointsDict[ithDisjointGraph] + ) + self.filStatsDict[ithDisjointGraph]["BranchPoints"] = ( + self.countBranchPointsDict[ithDisjointGraph] + ) + self.filStatsDict[ithDisjointGraph]["Segments"] = ( + self.countSegmentsDict[ithDisjointGraph] + ) self.branchesBrPtDict[ithDisjointGraph] = filament.brPtsDict else: self.infoDict["filaments"] -= 1 diff --git a/vessel_analysis_3d/graph/filament.py b/vessel_analysis_3d/graph/filament.py index 3748458..8547867 100644 --- a/vessel_analysis_3d/graph/filament.py +++ b/vessel_analysis_3d/graph/filament.py @@ -97,13 +97,13 @@ def dfs_iterative(self): ): # cycle found if len(self.graph[neighbor]) > 2: # neighbor is branch point oldPred = self._predDict[neighbor] - self._predDict[ - neighbor - ] = vertex # change predecessor to get segment of cycle + self._predDict[neighbor] = ( + vertex # change predecessor to get segment of cycle + ) segment = self._getSegment(neighbor) - self._predDict[ - neighbor - ] = oldPred # change back to old predecessor + self._predDict[neighbor] = ( + oldPred # change back to old predecessor + ) self._setSegStats(segment, interpolate=self.interpolate) if len(self.graph[vertex]) == 1: # end point found self.endPtsList.append(vertex) From 50f794a13e9b96631ffb5854ed95c3861b8654f9 Mon Sep 17 00:00:00 2001 From: Jianxu Chen Date: Wed, 2 Jul 2025 21:33:48 +0200 Subject: [PATCH 4/4] update build --- .flake8 | 2 +- .github/workflows/build-docs.yml | 34 ------------------- .github/workflows/build-main.yml | 15 ++++----- .github/workflows/test-and-lint.yml | 10 +++--- pyproject.toml | 52 ++++++++++++++++++++++++----- setup.cfg | 10 +++--- setup.py | 20 ----------- 7 files changed, 61 insertions(+), 82 deletions(-) delete mode 100644 .github/workflows/build-docs.yml delete mode 100644 setup.py diff --git a/.flake8 b/.flake8 index 3d7a970..696ff27 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ # .flake8 [flake8] exclude = docs/ -ignore = E501, W503, E203, E266 +ignore = E501, W503, E203, E266, E402 max-line-length = 88 diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml deleted file mode 100644 index 6b73c24..0000000 --- a/.github/workflows/build-docs.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Documentation - -on: - push: - branches: - - main - -jobs: - docs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.11 - - name: Install Dependencies - run: | - pip install --upgrade pip - pip install .[dev] - - name: Generate Docs - run: | - make gen-docs - touch docs/_build/html/.nojekyll - - name: Publish Docs - uses: JamesIves/github-pages-deploy-action@v4 - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BASE_BRANCH: main # The branch the action should deploy from. - BRANCH: gh-pages # The branch the action should deploy to. - FOLDER: docs/_build/html/ # The folder the action should deploy. - diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml index 896f73e..391307f 100644 --- a/.github/workflows/build-main.yml +++ b/.github/workflows/build-main.yml @@ -27,7 +27,7 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install .[test] + pip install .[test] --verbose - name: Test with pytest run: | pytest --cov-report xml --cov=vessel_analysis_3d vessel_analysis_3d/tests/ @@ -50,9 +50,9 @@ jobs: - name: Lint with flake8 run: | flake8 vessel_analysis_3d --count --verbose --show-source --statistics - - name: Check with black - run: | - black --check vessel_analysis_3d + #- name: Check with black + # run: | + # black --check vessel_analysis_3d publish: if: "contains(github.event.head_commit.message, 'Bump version')" @@ -68,12 +68,11 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel + pip install build - name: Build Package - run: | - python setup.py sdist bdist_wheel + run: python -m build - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@master with: - user: MMV-Lab + user: __token__ password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/test-and-lint.yml b/.github/workflows/test-and-lint.yml index eaf3a21..6c51041 100644 --- a/.github/workflows/test-and-lint.yml +++ b/.github/workflows/test-and-lint.yml @@ -19,7 +19,7 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install .[test] + pip install .[test] --verbose - name: Test with pytest run: | pytest vessel_analysis_3d/tests/ @@ -38,10 +38,10 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install .[test] + pip install .[test] --verbose - name: Lint with flake8 run: | flake8 vessel_analysis_3d --count --verbose --show-source --statistics - - name: Check with black - run: | - black --check vessel_analysis_3d + # - name: Check with black + # run: | + # black --check vessel_analysis_3d diff --git a/pyproject.toml b/pyproject.toml index 1576c0f..f67ee9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61.0"] +requires = ["setuptools>=64", "wheel"] build-backend = "setuptools.build_meta" [project] @@ -12,14 +12,13 @@ license = {file = "LICENSE"} authors = [ {name = "Jianxu Chen", email = "jianxuchen.ai@gmail.com"}, ] -keywords = ["vessel_analysis_3d"] +keywords = ["vessel analysis", "morphology", "topology"] classifiers = [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", "Natural Language :: English", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ] dependencies = [ "bioio==1.6.1", @@ -69,16 +68,51 @@ dev = [ "wheel>=0.34.2", ] +all = [ + "vessel_analysis_3d[dev]", + "vessel_analysis_3d[test]", + "vessel_analysis_3d[setup]", +] + [project.urls] Homepage = "https://github.com/MMV-Lab/vessel_analysis_3d" +[tool.setuptools] +include-package-data = true +zip-safe = false + +[tool.setuptools.packages.find] +include = ["vessel_analysis_3d"] + [project.scripts] run_vessel_analysis = "vessel_analysis_3d.bin.run_analysis:main" [tool.pytest.ini_options] -collect_ignore = ["setup.py"] +addopts = "--cov=vessel_analysis_3d --no-cov-on-fail --cov-report=term-missing --cov-report=xml --cov-branch --durations=10" +testpaths = [ + "vessel_analysis_3d/tests", +] +python_files = "test_*.py" + [tool.flake8] -exclude = ["docs/"] -ignore = ["E203", "E402", "W291", "W503", "E501"] -max-line-length = 88 +exclude = [ + "docs/", + ".git/", + "__pycache__/", + "build/", + "dist/", + ".venv/", + ".tox/", + "*.egg-info/", +] +ignore = [ + "E203", + "E402", + "W291", + "W503", + "W293", + "W292", + "E501", +] +max-line-length = 88 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 30135c5..056496b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,13 +3,13 @@ current_version = 0.0.1 commit = True tag = True -[bumpversion:file:setup.py] -search = version="{current_version}" -replace = version="{new_version}" +[bumpversion:file:pyproject.toml] +search = version = "{current_version}" +replace = version = "{new_version}" [bumpversion:file:vessel_analysis_3d/__init__.py] -search = {current_version} -replace = {new_version} +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" ignore = E203, E402, W291, W503, W293, W292, E501 max-line-length = 88 diff --git a/setup.py b/setup.py deleted file mode 100644 index fb5c716..0000000 --- a/setup.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -"""The setup script.""" - -from setuptools import find_packages, setup - -with open("README.md") as readme_file: - readme = readme_file.read() - - -setup( - long_description=readme, - long_description_content_type="text/markdown", - include_package_data=True, - packages=find_packages(exclude=["tests", "*.tests", "*.tests.*"]), - test_suite="vessel_analysis_3d/tests", - version="0.0.1", - zip_safe=False, -)