|
| 1 | +name: extrai_fatos |
| 2 | + |
| 3 | +on: [push, workflow_dispatch] |
| 4 | + |
| 5 | +jobs: |
| 6 | + extrai_fatos: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + steps: |
| 9 | + - uses: actions/checkout@v4 |
| 10 | + - name: Build container |
| 11 | + run: DOCKER_BUILDKIT=1 docker build --tag ptoie_python . |
| 12 | + |
| 13 | + - name: Run all inputs with all configurations |
| 14 | + run: | |
| 15 | + set -euo pipefail |
| 16 | + mkdir -p outputs |
| 17 | +
|
| 18 | + # Define flag combinations to run (same for JSON and CSV) |
| 19 | + FLAGS_LIST=("" "-cc" "-sc" "-hs" "-a" "-a -t" "-cc -sc -hs -a -t") |
| 20 | +
|
| 21 | + # iterate only over .conll files in the inputs directory |
| 22 | + for input_path in inputs/*.conll; do |
| 23 | + [ -f "$input_path" ] || continue |
| 24 | + filename=$(basename "$input_path") |
| 25 | + # strip last extension only (handles names like ceten-200.conll) |
| 26 | + name="${filename%.*}" |
| 27 | +
|
| 28 | + # detect input type: .txt -> --input-type txt, otherwise assume conll |
| 29 | + if [[ "$filename" == *.txt ]]; then |
| 30 | + input_args="--input-type txt" |
| 31 | + else |
| 32 | + input_args="-it conll" |
| 33 | + fi |
| 34 | +
|
| 35 | + for flags in "${FLAGS_LIST[@]}"; do |
| 36 | + # --- JSON --- |
| 37 | + echo "[JSON] input=$filename flags=[$flags]" |
| 38 | + # remove stale json output if any |
| 39 | + rm -f ./outputs/output.json |
| 40 | + docker run --rm -v "$(pwd)":/ptoie_python ptoie_python poetry run python3 src/main.py -i "$input_path" $input_args $flags || echo "json-run-failed for $filename $flags" |
| 41 | +
|
| 42 | + # compute cleaned suffix for filename (empty => base name only) |
| 43 | + if [[ -z "$flags" ]]; then |
| 44 | + out_json="./outputs/${name}.json" |
| 45 | + else |
| 46 | + cleaned=$(echo "$flags" | sed -E "s/^\s*-//; s/\s+-/ /g; s/\s+/-/g; s/^-//") |
| 47 | + # remove any leading/trailing hyphens/spaces |
| 48 | + cleaned=$(echo "$cleaned" | sed -E 's/^[ -]+//; s/[ -]+$//; s/\s+/-/g') |
| 49 | + out_json="./outputs/${name}-${cleaned}.json" |
| 50 | + fi |
| 51 | + if [[ -f ./outputs/output.json ]]; then |
| 52 | + mv ./outputs/output.json "$out_json" |
| 53 | + else |
| 54 | + echo "Warning: JSON output not produced for $filename with flags [$flags]" |
| 55 | + fi |
| 56 | +
|
| 57 | + # --- CSV --- |
| 58 | + echo "[CSV] input=$filename flags=[$flags]" |
| 59 | + # remove stale csv output if any |
| 60 | + rm -f ./outputs/output.csv |
| 61 | + docker run --rm -v "$(pwd)":/ptoie_python ptoie_python poetry run python3 src/main.py -i "$input_path" $input_args $flags -o ./outputs/output.csv -ot csv || echo "csv-run-failed for $filename $flags" |
| 62 | +
|
| 63 | + if [[ -z "$flags" ]]; then |
| 64 | + out_csv="./outputs/${name}.csv" |
| 65 | + else |
| 66 | + cleaned=$(echo "$flags" | sed -E "s/^\s*-//; s/\s+-/ /g; s/\s+/-/g; s/^-//") |
| 67 | + cleaned=$(echo "$cleaned" | sed -E 's/^[ -]+//; s/[ -]+$//; s/\s+/-/g') |
| 68 | + out_csv="./outputs/${name}-${cleaned}.csv" |
| 69 | + fi |
| 70 | + if [[ -f ./outputs/output.csv ]]; then |
| 71 | + mv ./outputs/output.csv "$out_csv" |
| 72 | + else |
| 73 | + echo "Warning: CSV output not produced for $filename with flags [$flags]" |
| 74 | + fi |
| 75 | +
|
| 76 | + done |
| 77 | + done |
| 78 | +
|
| 79 | + - name: Upload artifacts |
| 80 | + uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: extrai_fatos_outputs |
| 83 | + path: | |
| 84 | + ./outputs |
0 commit comments