Skip to content

Commit 1afc6d4

Browse files
author
miranov25
committed
ATO-648 - adding diff of workflow from the alien
1 parent 6520bbf commit 1afc6d4

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

UTILS/Parsers/workflowToJSON.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Source path for the script
2+
# source $O2DPG/UTILS/Parsers/workflowToJSON.sh
23
# source $NOTES/JIRA/ATO-648/workflowToJSON.sh
34

45
# Description:
@@ -110,6 +111,73 @@ jq -Rn '
110111
]' "$log_file"
111112
}
112113

114+
115+
# makeDiffWorkflow alien:///alice/data/2023/LHC23zzk/544515/apass5/1140/o2_ctf_run00544515_orbit0221337280_tf0000047516_epn242/workflowconfig.log alien:///alice/data/2023/LHC23zzk/544515/apass4/1140/o2_ctf_run00544515_orbit0221337280_tf0000047516_epn242/workflowconfig.log 1 gpu
116+
makeDiffWorkflow() {
117+
# Make diff of workflowConfig.log JSONs.
118+
# Usage:
119+
# makeDiffWorkflow <file0> <file1> <diffType> <filter>
120+
# file0: path or alien:// to first workflowconfig.log
121+
# file1: path or alien:// to second workflowconfig.log
122+
# diffType: 0 = unified diff, 1 = side-by-side (default: 1)
123+
# filter: string to match command, e.g. gpu (default: gpu)
124+
# Notes:
125+
# Creates workflow0.json and workflow1.json from parsed input.
126+
# Uses makeParse and jq for filtering and diffing.
127+
# Supports Alien paths via alien.py cat.
128+
129+
if [[ -z "$1" || -z "$2" ]]; then
130+
cat <<'HELP_USAGE' | helpCat0 bash
131+
makeDiffWorkflow: Compare two O2 workflowconfig logs (local or Alien).
132+
Usage:
133+
makeDiffWorkflow <file0> <file1> <diffType> <filter>
134+
Parameters:
135+
file0 – path to first workflowconfig.log or alien:// path
136+
file1 – path to second workflowconfig.log or alien:// path
137+
diffType – (optional) 0 = unified diff, 1 = side-by-side diff (default: 1)
138+
filter – (optional) command string filter, e.g. "gpu", "hlt" (default: gpu)
139+
Example:
140+
makeDiffWorkflow alien:///path/to/file0.log ./file1.log 1 gpu
141+
makeDiffWorkflow alien:///alice/data/2023/LHC23zzk/544515/apass5/1140/o2_ctf_run00544515_orbit0221337280_tf0000047516_epn242/workflowconfig.log alien:///alice/data/2023/LHC23zzk/544515/apass4/1140/o2_ctf_run00544515_orbit0221337280_tf0000047516_epn242/workflowconfig.log 1 gpu
142+
143+
HELP_USAGE
144+
return
145+
fi
146+
file0="$1"
147+
file1="$2"
148+
diffType="${3:-1}"
149+
filter="${4:-o2-gpu}"
150+
# Download from alien if needed
151+
if [[ "$file0" == alien://* ]]; then
152+
echo "Fetching $file0 from Alien..."
153+
alien.py cat "$file0" > "${TMPDIR:-/tmp}/workflow0.log"
154+
file0="${TMPDIR:-/tmp}/workflow0.log"
155+
fi
156+
if [[ "$file1" == alien://* ]]; then
157+
echo "Fetching $file1 from Alien..."
158+
alien.py cat "$file1" > "${TMPDIR:-/tmp}/workflow1.log"
159+
file1="${TMPDIR:-/tmp}/workflow1.log"
160+
fi
161+
162+
makeParse "$file0" > workflow0.json
163+
makeParse "$file1" > workflow1.json
164+
165+
# Apply filter to both JSON files
166+
jq ".[] | select(.command | test(\"^${filter}\"))" workflow0.json | jq --sort-keys . > workflow0.filtered.json
167+
jq ".[] | select(.command | test(\"^${filter}\"))" workflow1.json | jq --sort-keys . > workflow1.filtered.json
168+
169+
echo "Comparing workflow commands filtered by '^o2-${filter}'..."
170+
171+
if [[ "$diffType" -eq 1 ]]; then
172+
diff --side-by-side --left-column --color=always workflow0.filtered.json workflow1.filtered.json | less -R
173+
else
174+
diff --color=always workflow0.filtered.json workflow1.filtered.json | less -R
175+
fi
176+
}
177+
178+
179+
180+
113181
makeDiffExample(){
114182
cat <<HELP_USAGE | helpCat
115183
Description:

0 commit comments

Comments
 (0)