run_jsonl.sh 897 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # Check if an argument was provided
  3. if [ "$#" -ne 1 ]; then
  4. echo "Usage: $0 <path_to_jsonl_file>"
  5. exit 1
  6. fi
  7. FILE="$1"
  8. # Check if the file exists and is readable
  9. if [ ! -f "$FILE" ] || [ ! -r "$FILE" ]; then
  10. echo "Error: File '$FILE' does not exist or is not readable."
  11. exit 2
  12. fi
  13. # Iterate over each line of the JSONL file
  14. while IFS= read -r line; do
  15. # Construct command arguments from the JSON map
  16. # jq -r '. | to_entries | .[] | "--\(.key) \(.value)"' converts each key-value pair in the JSON object
  17. # into a format suitable for passing to the Python script
  18. # xargs -n 2 groups them back into pairs to handle as arguments correctly
  19. ARGS=$(echo "$line" | jq -r '. | to_entries | .[] | "--\(.key) \(.value)"' | xargs -n 2 echo)
  20. # Execute the Python script with the constructed arguments
  21. echo $ARGS
  22. python run.py $ARGS
  23. done < "$FILE"