picocreator commited on
Commit
ba431fb
1 Parent(s): 64e1d9b

result jsonl compression script

Browse files
scripts/compress-all-jsonl.sh ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Get the current script directory of the script
4
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5
+
6
+ # lm-eval-output dir
7
+ PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
8
+ BASE_DIR="$PROJECT_DIR/lm-eval-output"
9
+
10
+ echo "==================================================="
11
+ echo "Compressing all jsonl files in $BASE_DIR"
12
+ echo "==================================================="
13
+
14
+ # Find all directories containing .jsonl files, without duplicates
15
+ find "$BASE_DIR" -type f -name '*.jsonl' | awk -F/ 'BEGIN{OFS="/"}{$NF=""; print $0}' | xargs -I {} readlink -f {} | sort -u | while read -r DIR
16
+ do
17
+ # Process each directory
18
+ "$SCRIPT_DIR/generate-result-jsonl-in-folder.sh" "$DIR" &
19
+ done
20
+
21
+ # Sleep for 5 second to allow the background processes to start
22
+ sleep 5
23
+
24
+ # Wait for all background processes to finish
25
+ wait
26
+
27
+ # Sleep for 1 second to allow the background processes to finish / echo logs to flush, etc
28
+ sleep 1
29
+
30
+ # Done
31
+ echo "==================================================="
32
+ echo "All jsonl files in $BASE_DIR have been compressed"
33
+ echo "==================================================="
scripts/generate-result-jsonl-in-folder.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Check for argument representing the directory to perform the compression operation in
4
+ if [ -z "$1" ]; then
5
+ echo "Please provide the directory to perform the compression operation in"
6
+ exit 1
7
+ fi
8
+
9
+ # Go to the directory
10
+ cd "$1"
11
+
12
+ # Check if there is any jsonl file in the directory
13
+ if [ -z "$(find . -name '*.jsonl' -print -quit)" ]; then
14
+ echo "[SKIP] no jsonl files found : $1"
15
+ exit 0
16
+ fi
17
+
18
+ # Check if there is an existing result-jsonl.tar.gz file in the directory
19
+ if [ -f "result-jsonl.tar.gz" ]; then
20
+ # Check if any of the jsonl files have been modified since the last compression
21
+ if [ "result-jsonl.tar.gz" -nt "$(find . -name '*.jsonl' -print -quit)" ]; then
22
+ echo "[SKIP] no change found for : $1"
23
+ exit 0
24
+ fi
25
+ fi
26
+
27
+ # Compress the jsonl files
28
+ echo "[START] Compressing jsonl files in $1"
29
+ find . -maxdepth 1 -name '*.jsonl' -print0 | sort -z | tar --no-recursion --null -T - -cf - | gzip -n > .tmp.result-jsonl.tar.gz
30
+ mv .tmp.result-jsonl.tar.gz result-jsonl.tar.gz
31
+ echo "[DONE] result-jsonl.tar.gz created in $1"