-
Notifications
You must be signed in to change notification settings - Fork 40
88 lines (78 loc) · 3.23 KB
/
find-all-tools.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Find All Tools
on:
workflow_call:
outputs:
matrix:
description: 'Matrix of tools to test'
value: ${{ jobs.find-tools.outputs.matrix }}
permissions:
contents: read
jobs:
find-tools:
name: Find all tools
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: 'PolusAI/image-tools'
ref: 'master'
- name: Find tools
id: set-matrix
run: |
# List of directories to ignore
ignored_dirs="polus-python-template ftl-label .venv"
# List of tools that are broken for known reasons
broken_tools="binary-operations precompute-slide microjson-to-ome region-segmentation-eval basic-flatfield-estimation ftl-label cell-border-segmentation"
# Reasons:
# - binary-operations: Not fully updated to new tool standards
# - precompute-slide (Najib): Single failing test: 1023_1024_Segmentation_Zarr
# - microjson-to-ome (Hamdah): AttributeError: type object 'SerializerConfig' has no attribute '__slots__'
# - region-segmentation-eval: Installation error with numba.
# - basic-flatfield-estimation: Jax installation error.
# - ftl-label: Requires Rust installation. Also, has not been updated to new tool standards.
# - cell-border-segmentation (Hamdah): keras.models.load_model() is getting incorrect model format error.
# Initialize variables
ignored_dirs="$ignored_dirs $broken_tools"
ignored_dirs=$(echo $ignored_dirs | xargs)
tool_dirs=""
# Get all sub-directories in the current directory
dirs=$(find $(pwd) -type d)
# Get all directories that have a "pyproject.toml" file
for dir in $dirs; do
# Ignore the current directory
if [ "$dir" == "$(pwd)" ]; then
continue
fi
# Ignore the directory if it contains any of the substrings in "ignored_dirs"
for ignored_dir in $ignored_dirs; do
if [[ "$dir" == *"$ignored_dir"* ]]; then
continue 2
fi
done
# If the directory contains a "pyproject.toml" file, then add it to the list of tools
if [ -f "$dir/pyproject.toml" ]; then
tool_dirs="$tool_dirs $dir"
fi
done
# Remove leading and trailing spaces
tool_dirs=$(echo $tool_dirs | xargs)
# Convert the list of tools to a JSON string
tools_json="{\"include\": ["
for tool in $tool_dirs; do
tool_name=$(basename $tool)
json_line="{\"tool_dir\": \"$tool\", \"tool_name\": \"$tool_name\"},"
if [ ! "$tools_json" == *"json_line"* ]; then
tools_json="$tools_json$json_line"
fi
done
# Remove the trailing comma
if [ "$tools_json" == *"," ]; then
tools_json="${tools_json%?}"
fi
tools_json="$tools_json]}"
echo "tools_json: $tools_json"
# Set the output
echo "matrix=$( echo "$tools_json" )" >> $GITHUB_OUTPUT