Skip to content

Commit 270d183

Browse files
committed
added NOTICE and other files to pkg-gen templatests
1 parent 5170a26 commit 270d183

File tree

5 files changed

+112
-6
lines changed

5 files changed

+112
-6
lines changed

nipype2pydra/pkg_gen/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,11 @@ def copy_ignore(_, names):
653653
with open(pkg_dir / "README.rst", "w") as f:
654654
f.write(readme_rst)
655655

656+
with open(pkg_dir / "AUTHORS", "w") as f:
657+
f.write("# Enter list of names and emails of contributors to this package")
658+
659+
shutil.copyfile(TEMPLATES_DIR / "NOTICE", pkg_dir / "NOTICE")
660+
656661
fileformat_readme_path = related_pkgs_dir / "fileformats" / "README.rst"
657662
with open(fileformat_readme_path) as f:
658663
ff_readme_rst = f.read()
@@ -678,6 +683,9 @@ def copy_ignore(_, names):
678683
with open(pkg_dir / "pyproject.toml", "w") as f:
679684
f.write(pyproject_toml)
680685

686+
for tool_path in (TEMPLATES_DIR / "tools").iterdir():
687+
shutil.copyfile(tool_path, pkg_dir / tool_path.name)
688+
681689
# Add "pydra.tasks.<pkg>.auto to gitignore"
682690
with open(pkg_dir / ".gitignore", "a") as f:
683691
f.write(f"\n/pydra/tasks/{pkg}/auto" f"\n/pydra/tasks/{pkg}/_version.py\n")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Pydra-CHANGEME
2+
Copyright 2024 Pydra Development Team
3+
4+
The bases for the task interfaces defined in this package were semi-automatically converted
5+
from Nipype interfaces (https://github.com/nipy/nipype) using the Nipype2Pydra tool
6+
(https://github.com/nipype/nipype2pydra).

nipype2pydra/pkg_gen/resources/templates/gh_workflows/ci-cd.yaml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
repository_dispatch:
1717
types: [create-post-release]
1818

19+
env:
20+
CHANGEME_version: <set-CHANGEME-version-here>
21+
CHANGEME_install_dir: ${{ github.workspace }}/install
22+
1923
jobs:
2024

2125
nipype-conv:
@@ -103,7 +107,7 @@ jobs:
103107
104108
test:
105109
needs: [nipype-conv]
106-
runs-on: ubuntu-22.04
110+
runs-on: ubuntu-latest
107111
strategy:
108112
matrix:
109113
python-version: ['3.8', '3.11']
@@ -117,14 +121,23 @@ jobs:
117121
- name: Checkout repo
118122
uses: actions/checkout@v4
119123

120-
- name: Revert version to most recent version tag on upstream update
124+
- name: Revert version to most recent version tag on Nipype or Nipype2Pydra update
121125
if: github.event_name == 'repository_dispatch'
122126
run: git checkout $(git tag -l | grep 'v.*' | tail -n 1 | awk -F post '{print $1}')
123127

128+
- name: Cache CHANGEME Install
129+
id: cache-install
130+
uses: actions/cache@v4
131+
with:
132+
path: ${{ env.CHANGEME_install_dir }}
133+
key: CHANGEME-${{ env.CHANGEME_version }}-${{ runner.os }}
134+
124135
- name: Install CHANGEME Package
136+
if: steps.cache-install.outputs.cache-hit != 'true'
125137
run: |
126-
echo "NOT IMPLEMENTED YET"
127-
exit 1 # This is a placeholder for the actual install command
138+
echo "NOT IMPLEMENTED YET (install at CHANGEME_install_dir: $CHANGEME_install_dir)"
139+
exit 1 # This is a placeholder, replace this line and the one above with the installation procedure
140+
echo "PATH=${{ env.CHANGEME_install_dir }}/bin:$PATH" >> $GITHUB_ENV
128141
129142
- name: Download tasks converted from Nipype
130143
uses: actions/download-artifact@v3
@@ -362,6 +375,31 @@ jobs:
362375
draft: false
363376
prerelease: false
364377

378+
379+
report_progress:
380+
needs: [deploy]
381+
runs-on: ubuntu-latest
382+
steps:
383+
384+
- name: Generate progress report
385+
id: generate-report
386+
run: |
387+
tools/report_progress.py outputs/progress-report.json
388+
echo "progress_report=$(cat outputs/progress-report.json)" >> $GITHUB_OUTPUT
389+
390+
- name: Report progress to Nipype2Pydra repo
391+
if: github.event_name == 'release' || github.event_name == 'repository_dispatch'
392+
run: >-
393+
curl -XPOST -u "${{ env.POST_RELEASE_PAT }}" -H "Accept: application/vnd.github.everest-preview+json"
394+
"https://api.github.com/repos/nipype/pydra-CHANGEME/dispatches"
395+
-d '{
396+
"event_type": "progress-report",
397+
"client_payload": ${{ steps.generate-report.output.progress_report }}
398+
}'
399+
env:
400+
PAT: ${{ env.PROGRESS_REPORT_PAT }}
401+
402+
365403
# Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets.
366404
# Secrets are not accessible in the if: condition [0], so set an output variable [1]
367405
# [0] https://github.community/t/16928
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
from pathlib import Path
3+
import json
4+
import yaml
5+
import click
6+
7+
8+
@click.command
9+
@click.argument(
10+
"out_json_path",
11+
type=click.Path(path_type=Path),
12+
help="The output path to save the report",
13+
)
14+
def report_progress(out_json_path: Path):
15+
16+
out_json_path.parent.mkdir(exist_ok=True, parents=True)
17+
18+
SPECS_DIR = Path(__file__).parent / "nipype-auto-conv" / "specs"
19+
20+
report = {}
21+
22+
for spec_path in SPECS_DIR.glob("*.yaml"):
23+
with open(spec_path) as f:
24+
spec = yaml.load(f, Loader=yaml.SafeLoader)
25+
26+
report[spec["task_name"]] = {
27+
n: not s["xfail"] for n, s in spec["tests"].items()
28+
}
29+
30+
with open(out_json_path, "w") as f:
31+
json.dump(report, f)

nipype2pydra/task/tests/test_task.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22
import yaml
33
import pytest
44
import logging
5-
from nipype2pydra.utils import show_cli_trace
5+
import io
6+
import contextlib
67
from traceback import format_exc
78
from nipype2pydra.cli.task import task as task_cli
8-
from nipype2pydra.utils import add_to_sys_path, add_exc_note, INBUILT_NIPYPE_TRAIT_NAMES
9+
from nipype2pydra.utils import (
10+
add_to_sys_path,
11+
add_exc_note,
12+
INBUILT_NIPYPE_TRAIT_NAMES,
13+
show_cli_trace,
14+
)
915
from conftest import EXAMPLE_TASKS_DIR
1016

1117

@@ -120,6 +126,23 @@ def test_task_conversion(task_spec_file, cli_runner, work_dir, gen_test_conftest
120126
)
121127
)
122128

129+
# Run doctests
130+
logging.info("Running doctests for %s", output_module_path)
131+
with add_to_sys_path(pkg_root):
132+
with contextlib.redirect_stdout(io.StringIO()) as f:
133+
exit_code = pytest.main(
134+
[
135+
str(
136+
pkg_root.joinpath(
137+
*output_module_path.split(".")
138+
).with_suffix(".py")
139+
),
140+
"--doctest-modules",
141+
"--ignore-glob=test_*.py",
142+
]
143+
)
144+
145+
assert not exit_code, f.getvalue()
123146
# tests_fspath = pkg_root.joinpath(*output_module_path.split(".")).parent / "tests"
124147

125148
# # logging.info("Running generated tests for %s", output_module_path)

0 commit comments

Comments
 (0)