harbor run -t openthoughts/tasktrove-exp-rpt-stack-bash-withtests-v2-stack-bash-withtests-7362harbor download openthoughts/tasktrove-exp-rpt-stack-bash-withtests-v2-stack-bash-withtests-7362Implement a Bash script that will perform the following functionalities:
Directory Navigation: The script should check for the existence of a job-specific directory at /local/tmp/achen/$JOB_ID.$SGE_TASK_ID. If it exists, change the current working directory to this directory. If it does not exist, provide error output containing diagnostic information and exit gracefully.
Environment Setup:
PATH variable to include the specified location for the conda executable: /vol/grid-solar/sgeusers/achen/miniconda3/bin/.conda to activate the environment named cmaes_baselines.File Operations:
/vol/grid-solar/sgeusers/achen/primal_dual_baseline into the current job-specific directory.$experimentFolder/$experimentName/rac/ where the Python script will be executed.Experiment Execution: Execute a Python script named run_pybullet.py located in the previously mentioned subdirectory with parameters --env InvertedDoublePendulumBulletEnv-v0 and --seed $SGE_TASK_ID.
Output Management:
/vol/grid-solar/sgeusers/achen/primal_dual_baseline/$JOB_ID.$SGE_TASK_ID for storing results.logs directory from the current work directory to this output directory.$JOB_ID: An identifier for the job, passed as an environment variable.$SGE_TASK_ID: An identifier for the specific task, also passed as an environment variable./app/ directory as run_experiment.sh.JOB_ID and SGE_TASK_ID.The following test script will be used to verify your solution:
#!/bin/sh
#
# Force Bourne Shell if not Sun Grid Engine default shell (you never know!)
#
#$ -S /bin/sh
#
# I know I have a directory here so I'll use it as my initial working directory
#
#$ -wd /vol/grid-solar/sgeusers/achen
#
#
# End of the setup directives
#
# Now let's do something useful, but first change into the job-specific
# directory that should have been created for us
#
# Check we have somewhere to work now and if we don't, exit nicely.
#
if [ -d /local/tmp/achen/$JOB_ID.$SGE_TASK_ID ]; then
cd /local/tmp/achen/$JOB_ID.$SGE_TASK_ID
else
echo "Uh oh ! There's no job directory to change into "
echo "Something is broken. I should inform the programmers"
echo "Save some information that may be of use to them"
echo "Here's LOCAL TMP "
ls -la /local/tmp
echo "AND LOCAL TMP achen "
ls -la /local/tmp/achen
echo "Exiting"
exit 1
fi
#
# Now we are in the job-specific directory so now can do something useful
#
# Stdout from programs and shell echos will go into the file
# scriptname.o$JOB_ID
# so we'll put a few things in there to help us see what went on
#
#
# Do specific stuff here. Here i need to first use bash, then conda env list, source activate openai-neat.
#
echo ==UNAME==
uname -n
echo ==WHO AM I and GROUPS==
id
groups
echo ==SGE_O_WORKDIR==
echo $SGE_O_WORKDIR
echo ==/LOCAL/TMP==
ls -ltr /local/tmp/
echo ==/VOL/GRID-SOLAR==
ls -l /vol/grid-solar/sgeusers/
#
# OK, where are we starting from and what's the environment we're in
#
echo ==RUN HOME==
pwd
ls
echo ==ENV==
env
echo ==SET==
set
#
echo == WHATS IN LOCAL/TMP ON THE MACHINE WE ARE RUNNING ON ==
ls -ltra /local/tmp | tail
#
echo == WHATS IN LOCAL TMP achen JOB_ID AT THE START==
ls -la
#c
# Run python environment in bash
#
echo ==SETUP BASH==
bash
export PATH=/vol/grid-solar/sgeusers/achen/miniconda3/bin/:$PATH
source activate cmaes_baselines
#Define path
experimentFolder="primal_dual_baseline"
experimentName="baselines"
pyName="run_pybullet.py"
#
# Copy the input file to the local directory
#
cp -r /vol/grid-solar/sgeusers/achen/$experimentFolder .
#
# cd into repo
#
echo ==GOING INTO EXPERIMENT DIRECTORY==
cd $experimentFolder/$experimentName/rac/
#
# Run experiment
#
echo ==RUNNING EXPERIMENT==
python $pyName --env InvertedDoublePendulumBulletEnv-v0 --seed $SGE_TASK_ID
#
echo ==AND NOW, HAVING DONE SOMTHING USEFUL AND CREATED SOME OUTPUT==
ls -la
#
# Now we move the output to a place to pick it up from later
# (really should check that directory exists too, but this is just a test)
#
echo ==COPY PROGRAM RUN FILES==
mkdir -p /vol/grid-solar/sgeusers/achen/$experimentFolder/$JOB_ID.$SGE_TASK_ID
cp -r ./logs /vol/grid-solar/sgeusers/achen/$experimentFolder/$JOB_ID.$SGE_TASK_ID
#
echo "Ran through OK"