-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
132 lines (119 loc) · 4.01 KB
/
Copy pathaction.yml
File metadata and controls
132 lines (119 loc) · 4.01 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: "Raster Batch Runner"
description: >-
Run a declarative raster processing job (clip, reproject, resample, mosaic,
mask, COG conversion) across a folder of imagery, in parallel and resumably.
author: "python-remote-sensing.com"
branding:
icon: layers
color: green
inputs:
job:
description: "Path to the YAML job spec to run."
required: true
workers:
description: "Worker processes. Defaults to the runner's CPU count."
required: false
default: ""
timeout:
description: "Per-file timeout in seconds. Empty means no timeout."
required: false
default: ""
extra-args:
description: >-
Additional flags passed straight to `raster-batch run`, e.g.
"--retry-failed" or "--force --limit 50".
required: false
default: ""
python-version:
description: "Python version to set up. rasterio needs 3.12 or newer."
required: false
default: "3.12"
state-file:
description: >-
Ledger location. Point this at a cached path to make a job resumable
across workflow runs.
required: false
default: ""
fail-on-error:
description: >-
Fail the step if any file failed. Set to "false" to keep going and
inspect the summary output yourself.
required: false
default: "true"
outputs:
summary:
description: "The full run summary as a JSON string."
value: ${{ steps.run.outputs.summary }}
completed:
description: "Number of files processed in this run."
value: ${{ steps.run.outputs.completed }}
skipped:
description: "Number of files skipped because they were already done."
value: ${{ steps.run.outputs.skipped }}
failed:
description: "Number of files that failed."
value: ${{ steps.run.outputs.failed }}
runs:
using: composite
steps:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ inputs.python-version }}
cache: pip
- name: Install dependencies
shell: bash
run: python -m pip install --upgrade pip -r "${{ github.action_path }}/requirements.txt"
- name: Validate the job spec
shell: bash
env:
PYTHONPATH: ${{ github.action_path }}
run: python -m raster_batch validate "${{ inputs.job }}"
- name: Run the job
id: run
shell: bash
env:
PYTHONPATH: ${{ github.action_path }}
run: |
set -o pipefail
args=()
[ -n "${{ inputs.workers }}" ] && args+=(--workers "${{ inputs.workers }}")
[ -n "${{ inputs.timeout }}" ] && args+=(--timeout "${{ inputs.timeout }}")
[ -n "${{ inputs.state-file }}" ] && args+=(--state "${{ inputs.state-file }}")
# shellcheck disable=SC2206
[ -n "${{ inputs.extra-args }}" ] && args+=(${{ inputs.extra-args }})
set +e
python -m raster_batch run "${{ inputs.job }}" --json "${args[@]}" > summary.json
status=$?
set -e
cat summary.json
{
echo "summary<<RASTER_BATCH_EOF"
cat summary.json
echo "RASTER_BATCH_EOF"
} >> "$GITHUB_OUTPUT"
python - <<'PY' >> "$GITHUB_OUTPUT"
import json
with open("summary.json") as handle:
data = json.load(handle)
for key in ("completed", "skipped", "failed"):
print(f"{key}={data.get(key, 0)}")
PY
python - <<'PY' >> "$GITHUB_STEP_SUMMARY"
import json
with open("summary.json") as handle:
data = json.load(handle)
print("## Raster batch run\n")
print(f"- Completed: {data.get('completed', 0)}")
print(f"- Skipped: {data.get('skipped', 0)}")
print(f"- Failed: {data.get('failed', 0)}")
print(f"- Elapsed: {data.get('elapsed_seconds', 0)}s")
failures = data.get("failures") or []
if failures:
print("\n### Failures\n")
for failure in failures:
print(f"- `{failure['unit']}`: {failure['error']}")
PY
if [ "${{ inputs.fail-on-error }}" = "true" ]; then
exit $status
fi