meg's picture
meg HF staff
Unifying Regis, me, Sasha code to see if it can all come together.
6c04bde verified
raw
history blame
1.65 kB
#!/bin/bash
# TODO: I think this flag is related to getting fail logs; check.
set -e
export SPACE="EnergyStarAI/launch-computation-example"
echo "Not checking h100 -- already know it's not there."
#python /check_h100.py
echo "Attempting to run."
#if [[ $? = 0 ]]; then
python /parse_requests.py | while read line; do
IFS="," read backend_model experiment_name <<< $(echo ${line})
echo "Benchmarking Model: ${backend_model}, Task: ${experiment_name}"
now=$(date +%Y-%m-%d-%H-%M-%S)
export run_dir="./runs/" #${experiment_name}/${backend_model}/${now}"
optimum-benchmark --config-name ${experiment_name} --config-dir /optimum-benchmark/examples/energy_star/ backend.model=${backend_model} backend.processor=${backend_model} hydra.run.dir=${run_dir} 2> $run_dir/error.log
done || {
echo "An error occurred while benchmarking the model..."
echo "Using curl to retrieve the space run log."
curl https://api.hf.space/v1/${SPACE}/logs/run -H "Authorization: Bearer ${DEBUG}" > ./runs/logs-${now}.txt
python /failed_run.py --run_dir $run_dir --model_name $backend_model
}
if [ -s ./runs/logs-${now}.txt ]; then
# error.log is not-empty, an error was raised
echo "An error was raised while benchmarking the model..."
python /failed_run.py --run_dir $run_dir --model_name $backend_model
# # Delete the current run directory so that it is not pushed by create_results.py later
# rm -rf $run_dir
else
# The file is empty, so no error
echo "Finished; uploading dataset results"
python /create_results.py ./runs
fi
# Pausing space
echo "Pausing space."
python /pause_space.py
echo "Done."