Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit 8e894cd

Browse files
committed
Automated commit -> added return statement to parser in jatosapi
1 parent 3bb50bc commit 8e894cd

File tree

16 files changed

+93
-602
lines changed

16 files changed

+93
-602
lines changed

.github/workflows/main.yml

Lines changed: 93 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ jobs:
1919
name: Process Raw CSV Files
2020
runs-on: self-hosted
2121
outputs:
22-
sub: ${{ steps.set_vars.outputs.sub }}
23-
task: ${{ steps.set_vars.outputs.task }}
24-
version: ${{ steps.set_vars.outputs.version }}
25-
run_part: ${{ steps.set_vars.outputs.run_part }}
22+
data: ${{ steps.set_vars.outputs.json }}
2623

2724
steps:
2825
- name: Checkout Code
@@ -47,14 +44,13 @@ jobs:
4744
echo "Changed CSV files in the last 24 hours:"
4845
echo "$formatted_data"
4946
50-
51-
- name: Install Python Dependencies
52-
run: |
53-
python -m pip install --upgrade pip
54-
5547
- name: Parse Raw CSV Files
5648
id: set_vars
5749
run: |
50+
# Initialize an empty JSON array
51+
json_array="["
52+
first_item=true
53+
5854
# Loop through each CSV file in $data
5955
for file in $data; do
6056
# Extract the directory and filename
@@ -68,11 +64,22 @@ jobs:
6864
IFS='_' read -r sub task version <<< "$filename"
6965
version="${version%.csv}" # Remove the .csv extension from version
7066
71-
# Set outputs
72-
echo "::set-output name=run_part::$run_part"
73-
echo "::set-output name=sub::$sub"
74-
echo "::set-output name=task::$task"
75-
echo "::set-output name=version::$version"
67+
# Escape variables for JSON
68+
sub_escaped=$(printf '%s' "$sub" | sed 's/"/\\"/g')
69+
task_escaped=$(printf '%s' "$task" | sed 's/"/\\"/g')
70+
version_escaped=$(printf '%s' "$version" | sed 's/"/\\"/g')
71+
run_part_escaped=$(printf '%s' "$run_part" | sed 's/"/\\"/g')
72+
73+
# Build JSON object
74+
json_object="{\"sub\":\"$sub_escaped\",\"task\":\"$task_escaped\",\"version\":\"$version_escaped\",\"run_part\":\"$run_part_escaped\"}"
75+
76+
# Append to JSON array
77+
if [ "$first_item" = true ]; then
78+
json_array="$json_array$json_object"
79+
first_item=false
80+
else
81+
json_array="$json_array,$json_object"
82+
fi
7683
7784
# Print the extracted values
7885
echo "Run Part: $run_part"
@@ -81,21 +88,29 @@ jobs:
8188
echo "Version: $version"
8289
done
8390
91+
json_array="$json_array]"
92+
93+
# Output the JSON array
94+
echo "json=$json_array" >> $GITHUB_OUTPUT
95+
8496
run_qc:
8597
name: Run Quality Control
8698
runs-on: self-hosted
8799
needs: process_raw
100+
strategy:
101+
matrix:
102+
config: ${{ fromJson(needs.process_raw.outputs.data) }}
88103

89104
steps:
90105
- name: Checkout Code
91106
uses: actions/checkout@v3
92107

93108
- name: Debug Environment Variables
94109
run: |
95-
echo "Subject: ${{ needs.process_raw.outputs.sub }}"
96-
echo "Task: ${{ needs.process_raw.outputs.task }}"
97-
echo "Version: ${{ needs.process_raw.outputs.version }}"
98-
echo "Run Part: ${{ needs.process_raw.outputs.run_part }}"
110+
echo "Subject: ${{ matrix.config.sub }}"
111+
echo "Task: ${{ matrix.config.task }}"
112+
echo "Version: ${{ matrix.config.version }}"
113+
echo "Run Part: ${{ matrix.config.run_part }}"
99114
100115
- name: Install Python Dependencies
101116
run: |
@@ -105,39 +120,73 @@ jobs:
105120
env:
106121
TEASE: ${{ secrets.TEASE }}
107122
run: |
108-
sub=${{ needs.process_raw.outputs.sub }}
109-
task=${{ needs.process_raw.outputs.task }}
110-
vers=${{ needs.process_raw.outputs.version }}
111-
run_part=${{ needs.process_raw.outputs.run_part }}
123+
sub=${{ matrix.config.sub }}
124+
task=${{ matrix.config.task }}
125+
vers=${{ matrix.config.version }}
126+
run_part=${{ matrix.config.run_part }}
127+
128+
echo "Processing subject: $sub"
129+
echo "Processing task: $task"
130+
echo "Processing version: $vers"
131+
csv_file="./data/${sub}/processed/${run_part}/${sub}_${task}_${vers}.csv"
132+
mkdir -p "./data/${sub}/${run_part}"
133+
log_file="./data/${sub}/${run_part}/qc_${task}_${vers}.log"
134+
echo "CSV file: $csv_file"
135+
echo "Log file: $log_file"
136+
if [ -f "$csv_file" ]; then
137+
python ./code/PCqC.py -s "$csv_file" -o "./data/${sub}/${run_part}" -sub "$sub" | tee "$log_file"
138+
echo "QC for ${sub}_${task}_${vers} completed"
139+
else
140+
echo "CSV file $csv_file does not exist"
141+
fi
112142
113-
for sub in ${sub}; do
114-
echo "Processing subject: $sub"
115-
for task in ${task}; do
116-
echo "Processing task: $task"
117-
for vers in ${vers}; do
118-
echo "Processing version: $vers"
119-
csv_file="./data/${sub}/processed/${run_part}/${sub}_${task}_${vers}.csv"
120-
mkdir -p "./data/${sub}/${run_part}"
121-
log_file="./data/${sub}/${run_part}/qc_${task}_${vers}.log"
122-
echo "CSV file: $csv_file"
123-
echo "Log file: $log_file"
124-
if [ -f "$csv_file" ]; then
125-
python ./code/PCqC.py -s "$csv_file" -o "./data/${sub}/${run_part}" -sub "$sub" | tee "$log_file"
126-
echo "QC for ${sub}_${task}_${vers} completed"
127-
else
128-
echo "CSV file $csv_file does not exist"
129-
fi
130-
done
131-
done
132-
done
143+
- name: Upload QC Results
144+
uses: actions/upload-artifact@v3
145+
with:
146+
name: qc-results-${{ matrix.config.sub }}-${{ matrix.config.task }}-${{ matrix.config.version }}-${{ matrix.config.run_part }}
147+
path: |
148+
./data/${{ matrix.config.sub }}/${{ matrix.config.run_part }}/*.png
149+
./data/${{ matrix.config.sub }}/${{ matrix.config.run_part }}/*.log
133150
134151
152+
commit_results:
153+
name: Commit and Push QC Results
154+
runs-on: self-hosted
155+
needs: run_qc
156+
157+
steps:
158+
- name: Checkout Code
159+
uses: actions/checkout@v3
160+
161+
- name: Download all artifacts
162+
uses: actions/download-artifact@v3
163+
with:
164+
path: ./
165+
166+
- name: Move QC Results
167+
run: |
168+
echo "Moving QC results to data directory..."
169+
for dir in qc-results-*; do
170+
echo "Processing artifact directory: $dir"
171+
# Extract sub, task, version, and run_part from the directory name
172+
IFS='-' read -r _ _ sub task version run_part <<< "$dir"
173+
echo "Subject: $sub, Task: $task, Version: $version, Run Part: $run_part"
174+
# Define the target directories
175+
run_part_dir="./data/${sub}/${run_part}"
176+
# Create the target directories if they don't exist
177+
mkdir -p "$run_part_dir"
178+
# Move .png files to the processed directory
179+
mv "$dir"/*.png "$run_part_dir/" 2>/dev/null || :
180+
# Move .log files to the run_part directory
181+
mv "$dir"/*.log "$run_part_dir/" 2>/dev/null || :
182+
done
183+
135184
- name: Commit and Push QC Results
136185
run: |
137186
git config --global user.name "miloswrath"
138187
git config --global user.email "[email protected]"
139188
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
140-
git add ./data/*/*/*.png
189+
git add ./data/*/*/*.png ./data/*/*/*.log
141190
git commit -m "Add QC results for subjects $(date +%Y-%m-%d)"
142191
git push origin main
143192
@@ -147,12 +196,10 @@ jobs:
147196
find ./data -type d
148197
find ./data -type f
149198
150-
151-
152199
add:
153200
name: Generate Jekyll Posts and Deploy
154201
runs-on: ubuntu-latest
155-
needs: [process_raw, run_qc]
202+
needs: [process_raw, run_qc, commit_results]
156203

157204
steps:
158205
# 1. Checkout the Repository

_posts/2024-09-27-subject-8004-155033.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

data/7004/processed/run-1/7004_PC_A.csv

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)