Skip to content

Commit

Permalink
refactor: universal running instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
tskir committed Dec 1, 2023
1 parent 2b87af9 commit 79cd420
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 27 deletions.
20 changes: 12 additions & 8 deletions src/batch/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
## How to run a batch job

Set up:
```bash
# Prepare and upload config.
python3 eqtl_catalogue.py > config.json
# Upload the script.
gsutil cp eqtl_catalogue.py gs://genetics_etl_python_playground/batch/eqtl_catalogue/eqtl_catalogue.py
gsutil cp eqtl_catalogue.sh gs://genetics_etl_python_playground/batch/eqtl_catalogue/eqtl_catalogue.sh
# Submit the batch job.
export MODULE=eqtl_catalogue
```

Run:
```bash
# Upload code.
gsutil -m cp -r . gs://genetics_etl_python_playground/batch/code
# Submit batch job.
gcloud batch jobs submit \
eqtl-catalogue24 \
--config config.json \
"${MODULE}-$(date --utc +"%Y%m%d-%H%M%S")" \
--config <(python3 ${MODULE}.py) \
--location europe-west1
```
19 changes: 0 additions & 19 deletions src/batch/eqtl_catalogue.sh

This file was deleted.

28 changes: 28 additions & 0 deletions src/batch/runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export MODULE=$1

# Create directory for logs, if necessary.
mkdir -p /mnt/share/logs/$MODULE

# Redirect all subsequent logs.
# The $BATCH_TASK_INDEX variable is set by Google Batch.
exec &> /mnt/share/logs/$MODULE/log.$BATCH_TASK_INDEX.log

echo ">>> Update APT"
sudo apt -y update

echo ">>> Install packages"
sudo apt -y install python3 python3-pip python3-setuptools

echo ">>> Update PIP and setuptools"
sudo python3 -m pip install --upgrade pip setuptools
echo $?

echo ">>> Install packages"
sudo python3 -m pip install -r /mnt/share/code/requirements.tt
echo $?

echo ">>> Run script"
sudo python3 /mnt/share/code/${MODULE}.py ${BATCH_TASK_INDEX}

echo ">>> Completed"
echo $?

0 comments on commit 79cd420

Please sign in to comment.