@@ -24,29 +24,13 @@ echo "Setting up conda environment..."
2424echo " source ~/miniconda3/bin/activate" >> ~ /.bashrc
2525~ /miniconda3/bin/conda init bash
2626
27- # Get benchmark year from instance metadata
28- BENCHMARK_YEAR =$( curl -H " Metadata-Flavor: Google" " http://metadata.google.internal/computeMetadata/v1/instance/attributes/benchmark_year " )
29- echo " Using benchmark year : ${BENCHMARK_YEAR } "
27+ # Get benchmark years from instance metadata
28+ BENCHMARK_YEARS_JSON =$( curl -H " Metadata-Flavor: Google" " http://metadata.google.internal/computeMetadata/v1/instance/attributes/benchmark_years " )
29+ echo " Retrieved benchmark years : ${BENCHMARK_YEARS_JSON } "
3030
31- # Create conda environment with the appropriate year
32- cd /solver-benchmark/
33- ~ /miniconda3/bin/conda env create -f runner/envs/benchmark-${BENCHMARK_YEAR} -fixed.yaml
34-
35- # Activate the conda environment
36- echo " Activating conda environment benchmark-${BENCHMARK_YEAR} ..."
37- source ~ /miniconda3/bin/activate
38- conda activate benchmark-${BENCHMARK_YEAR}
39-
40- # Add auto-activation to .bashrc
41- echo -e " \n# Automatically activate benchmark environment" >> ~ /.bashrc
42- echo " conda activate benchmark-${BENCHMARK_YEAR} " >> ~ /.bashrc
43-
44- # Verify environment is active
45- echo " Current conda environment:"
46- conda info --envs | grep " *"
47-
48- echo " Setup completed at $( date) "
49- echo " Conda environment benchmark-${BENCHMARK_YEAR} is now active and will be activated on login"
31+ # Parse the JSON array into a space-separated string for benchmark_all.sh
32+ BENCHMARK_YEARS_STR=$( echo " ${BENCHMARK_YEARS_JSON} " | jq -r ' join(" ")' )
33+ echo " Parsed benchmark years: ${BENCHMARK_YEARS_STR} "
5034
5135# Get benchmark filename from instance metadata
5236BENCHMARK_FILE=$( curl -H " Metadata-Flavor: Google" " http://metadata.google.internal/computeMetadata/v1/instance/attributes/benchmark_file" )
@@ -58,28 +42,53 @@ BENCHMARK_CONTENT=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.in
5842# Write the benchmark file - preserve the exact content
5943echo " ${BENCHMARK_CONTENT} " > /solver-benchmark/benchmarks/${BENCHMARK_FILE}
6044
61- # Run the benchmarks
62- echo " Starting benchmarks..."
63- python /solver-benchmark/runner/run_benchmarks.py /solver-benchmark/benchmarks/${BENCHMARK_FILE} ${BENCHMARK_YEAR}
45+ # Make benchmark_all.sh executable
46+ cd /solver-benchmark/
47+ chmod +x ./runner/benchmark_all.sh
48+
49+ # Run the benchmark_all.sh script with our years
50+ echo " Starting benchmarks for years: ${BENCHMARK_YEARS_STR} "
51+ source ~ /miniconda3/bin/activate
52+ ./runner/benchmark_all.sh -y " ${BENCHMARK_YEARS_STR} " ./benchmarks/${BENCHMARK_FILE}
53+ BENCHMARK_EXIT_CODE=$?
54+
55+ if [ $BENCHMARK_EXIT_CODE -ne 0 ]; then
56+ echo " ERROR: Benchmark failed with exit code $BENCHMARK_EXIT_CODE at $( date) "
57+ exit $BENCHMARK_EXIT_CODE
58+ fi
59+
60+ echo " All benchmarks completed at $( date) "
61+
62+ # Create timestamp for the results
63+ TIMESTAMP=$( date +%Y%m%d_%H%M%S)
64+ echo " Using timestamp: ${TIMESTAMP} "
65+
66+ # Create a copy of results with timestamp
67+ CLEAN_FILENAME=$( basename " ${BENCHMARK_FILE} " .yaml)
68+ RESULTS_COPY=" /tmp/${CLEAN_FILENAME} _${TIMESTAMP} .csv"
69+ echo " Creating copy of results as: ${RESULTS_COPY} "
70+
71+ cp /solver-benchmark/results/benchmark_results.csv " ${RESULTS_COPY} "
72+ COPY_EXIT_CODE=$?
73+
74+ if [ $COPY_EXIT_CODE -ne 0 ]; then
75+ echo " ERROR: Failed to copy benchmark results at $( date) . Exit code: $COPY_EXIT_CODE "
76+ echo " Check if file exists: /solver-benchmark/results/benchmark_results.csv"
77+ ls -la /solver-benchmark/results/
78+ exit $COPY_EXIT_CODE
79+ fi
80+
81+ echo " Benchmark results successfully copied at $( date) "
6482
6583# ----- GCS UPLOAD CONFIGURATION -----
84+ # Only proceed if the benchmark and copy operations were successful
6685# Check if GCS upload is enabled
6786ENABLE_GCS_UPLOAD=$( curl -H " Metadata-Flavor: Google" " http://metadata.google.internal/computeMetadata/v1/instance/attributes/enable_gcs_upload" )
6887if [ " ${ENABLE_GCS_UPLOAD} " == " true" ]; then
6988 # Get the GCS bucket name
7089 GCS_BUCKET_NAME=$( curl -H " Metadata-Flavor: Google" " http://metadata.google.internal/computeMetadata/v1/instance/attributes/gcs_bucket_name" )
7190 echo " Using GCS bucket: ${GCS_BUCKET_NAME} "
7291
73- # Create timestamp for the file
74- TIMESTAMP=$( date +%Y%m%d_%H%M%S)
75- echo " Using timestamp: ${TIMESTAMP} "
76-
77- # Create the properly named copy of results
78- CLEAN_FILENAME=$( basename " ${BENCHMARK_FILE} " .yaml)
79- RESULTS_COPY=" /tmp/${CLEAN_FILENAME} _${TIMESTAMP} .csv"
80- echo " Creating copy of results as: ${RESULTS_COPY} "
81- cp /solver-benchmark/results/benchmark_results.csv " ${RESULTS_COPY} "
82-
8392 # Ensure gsutil is available (should be on GCP instances by default)
8493 if ! command -v gsutil & > /dev/null; then
8594 echo " Installing Google Cloud SDK..."
0 commit comments