Skip to content

Commit f60bf03

Browse files
authored
Merge pull request #14 from fractal-analytics-platform/add_task_metadata
Update template & add task metadata
2 parents d81a335 + a776fb7 commit f60bf03

10 files changed

+137
-74
lines changed

.copier-answers.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Do not edit - changes here will be overwritten by Copier
2-
_commit: v0.3.0
2+
_commit: v0.4.2
33
_src_path: gh:fractal-analytics-platform/fractal-tasks-template
44
author_email: [email protected]
55
author_name: Joel Luethi

.github/workflows/build_and_test.yml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: CI (build and test)
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
tags:
7+
- "*"
8+
pull_request:
9+
branches: ["main"]
10+
11+
12+
jobs:
13+
tests:
14+
strategy:
15+
matrix:
16+
os: [ubuntu-22.04, macos-latest]
17+
python-version: ["3.9", "3.10", "3.11"]
18+
exclude:
19+
- os: macos-latest
20+
python-version: '3.9'
21+
- os: macos-latest
22+
python-version: '3.10'
23+
name: "Core, Python ${{ matrix.python-version }}, ${{ matrix.os }}"
24+
runs-on: ${{ matrix.os }}
25+
timeout-minutes: 30
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 1
31+
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
cache: "pip"
37+
38+
- name: Install package
39+
run: python -m pip install -e .[dev]
40+
41+
- name: Install some testing dependencies (hard-coded)
42+
run: python -m pip install pytest pytest-cov devtools jsonschema requests wget pooch
43+
44+
- name: Regenerate the manifest
45+
run: python src/fractal_helper_tasks/dev/create_manifest.py
46+
47+
- name: Cache Pooch folder
48+
id: cache-pooch-folder
49+
uses: actions/cache@v3
50+
with:
51+
path: ~/.cache/pooch
52+
key: pooch-cache
53+
54+
- name: Check if manifest has changed
55+
run: |
56+
if [ -n "$(git diff --exit-code ./src/fractal_helper_tasks/__FRACTAL_MANIFEST__.json)" ]; then
57+
echo "__FRACTAL_MANIFEST__.json has changed. Please run 'python src/fractal_helper_tasks/dev/create_manifest.py' and commit the changes."
58+
exit 1
59+
else
60+
echo "__FRACTAL_MANIFEST__.json has not changed."
61+
fi
62+
63+
- name: Test tasks with pytest
64+
run: pytest --color=yes --cov --cov-report=xml --cov-report=term-missing -s --log-cli-level debug
65+
66+
- name: Upload coverage reports to Codecov
67+
uses: codecov/[email protected]
68+
with:
69+
token: ${{ secrets.CODECOV_TOKEN }}
70+
slug: jluethi/fractal-helper-tasks
71+
72+
deploy:
73+
name: Deploy
74+
needs: tests
75+
if: success() && startsWith(github.ref, 'refs/tags/') && github.event_name != 'schedule'
76+
runs-on: ubuntu-latest
77+
78+
permissions:
79+
# IMPORTANT: this permission is mandatory for trusted publishing on PyPi
80+
# see https://docs.pypi.org/trusted-publishers/
81+
id-token: write
82+
# This permission allows writing releases
83+
contents: write
84+
85+
steps:
86+
- uses: actions/checkout@v4
87+
with:
88+
fetch-depth: 0
89+
90+
- name: 🐍 Set up Python
91+
uses: actions/setup-python@v5
92+
with:
93+
python-version: "3.x"
94+
95+
- name: 👷 Build
96+
run: |
97+
python -m pip install build
98+
python -m build
99+
100+
- name: 🚢 Publish to PyPI
101+
# TODO remove the "if: false" line when the package is ready for pypi release
102+
if: false
103+
uses: pypa/gh-action-pypi-publish@release/v1
104+
105+
- uses: softprops/action-gh-release@v2
106+
with:
107+
generate_release_notes: true
108+
files: './dist/*'

.github/workflows/ci_pip.yml

-52
This file was deleted.

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Git ignored is sourced from https://github.com/pydev-guide/pyrepo-copier/blob/main/LICENSE
12
# Byte-compiled / optimized / DLL files
23
__pycache__/
34
*.py[cod]
@@ -108,4 +109,4 @@ ENV/
108109

109110
# IDE settings
110111
.vscode/
111-
.idea/
112+
.idea/

pyproject.toml

+2-8
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@ build-backend = "hatchling.build"
55

66
# https://hatch.pypa.io/latest/config/metadata/
77
[tool.hatch.version]
8-
#path = "src/fractal_helper_tasks/__init__.py"
98
source = "vcs"
109

1110
# read more about configuring hatch at:
1211
# https://hatch.pypa.io/latest/config/build/
1312
[tool.hatch.build.targets.wheel]
14-
only-include = ["src"]
15-
sources = ["src"]
16-
17-
# Always include the __FRACTAL_MANIFEST__.json file in the package
18-
[tool.hatch.build]
19-
include = ["__FRACTAL_MANIFEST__.json"]
13+
packages = ["src/fractal_helper_tasks"]
2014

2115

2216
# Project metadata (see https://peps.python.org/pep-0621)
@@ -33,7 +27,7 @@ authors = [
3327
# Required Python version and dependencies
3428
requires-python = ">=3.9"
3529
dependencies = [
36-
"fractal-tasks-core==1.2.0"
30+
"fractal-tasks-core==1.3.3"
3731
]
3832

3933
# Optional dependencies (e.g. for `pip install -e ".[dev]"`, see

src/fractal_helper_tasks/__FRACTAL_MANIFEST__.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"output_types": {
77
"has_t": false
88
},
9+
"tags": [
10+
"Singelton time dimension"
11+
],
912
"executable_non_parallel": "drop_t_dimension.py",
1013
"meta_non_parallel": {
1114
"cpus_per_task": 2,
@@ -45,6 +48,10 @@
4548
"input_types": {
4649
"is_3D": false
4750
},
51+
"tags": [
52+
"Mixed modality",
53+
"2D to 3D workflows"
54+
],
4855
"executable_parallel": "convert_2D_segmentation_to_3D.py",
4956
"meta_parallel": {
5057
"cpus_per_task": 2,
@@ -122,5 +129,6 @@
122129
}
123130
],
124131
"has_args_schemas": true,
125-
"args_schema_version": "pydantic_v2"
132+
"args_schema_version": "pydantic_v2",
133+
"authors": "Joel Luethi"
126134
}

src/fractal_helper_tasks/dev/create_manifest.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
to the package manifest.
88
"""
99
PACKAGE = "fractal_helper_tasks"
10-
create_manifest(package=PACKAGE)
10+
AUTHORS = "Joel Luethi"
11+
create_manifest(package=PACKAGE, authors=AUTHORS)

src/fractal_helper_tasks/dev/task_list.py

+5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88
executable="drop_t_dimension.py",
99
meta={"cpus_per_task": 2, "mem": 8000},
1010
output_types=dict(has_t=False),
11+
tags=["Singelton time dimension"],
1112
),
1213
ParallelTask(
1314
input_types=dict(is_3D=False),
1415
name="Convert 2D segmentation to 3D",
1516
executable="convert_2D_segmentation_to_3D.py",
1617
meta={"cpus_per_task": 2, "mem": 8000},
18+
tags=[
19+
"Mixed modality",
20+
"2D to 3D workflows",
21+
],
1722
),
1823
]

tests/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import fractal_helper_tasks
21
import json
32
from pathlib import Path
43

4+
import fractal_helper_tasks
55

66
PACKAGE = "fractal_helper_tasks"
77
PACKAGE_DIR = Path(fractal_helper_tasks.__file__).parent

tests/test_valid_task_interface.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import json
22
import subprocess
33
from shlex import split as shlex_split
4-
from subprocess import PIPE
54

65
import pytest
76
from devtools import debug
@@ -16,22 +15,21 @@ def validate_command(cmd: str):
1615
debug(cmd)
1716
result = subprocess.run( # nosec
1817
shlex_split(cmd),
19-
stdout=PIPE,
20-
stderr=PIPE,
18+
capture_output=True,
2119
)
2220
# The command must always fail, since tmp_file_args includes invalid
2321
# arguments
2422
assert result.returncode == 1
2523
stderr = result.stderr.decode()
2624
debug(stderr)
2725

28-
# Valid stderr includes pydantic.error_wrappers.ValidationError (type
26+
# Valid stderr includes pydantic.v1.error_wrappers.ValidationError (type
2927
# match between model and function, but tmp_file_args has wrong arguments)
30-
# assert "pydantic.v1.error_wrappers.ValidationError" in stderr
28+
assert "ValidationError" in stderr
3129

32-
# # Valid stderr must include a mention of "unexpected keyword arguments",
33-
# # because we are including some invalid arguments
34-
# assert "unexpected keyword arguments" in stderr
30+
# Valid stderr must include a mention of "Unexpected keyword argument",
31+
# because we are including some invalid arguments
32+
assert "Unexpected keyword argument" in stderr
3533

3634
# # Invalid stderr includes ValueError
3735
# assert "ValueError" not in stderr
@@ -46,7 +44,7 @@ def test_task_interface(task, tmp_path):
4644
tmp_file_args = str(tmp_path / "args.json")
4745
tmp_file_metadiff = str(tmp_path / "metadiff.json")
4846
with open(tmp_file_args, "w") as fout:
49-
args = dict(wrong_arg_1=123, wrong_arg_2=[1, 2, 3])
47+
args = {"wrong_arg_1": 123, "wrong_arg_2": [1, 2, 3]}
5048
json.dump(args, fout, indent=4)
5149

5250
for key in ["executable_non_parallel", "executable_parallel"]:

0 commit comments

Comments
 (0)