From 2cb1b77e3faca44089f483ad323656b5aa01f985 Mon Sep 17 00:00:00 2001 From: athril Date: Mon, 22 Jan 2024 22:18:13 -0500 Subject: [PATCH 01/20] chore: expanding CI by adding coverage report --- .github/workflows/CI.yml | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5faf31d..4db71e7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,19 +1,23 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions -name: CI +name: CI on: - [push] - + push: + tags: + - 'v*' # Execute if version is tagged + branches: + - main # Or if it is push to main + pull_request: # Or if it is any pull_request + workflow_call: # Or if the call comes from another workflow (reusability) + permissions: contents: read jobs: build: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - name: Set up Python 3.10 @@ -36,21 +40,19 @@ jobs: - name: Generate coverage report run: | PYTHONPATH=src - pytest --cov=./src tests/ + pytest --cov=./src tests/ --cov-report term --cov-report=xml:coverage.xml - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: verbose: true - - name: Install pypa/build - run: >- - python -m - pip install - build - --user - - name: Build a binary wheel and a source tarball - run: >- - python -m - build - --sdist - --wheel - --outdir dist/ + directory: ./coverage/reports/ + env_vars: OS,PYTHON + fail_ci_if_error: true + files: ./coverage.xml + flags: unittests + name: codecov-umbrella +# token: ${{ secrets.CODECOV_TOKEN }} + - name: Check if the package builds + run: | + python -m pip install -U pip build + python -m build From ff59969313c37a548282e64a0f9e476d77b444a5 Mon Sep 17 00:00:00 2001 From: athril Date: Mon, 22 Jan 2024 22:18:42 -0500 Subject: [PATCH 02/20] chore: adding protection for sphinx workflow --- .github/workflows/sphinx.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 0ebbc75..5be410a 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -1,10 +1,21 @@ name: Sphinx build -on: push +on: + push: + branches: + - main # Run if it is a push to main + pull_request: + branches: + - main # Or if it is a pull request to main jobs: + check: + uses: ./.github/workflows/CI.yml + build: + needs: check runs-on: ubuntu-latest + steps: - uses: actions/checkout@v3 - name: Set up Python 3.10 From 08683bb2a0f00f11f0898978e96236ce26f7c479 Mon Sep 17 00:00:00 2001 From: athril Date: Mon, 22 Jan 2024 22:20:31 -0500 Subject: [PATCH 03/20] chore: an automated pipeline to release new version on Github and PyPI --- .github/workflows/release.yml | 92 +++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3b700f7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,92 @@ +# Build the package, release new version and publish it to PyPI after tests pass +# References: +# - https://discourse.jupyter.org/t/use-github-workflows-to-automatically-publish-to-pypi-when-new-tags-are-created/14941/2 +# - https://dev.to/this-is-learning/manually-trigger-a-github-action-with-workflowdispatch-3mga +# - https://maciek.land/blog/automatic-releases-with-github-actions +# - https://www.loopwerk.io/articles/2021/automating-changelog/ + + +name: Release new version +on: + workflow_dispatch: + inputs: + version: + description: "Please specify version, e.g.: v0.3.5" + default: "v0.0.0" +jobs: + verify: + runs-on: ubuntu-latest + steps: + - name: Check permissions + uses: actions-cool/check-user-permission@v2 + id: checkUser + with: + require: 'admin' + check: + needs: verify + uses: ./.github/workflows/CI.yml +# if: steps.checkUser.outputs.check-result == 'true' + publish: + needs: check + runs-on: ubuntu-latest + steps: + - name: Set up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Checkout source + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure git user + run: | + git config user.email "actions-bot@github.com" + git config user.name "GitHub Actions (run by ${{ github.actor }})" + + - name: Tag commit + uses: tvdias/github-tagger@v0.0.2 + with: + repo-token: ${{ github.token }} + tag: ${{ github.event.inputs.version }} + + - name: Update CHANGELOG + id: changelog + uses: requarks/changelog-action@v1 + with: + token: ${{ github.token }} + tag: ${{ github.event.inputs.version }} + + - name: Commit and push CHANGELOG.md + uses: EndBug/add-and-commit@v9 + with: + add: CHANGELOG.md + message: "chore: Update CHANGELOG.md" + pull: '--rebase --autostash' + tag: '-a ${{ github.event.inputs.version }} -m ${{ github.event.inputs.version }} --force' + tag_push: '--force' + + - name: Build package + run: | + python -m pip install -U pip build + python -m build + + - name: Publish Distribution to PyPI + uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + skip_existing: true + + - name: Create Release + uses: ncipollo/release-action@v1.13.0 + with: + allowUpdates: true + draft: false + makeLatest: true + name: ${{ github.event.inputs.version }} + tag: ${{ github.event.inputs.version }} + body: ${{ steps.changelog.outputs.changes }} + token: ${{ github.token }} From ee0791851daea7d0ea0dd48a3db5bfee96fbefaa Mon Sep 17 00:00:00 2001 From: athril Date: Mon, 22 Jan 2024 22:29:09 -0500 Subject: [PATCH 04/20] chore: dynamic versioning of PyPI package with setuptools_scm --- .gitignore | 3 +++ pyproject.toml | 13 +++++++------ src/sparc/client/__init__.py | 5 +---- tests/test_package.py | 4 ++++ 4 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 tests/test_package.py diff --git a/.gitignore b/.gitignore index 258d391..690f01c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,9 @@ share/python-wheels/ *.egg MANIFEST +# dynamic versioning of version +src/sparc/client/_version.py + # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. diff --git a/pyproject.toml b/pyproject.toml index 189bc03..4f227e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "sparc.client" -version = "0.2.0" +dynamic = ["version"] description = "NIH SPARC Python Client" readme = "README.md" requires-python = ">=3.10" @@ -46,13 +46,11 @@ test = [ "responses", ] - [project.urls] homepage = "https://sparc.science" -documentation = "https://github.com/nih-sparc/sparc.client/README.md" +documentation = "https://github.com/nih-sparc/sparc.client/blob/main/README.md" repository = "https://github.com/nih-sparc/sparc.client" -changelog = "https://github.com/nih-sparc/sparc.client/CHANGELOG.md" - +changelog = "https://github.com/nih-sparc/sparc.client/blob/main/CHANGELOG.md" [tool.black] line-length = 99 @@ -79,9 +77,12 @@ where = ["src", "config"] "*" = ["*.ini", "*.txt"] [build-system] -requires = ["setuptools", "pennsieve2", "cmlibs.zinc", "cmlibs.utils", "scaffoldmaker", "mbfxml2ex"] +requires = ["setuptools>=64", "setuptools-scm>=8.0", "pennsieve2", "cmlibs.zinc", "cmlibs.utils", "scaffoldmaker", "mbfxml2ex"] build-backend = "setuptools.build_meta" +[tool.setuptools_scm] +version_file = "src/sparc/client/_version.py" + [tool.pytest.ini_options] addopts = "-ra -q" testpaths = [ diff --git a/src/sparc/client/__init__.py b/src/sparc/client/__init__.py index 4b5e4f9..64d2cbe 100644 --- a/src/sparc/client/__init__.py +++ b/src/sparc/client/__init__.py @@ -1,10 +1,7 @@ from .client import SparcClient +from ._version import __version__ __all__: tuple[str, ...] = [ "SparcClient", # "services.pennsieve.PennsieveService" ] - - -# import pkg_resources -# __version__ = pkg_resources.get_distribution("sparc.client").version diff --git a/tests/test_package.py b/tests/test_package.py new file mode 100644 index 0000000..f13dbf6 --- /dev/null +++ b/tests/test_package.py @@ -0,0 +1,4 @@ +import sparc.client + +def test_version(): + assert sparc.client.__version__ From f31c5c08ac122db7ec6c5919bf061278fe8fdd69 Mon Sep 17 00:00:00 2001 From: athril Date: Mon, 22 Jan 2024 22:34:19 -0500 Subject: [PATCH 05/20] docs: preparing CHANGELOG.md for automated updates within new release workflow based on semantic versioning --- CHANGELOG.md | 110 +++++++++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5c7493..406a09f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,51 +1,67 @@ -v0.2.0 -====== -New functionalities: -* Added O2SparcService service: - * Introduced a `O2SparcSolver` class which is the main class for running computational jobs on o²S²PARC. This class holds the following methods: - * `submit_job` - * `get_job_progress` - * `job_done` - * `get_results` - * `get_job_log` -* Introduced `get_solver` method to `O2SparcService` which returns a `O2SparcSolver` object -* Scaffold Retrieval: - * Introducing the ability to use `sparc.client` to retrieve scaffolds or scaffold descriptions. - * The retrieved scaffold or scaffold description files can now be converted to a commonly used mesh format, such as VTK. - * Reuse of packages from the mapping tools codebase ensures efficient and standardized mesh conversion. -* MBF Segmentation Export: - * Added support for exporting MBF Segmentation data to a commonly used mesh format, like VTK. -* Segmentation Data Analysis: - * New functionality to analyze a given segmentation data file for suitability in the mapping tools fitting workflow, and provide a clear and informative report. -* Updated Documentation: - * Added the [SPARC Python Zinc Client tutorial](https://github.com/nih-sparc/sparc.client/blob/main/docs/tutorial-zinc.ipynb) to reflect the features related to Zinc. - - -v0.1.0 -====== -Fixes: -* download multiple files from Pennsieve #12 -* pennsieve Download file API #14 -* Github action updates: Reviewdog should run whenever a PR is modified after opening #15 -* new tutorial in Jupyter Notebook -* README.md update - - -v0.0.2 -====== +# CHANGELOG + +## [v0.2.0] + +### :sparkles: New features + +- Added O2SparcService service: + + * Introduced a `O2SparcSolver` class which is the main class for running computational jobs on o²S²PARC. This class holds the following methods: + * `submit_job` + * `get_job_progress` + * `job_done` + * `get_results` + * `get_job_log` + +- Introduced `get_solver` method to `O2SparcService` which returns a `O2SparcSolver` object + +- Scaffold Retrieval: + + * Introducing the ability to use `sparc.client` to retrieve scaffolds or scaffold descriptions. + * The retrieved scaffold or scaffold description files can now be converted to a commonly used mesh format, such as VTK. + * Reuse of packages from the mapping tools codebase ensures efficient and standardized mesh conversion. + +- MBF Segmentation Export: + + * Added support for exporting MBF Segmentation data to a commonly used mesh format, like VTK. + +- Segmentation Data Analysis: + + * New functionality to analyze a given segmentation data file for suitability in the mapping tools fitting workflow, and provide a clear and informative report. + +- Updated Documentation: + + * Added the [SPARC Python Zinc Client tutorial](https://github.com/nih-sparc/sparc.client/blob/main/docs/tutorial-zinc.ipynb) to reflect the features related to Zinc. + + +## [v0.1.0] + +### :bug: Bug Fixes + +- download multiple files from Pennsieve #12 +- pennsieve Download file API #14 +- Github action updates: Reviewdog should run whenever a PR is modified after opening #15 +- new tutorial in Jupyter Notebook +- README.md update + +## [v0.0.2] + Alpha2 release of Python Sparc Client. -Major updates: -* Code coverage at 100% -* Sphinx documentation with Github Pages +### :sparkles: New features + +- Code coverage at 100% +- Sphinx documentation with Github Pages + +## [v0.0.1] -v0.0.1 -====== Alpha release of Python Sparc Client. -Basic functionalities: -* automatic/manual module loading -* ServiceBase class for adding new modules -* Pennsieve module with basic functionalities: - * listing datasets, files, records - * downloading files - * Basic API support (GET/POST) \ No newline at end of file + +### :sparkles: New features + +- automatic/manual module loading +- ServiceBase class for adding new modules +- Pennsieve module with basic functionalities: + * listing datasets, files, records + * downloading files + * Basic API support (GET/POST) From a58bcd11e458eb379910a744893a7bef9f2e8820 Mon Sep 17 00:00:00 2001 From: athril Date: Mon, 22 Jan 2024 22:34:51 -0500 Subject: [PATCH 06/20] docs: updating documentation on releasing new versions --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/README.md b/README.md index 3d3479a..1774a7c 100644 --- a/README.md +++ b/README.md @@ -94,3 +94,48 @@ Run `pip install -e '.[test]'` to install the dependencies needed for a developm Run `pytest --cov=./src` to run the tests and get a test coverage summary. Run `pytest --cov-report html --cov=./src` to run the tests and get a full HTML coverage report output to `htmlcov`. + +Run `python -m build` to check if your package builds successfully. + + +The process is currently automated using Github Action in CI.yml. + + +# Software releasing guidelines + +The process of releasing new version of the software is fully automated. + +This means that `CHANGELOG.md` as well as release commands are automatically generated. + +The versioning is fully dynamic using git tags. + +Please also note that there is no package/software version pyproject.toml. We use dynamic versioning provided by setuptools_scm + + +Also file sparc.client/_version.py should not be committed to the repository. + + + +## How commits should look like? + +We are using [Semantic Commit Messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716) for commits. + +Basically this means that important commits should start with one of the following prefixes: *chore:*, *docs:*, *feat:*, *fix:*, *refactor:*, *style:*, or *test:*. + +Additionally, we ask to refer to the issue number on Github (by adding a reference, e.g. `#24234`) +[Refer to issues](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls) + + +## Releasing a new version + + +1. In order to release a new version, an action 'Create new release' needs to be launched from Github Actions menu. +Please navigate to 'Actions' and click 'Create new release' on the left hand side. On the right hand side, you can click 'Run workflow' + +2. After launching a workflow, specify manually a version. The version needs to start with 'v', e.g. 'v0.0.34'. + +3. Launching a workflow checks for the user permission (needs to be admin to the repository) and runs CI in order to verify integrity of the software. + +4. If the CI/CD test passes, a temporary tag is created. The commits which follow the symantic versioning naming convention are then used to create and update CHANGELOG.md. + +5. Once CHANGELOG.md is pushed to the main branch, the new version is tagged again and the software is released to Github and to PyPI. From 24769769311ba932254d24f47943e2ee114d38aa Mon Sep 17 00:00:00 2001 From: athril Date: Mon, 22 Jan 2024 23:09:37 -0500 Subject: [PATCH 07/20] chore^Creleasing to PyPI --- .github/workflows/release.yml | 18 +++++++++++++++--- .gitignore | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b700f7..089a9ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,6 +29,12 @@ jobs: publish: needs: check runs-on: ubuntu-latest + +# # Specifying a GitHub environment for PyPI release is optional, but strongly encouraged +# environment: release +# permissions: +# # IMPORTANT: this permission is mandatory for trusted publishing on PyPI +# id-token: write steps: - name: Set up Python 3.10 uses: actions/setup-python@v4 @@ -72,13 +78,19 @@ jobs: python -m pip install -U pip build python -m build +# - name: Publish Distribution to TestPyPI +# uses: pypa/gh-action-pypi-publish@v1.5.0 +# with: +# user: __token__ +# password: ${{ secrets.TEST_PYPI_TOKEN }} +# repository_url: https://test.pypi.org/legacy/ +# skip_existing: true + - name: Publish Distribution to PyPI uses: pypa/gh-action-pypi-publish@v1.5.0 with: user: __token__ - password: ${{ secrets.TEST_PYPI_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - skip_existing: true + password: ${{ secrets.PYPI_TOKEN }} - name: Create Release uses: ncipollo/release-action@v1.13.0 diff --git a/.gitignore b/.gitignore index 690f01c..50c9ac0 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,7 @@ share/python-wheels/ *.egg MANIFEST -# dynamic versioning of version +# dynamic versioning in _version.py (automatically built for PyPI only) src/sparc/client/_version.py # PyInstaller From 37431b42ead4eae38d8adbacafabb78bbb82f292 Mon Sep 17 00:00:00 2001 From: athril Date: Tue, 23 Jan 2024 12:43:30 -0500 Subject: [PATCH 08/20] chore: fixing PyPI deployment --- .github/workflows/release.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 089a9ec..d358122 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,11 +30,15 @@ jobs: needs: check runs-on: ubuntu-latest -# # Specifying a GitHub environment for PyPI release is optional, but strongly encouraged -# environment: release -# permissions: + # Specifying a GitHub environment for PyPI release is optional, but strongly encouraged + environment: + name: pypi + url: https://pypi.org/p/sparc.client + permissions: # # IMPORTANT: this permission is mandatory for trusted publishing on PyPI -# id-token: write + id-token: write + contents: write + packages: write steps: - name: Set up Python 3.10 uses: actions/setup-python@v4 @@ -87,10 +91,10 @@ jobs: # skip_existing: true - name: Publish Distribution to PyPI - uses: pypa/gh-action-pypi-publish@v1.5.0 - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} + uses: pypa/gh-action-pypi-publish@release/v1 +# with: #not needed with new PyPI publishing +# user: __token__ +# password: ${{ secrets.PYPI_TOKEN }} - name: Create Release uses: ncipollo/release-action@v1.13.0 From b485c9e6c3d827a9abe1f0f1ab95e981e5ff31aa Mon Sep 17 00:00:00 2001 From: athril Date: Wed, 24 Jan 2024 11:13:24 -0500 Subject: [PATCH 09/20] chore: removing commented lines --- .github/workflows/CI.yml | 8 +++++++- .github/workflows/black-action.yml | 1 + .github/workflows/release.yml | 15 ++------------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4db71e7..deda39b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -20,27 +20,33 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Set up Python 3.10 uses: actions/setup-python@v3 with: python-version: "3.10" + - name: Setup OpenGL run: | sudo apt-get install libopengl0 libglu1-mesa + - name: Install dependencies run: | python -m pip install --upgrade pip pip install -e '.[test]' + - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Generate coverage report run: | PYTHONPATH=src pytest --cov=./src tests/ --cov-report term --cov-report=xml:coverage.xml + - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: @@ -51,7 +57,7 @@ jobs: files: ./coverage.xml flags: unittests name: codecov-umbrella -# token: ${{ secrets.CODECOV_TOKEN }} + - name: Check if the package builds run: | python -m pip install -U pip build diff --git a/.github/workflows/black-action.yml b/.github/workflows/black-action.yml index 704a312..5587317 100644 --- a/.github/workflows/black-action.yml +++ b/.github/workflows/black-action.yml @@ -11,6 +11,7 @@ jobs: id: action_black with: black_args: "." + - name: Annotate diff changes using reviewdog if: steps.action_black.outputs.is_formatted == 'true' uses: reviewdog/action-suggester@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d358122..55760a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: check: needs: verify uses: ./.github/workflows/CI.yml -# if: steps.checkUser.outputs.check-result == 'true' + publish: needs: check runs-on: ubuntu-latest @@ -35,7 +35,7 @@ jobs: name: pypi url: https://pypi.org/p/sparc.client permissions: -# # IMPORTANT: this permission is mandatory for trusted publishing on PyPI + # IMPORTANT: this permission is mandatory for trusted publishing on PyPI id-token: write contents: write packages: write @@ -82,19 +82,8 @@ jobs: python -m pip install -U pip build python -m build -# - name: Publish Distribution to TestPyPI -# uses: pypa/gh-action-pypi-publish@v1.5.0 -# with: -# user: __token__ -# password: ${{ secrets.TEST_PYPI_TOKEN }} -# repository_url: https://test.pypi.org/legacy/ -# skip_existing: true - - name: Publish Distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 -# with: #not needed with new PyPI publishing -# user: __token__ -# password: ${{ secrets.PYPI_TOKEN }} - name: Create Release uses: ncipollo/release-action@v1.13.0 From 65e0c7528803a3d1292526830574213c1f2b55bd Mon Sep 17 00:00:00 2001 From: athril Date: Wed, 24 Jan 2024 11:52:19 -0500 Subject: [PATCH 10/20] chore: limiting scope of Sphinx workflow launch --- .github/workflows/sphinx.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 5be410a..daa4b91 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -4,9 +4,6 @@ on: push: branches: - main # Run if it is a push to main - pull_request: - branches: - - main # Or if it is a pull request to main jobs: check: From 676b1f9f7d34a661c03fd62b0d11fde48a16e938 Mon Sep 17 00:00:00 2001 From: athril Date: Wed, 24 Jan 2024 12:46:22 -0500 Subject: [PATCH 11/20] chore: adding CODECOV token to prepare for codecov-action@v4 (currently in beta) --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index deda39b..35c5385 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -57,6 +57,7 @@ jobs: files: ./coverage.xml flags: unittests name: codecov-umbrella + token: ${{ secrets.CODECOV_TOKEN }} - name: Check if the package builds run: | From 7341eaebf1323a1aa98150038b321d6da190f42b Mon Sep 17 00:00:00 2001 From: athril Date: Thu, 25 Jan 2024 11:43:11 -0500 Subject: [PATCH 12/20] chore: fixing reviewdog permissions --- .github/workflows/reviewdog.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index d44fadb..df97220 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -6,8 +6,14 @@ on: jobs: reviewdog: + runs-on: ubuntu-latest + permissions: + contents: read + checks: write + pull-requests: read + steps: - name: Checkout @@ -21,12 +27,14 @@ jobs: run: | python -m pip install -U pip pip install --progress-bar off -U .[checking] + - name: Apply formatters run: | pip install black blackdoc isort black . blackdoc . isort . + - name: Reviewdog uses: reviewdog/action-suggester@v1 with: From 4119d2ebf0bad418895f505704d3b36da5fb376c Mon Sep 17 00:00:00 2001 From: athril Date: Thu, 25 Jan 2024 11:49:58 -0500 Subject: [PATCH 13/20] chore: fixing reviewdog permissions --- .github/workflows/reviewdog.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index df97220..1211e7e 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -12,12 +12,13 @@ jobs: permissions: contents: read checks: write - pull-requests: read + issues: write + pull-requests: write steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: actions/setup-python@v3 with: From 2afa0eb4ca6260ce1438d6bceb796c7b90a2d6c2 Mon Sep 17 00:00:00 2001 From: athril Date: Thu, 25 Jan 2024 12:02:16 -0500 Subject: [PATCH 14/20] chore: fixing reviewdog permissions --- .github/workflows/reviewdog.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 1211e7e..a7bb52a 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -16,7 +16,6 @@ jobs: pull-requests: write steps: - - name: Checkout uses: actions/checkout@v4 @@ -40,3 +39,5 @@ jobs: uses: reviewdog/action-suggester@v1 with: tool_name: formatters + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review \ No newline at end of file From ea660848a269fb9b842c2db2e42a0d586ab23886 Mon Sep 17 00:00:00 2001 From: athril Date: Thu, 25 Jan 2024 12:44:17 -0500 Subject: [PATCH 15/20] chore: reviewdog permissions --- .github/workflows/reviewdog.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index a7bb52a..73abf84 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -10,7 +10,8 @@ jobs: runs-on: ubuntu-latest permissions: - contents: read + id-token: write + contents: write checks: write issues: write pull-requests: write @@ -19,7 +20,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v5 with: python-version: '3.10' @@ -40,4 +41,3 @@ jobs: with: tool_name: formatters github_token: ${{ secrets.GITHUB_TOKEN }} - reporter: github-pr-review \ No newline at end of file From b70d8672d202e25a7b74058a290063c3eb6eef9b Mon Sep 17 00:00:00 2001 From: athril Date: Thu, 25 Jan 2024 13:42:44 -0500 Subject: [PATCH 16/20] chore: reviewdog permissions --- .github/workflows/reviewdog.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 73abf84..cf61385 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -4,17 +4,18 @@ on: pull_request: types: [opened, edited, synchronize, review_requested, reopened] +permissions: + id-token: write + contents: write + checks: write + issues: write + pull-requests: write + jobs: reviewdog: runs-on: ubuntu-latest - permissions: - id-token: write - contents: write - checks: write - issues: write - pull-requests: write steps: - name: Checkout From e4457a1e783fdd4bdaad259de5b4e64f271ed20c Mon Sep 17 00:00:00 2001 From: athril Date: Fri, 26 Jan 2024 14:28:56 -0500 Subject: [PATCH 17/20] fix: no additional permissions needed, would need to run on vulnerable: pull_request_target --- .github/workflows/reviewdog.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index cf61385..60f1662 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -4,13 +4,6 @@ on: pull_request: types: [opened, edited, synchronize, review_requested, reopened] -permissions: - id-token: write - contents: write - checks: write - issues: write - pull-requests: write - jobs: reviewdog: From 38cc7c4b730b52e8176f3be17146acb10163d9bc Mon Sep 17 00:00:00 2001 From: athril Date: Fri, 26 Jan 2024 14:30:56 -0500 Subject: [PATCH 18/20] chore: fixing outdated versions of actions --- .github/workflows/CI.yml | 4 ++-- .github/workflows/black-action.yml | 2 +- .github/workflows/sphinx.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 35c5385..c4859a9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,10 +19,10 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.10 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.10" diff --git a/.github/workflows/black-action.yml b/.github/workflows/black-action.yml index 5587317..949d05e 100644 --- a/.github/workflows/black-action.yml +++ b/.github/workflows/black-action.yml @@ -5,7 +5,7 @@ jobs: name: runner / black runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check files using the black formatter uses: rickstaa/action-black@v1 id: action_black diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index daa4b91..0237417 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -14,9 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.10 - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: "3.10" - name: Build HTML From a8b17546d4988a2036df66451abb94c85b217740 Mon Sep 17 00:00:00 2001 From: athril Date: Fri, 26 Jan 2024 14:40:07 -0500 Subject: [PATCH 19/20] fix: code reformatting --- src/sparc/client/__init__.py | 2 +- src/sparc/client/zinchelper.py | 3 +-- tests/test_package.py | 1 + tests/test_zinc.py | 8 ++------ 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/sparc/client/__init__.py b/src/sparc/client/__init__.py index 64d2cbe..60c9188 100644 --- a/src/sparc/client/__init__.py +++ b/src/sparc/client/__init__.py @@ -1,5 +1,5 @@ -from .client import SparcClient from ._version import __version__ +from .client import SparcClient __all__: tuple[str, ...] = [ "SparcClient", diff --git a/src/sparc/client/zinchelper.py b/src/sparc/client/zinchelper.py index f31bb6a..353d1ca 100644 --- a/src/sparc/client/zinchelper.py +++ b/src/sparc/client/zinchelper.py @@ -19,8 +19,7 @@ from scaffoldmaker.annotation.lung_terms import get_lung_term from scaffoldmaker.annotation.muscle_terms import get_muscle_term from scaffoldmaker.annotation.nerve_terms import get_nerve_term -from scaffoldmaker.annotation.smallintestine_terms import \ - get_smallintestine_term +from scaffoldmaker.annotation.smallintestine_terms import get_smallintestine_term from scaffoldmaker.annotation.stellate_terms import get_stellate_term from scaffoldmaker.annotation.stomach_terms import get_stomach_term from scaffoldmaker.utils.exportvtk import ExportVtk diff --git a/tests/test_package.py b/tests/test_package.py index f13dbf6..6d4275e 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -1,4 +1,5 @@ import sparc.client + def test_version(): assert sparc.client.__version__ diff --git a/tests/test_zinc.py b/tests/test_zinc.py index a502401..6d7118b 100644 --- a/tests/test_zinc.py +++ b/tests/test_zinc.py @@ -12,9 +12,7 @@ def zinc(): def test_export_scaffold_into_vtk_format(zinc): # create a temporary output file - output_location = os.path.abspath( - os.path.join(os.path.dirname(__file__), "resources/") - ) + output_location = os.path.abspath(os.path.join(os.path.dirname(__file__), "resources/")) # ensure the function returns None if the dataset has no Scaffold_Creator-settings.json file invalid_dataset_id = 1000000 @@ -42,9 +40,7 @@ def test_export_scaffold_into_vtk_format(zinc): def test_export_scaffold_into_stl_format(zinc): # create a temporary output file - output_location = os.path.abspath( - os.path.join(os.path.dirname(__file__), "resources/") - ) + output_location = os.path.abspath(os.path.join(os.path.dirname(__file__), "resources/")) # ensure the function returns None if the dataset has no Scaffold_Creator-settings.json file invalid_dataset_id = 1000000 From 0a419f6f95b37669c5c8f44fb126c3e6aaae6351 Mon Sep 17 00:00:00 2001 From: athril Date: Fri, 26 Jan 2024 14:45:36 -0500 Subject: [PATCH 20/20] fix: reformatting back --- src/sparc/client/zinchelper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sparc/client/zinchelper.py b/src/sparc/client/zinchelper.py index 353d1ca..f31bb6a 100644 --- a/src/sparc/client/zinchelper.py +++ b/src/sparc/client/zinchelper.py @@ -19,7 +19,8 @@ from scaffoldmaker.annotation.lung_terms import get_lung_term from scaffoldmaker.annotation.muscle_terms import get_muscle_term from scaffoldmaker.annotation.nerve_terms import get_nerve_term -from scaffoldmaker.annotation.smallintestine_terms import get_smallintestine_term +from scaffoldmaker.annotation.smallintestine_terms import \ + get_smallintestine_term from scaffoldmaker.annotation.stellate_terms import get_stellate_term from scaffoldmaker.annotation.stomach_terms import get_stomach_term from scaffoldmaker.utils.exportvtk import ExportVtk