From 1ce7dec84f38cec32d061ddee93008f7bc8db67f Mon Sep 17 00:00:00 2001 From: Larissa Heinrich Date: Mon, 26 Aug 2024 17:56:54 +0000 Subject: [PATCH] feat: make setup more robust by exiting if env activation fails --- README.md | 2 +- setup.sh | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c878975..caa4e9d 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ This is a GPU-hungry exercise so you're going to need all the GPU memory you can Next, run the setup script. It might take a few minutes. ``` cd 08_knowledge_extraction -sh setup.sh +bash setup.sh ``` This will: - Create a `conda` environment for this exercise diff --git a/setup.sh b/setup.sh index 22009e7..af633c7 100755 --- a/setup.sh +++ b/setup.sh @@ -4,12 +4,15 @@ conda create -n 08_knowledge_extraction -y python=3.11 eval "$(conda shell.bash hook)" conda activate 08_knowledge_extraction # Check if the environment is activated -echo "Environment activated: $(which python)" - +if [[ "$CONDA_DEFAULT_ENV" == "08_knowledge_extraction" ]]; then + echo "Environment activated successfully for package installation" +else + echo "Failed to activate environment for package installation. Dependencies not installed!" + exit +fi +echo "Training classifier model" conda install -y pytorch torchvision pytorch-cuda=12.1 -c pytorch -c nvidia pip install -r requirements.txt - -echo "Training classifier model" python extras/train_classifier.py conda deactivate