Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-27 07:41:45

0001 #!/bin/bash
0002 # Make sure this script has execute permissions: chmod +x my_script.sh
0003 
0004 echo "Running on $(hostname)"
0005 echo "Start time: $(date)"
0006 
0007 if [ $# -ne 1 ]; then
0008     echo "[ERROR] Usage: $0 '<stf_json>'"
0009     exit 1
0010 fi
0011 
0012 STF_JSON="$1"
0013 
0014 echo "[INFO] Received STF JSON:"
0015 echo "$STF_JSON"
0016 
0017 # Check jq
0018 if ! command -v jq &>/dev/null; then
0019     echo "[ERROR] jq is not installed!"
0020     exit 1
0021 fi
0022 
0023 # Extract fields from the actual message format sent by the processing agent
0024 RUN_ID=$(echo "$STF_JSON" | jq -r '.run_id')
0025 FILENAME=$(echo "$STF_JSON" | jq -r '.filename')
0026 STATE=$(echo "$STF_JSON" | jq -r '.state')
0027 SUBSTATE=$(echo "$STF_JSON" | jq -r '.substate')
0028 
0029 echo "[INFO] Processing Agent Dataset Metadata:"
0030 echo "  Run ID:    $RUN_ID"
0031 echo "  Filename:  $FILENAME"
0032 echo "  State:     $STATE"
0033 echo "  Substate:  $SUBSTATE"
0034 
0035 # This is dataset-based processing - one job processes entire run
0036 echo "[INFO] Starting dataset-based STF processing for run $RUN_ID..."
0037 
0038 # In a real implementation, one would:
0039 # 1. List the dataset contents via Rucio API
0040 # 2. Download/access the STF files in the dataset
0041 # 3. Process all files in the run
0042 echo "[INFO] Simulating dataset processing (all STF files in run)..."
0043 sleep 3
0044 
0045 # Create output file with processing results
0046 cat > myout.txt <<EOF
0047 STF Dataset Processing Results
0048 ==============================
0049 Processing completed at: $(date)
0050 Hostname: $(hostname)
0051 
0052 Dataset Processing Details:
0053   Run ID:           $RUN_ID
0054   Dataset Filename: $FILENAME
0055   Processing State: $STATE
0056   Processing Stage: $SUBSTATE
0057 
0058 Processing Mode: Dataset-based (entire run processed as one job)
0059 Processing Status: SUCCESS
0060 Output Files Generated: myout.txt
0061 
0062 Notes:
0063 - This job processes all STF files collected for run $RUN_ID
0064 - Files were gathered by the processing agent during data_ready messages
0065 - Dataset was closed at end_run and submitted as single PanDA job
0066 
0067 Full JSON Input:
0068 $STF_JSON
0069 EOF
0070 
0071 echo "[INFO] Dataset processing completed successfully"
0072 echo "[INFO] Output written to myout.txt"
0073 echo "Done at: $(date)"
0074 
0075 # Show what we created
0076 echo "[INFO] Output file contents:"
0077 cat myout.txt