Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ docs/_build/
# PyBuilder
target/

# Conda
miniconda.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glad to see that you excluded this!


# Jupyter Notebook
.ipynb_checkpoints

Expand Down
7 changes: 7 additions & 0 deletions setup/activate_conda.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source setup/export_versions.sh

INSTALL_PREFIX=$HOME/miniconda-$EXP_CONDA_VER
SOURCE_SCRIPT="$HOME/miniconda-$EXP_CONDA_VER/etc/profile.d/conda.sh"

source $SOURCE_SCRIPT
conda activate emissioneval
7 changes: 4 additions & 3 deletions setup/checks/check_for_conda.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
source setup/export_versions.sh
CURR_CONDA_VER=`conda --version | cut -d " " -f 2`
EXP_CONDA_VER=23.1.0

if [ $CURR_CONDA_VER == $EXP_CONDA_VER ]; then
if [[ $CURR_CONDA_VER == $EXP_CONDA_VER ]]; then
echo "For conda, found $CURR_CONDA_VER, expected $EXP_CONDA_VER, all is good!"
else
echo "For conda, found $CURR_CONDA_VER, expected $EXP_CONDA_VER, run 'bash setup/setup_conda.sh $EXP_CONDA_VER <platform>' to get the correct version"
echo "For conda, found $CURR_CONDA_VER, expected $EXP_CONDA_VER, run 'bash setup/setup_conda.sh <platform>' to get the correct version"
echo "Or install manually after downloading from https://repo.anaconda.com/miniconda/"
fi

3 changes: 3 additions & 0 deletions setup/export_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export EXP_CONDA_VER=23.1.0
export EXP_CONDA_VER_SUFFIX=1
export EXP_LIBMAMBA_VER=1.0.0
5 changes: 1 addition & 4 deletions setup/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
# - on OSX: /Users/<user>/miniconda3/bin/conda
# - on Windows: C:/Users/<user>/Miniconda3/Scripts/conda

set -e

source setup/checks/check_for_conda.sh

conda create -n emissioneval
echo "Installing using conda now"
conda env update --name emissioneval --file setup/environment.yml
conda activate emissioneval
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that you no longer activate right after the setup here.

But then I noticed that you do set this up as part of the new activate_conda.sh script
https://github.com/MobilityNet/mobilitynet-analysis-scripts/pull/72/files#diff-b6b89814c0d70733151b062c77846d8546d726d07548236ee6a5bacff96b1f5eR7

I am merging this now to unblock @KG2468, but note that you need to update the README to match
https://github.com/MobilityNet/mobilitynet-analysis-scripts/tree/master?tab=readme-ov-file#running-existing-notebooks

63 changes: 45 additions & 18 deletions setup/setup_conda.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,48 @@
EXP_CONDA_VER=$1
PLATFORM=$2
echo "Installing for version $EXP_CONDA_VER and platform $PLATFORM"
if [[ ! -f setup/export_versions.sh ]]; then
echo "Error: setup/export_versions.sh file is missing. Please ensure it exists before running this script."
exit 1
fi

source setup/export_versions.sh
if [[ $? -ne 0 ]]; then
echo "Error: Failed to source setup/export_versions.sh. Please check the file for errors."
exit 1
fi

if [[ -z $EXP_CONDA_VER ]]; then
echo "Error: Requires the EXP_CONDA_VER variable to be set"
echo "Please check the 'export_versions.sh' script and ensure that it works"
exit 1
fi

if [[ -z $EXP_CONDA_VER || -z $PLATFORM ]]; then
echo "Usage: setup_conda.sh <version> <platform>"
echo " Platform options are Linux-x86_64, MacOSX-x86_64"
echo " For Windows, manually download and install https://repo.anaconda.com/miniconda/Miniconda3-$EXP_CONDA_VER-Windows-x86_64.exe"
else
PLATFORM=$1
INSTALL_PREFIX=$2

if [[ -z $PLATFORM ]]; then
echo "Usage: setup_conda.sh <platform> [install_prefix]"
echo " Platform options are Linux-x86_64, MacOSX-x86_64, MacOSX-arm64"
WINDOWS_INSTALLER_URL="https://repo.anaconda.com/miniconda/Miniconda3-py39_$EXP_CONDA_VER-$EXP_CONDA_VER_SUFFIX-Windows-x86_64.exe"
echo " For Windows, manually download and install $WINDOWS_INSTALLER_URL"
exit 2
fi

if [[ -z $INSTALL_PREFIX ]]; then
INSTALL_PREFIX=$HOME/miniconda-$EXP_CONDA_VER
SOURCE_SCRIPT="$HOME/miniconda-$EXP_CONDA_VER/etc/profile.d/conda.sh"

curl -o miniconda.sh -L https://repo.continuum.io/miniconda/Miniconda3-py39_$EXP_CONDA_VER-1-$PLATFORM.sh;
bash miniconda.sh -b -p $INSTALL_PREFIX
source $SOURCE_SCRIPT
hash -r
conda config --set always_yes yes --set changeps1 no
# Useful for debugging any issues with conda
conda info -a
echo "Successfully installed at $INSTALL_PREFIX. Please run 'source $SOURCE_SCRIPT' in every terminal where you want to use conda"
fi
SOURCE_SCRIPT="$INSTALL_PREFIX/etc/profile.d/conda.sh"

echo "Installing for version $EXP_CONDA_VER and platform $PLATFORM at $INSTALL_PREFIX"
curl -o miniconda.sh -L https://repo.anaconda.com/miniconda/Miniconda3-py39_$EXP_CONDA_VER-$EXP_CONDA_VER_SUFFIX-$PLATFORM.sh
bash miniconda.sh -b -p $INSTALL_PREFIX
source $SOURCE_SCRIPT
hash -r
conda config --set auto_update_conda false
conda install conda-libmamba-solver=$EXP_CONDA_VER libmamba=$EXP_LIBMAMBA_VER
conda config --set solver libmamba
conda config --set always_yes yes
# Useful for debugging any issues with conda
conda info -a
echo "Successfully installed at $INSTALL_PREFIX"
echo "Please initalize with '$HOME/miniconda-23.1.0/bin/conda init <shell-name>' (bash, zsh, etc.) and restart your terminal"
echo "Please run 'source setup/setup.sh' to set up the necessary conda environment"
echo "Please activate with 'source setup/activate_conda.sh' in every terminal where you want to use conda"
3 changes: 1 addition & 2 deletions setup/teardown.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
conda activate base
conda env remove --name emissioneval
conda deactivate && conda env remove --name emissioneval
8 changes: 2 additions & 6 deletions setup/teardown_conda.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
EXP_CONDA_VER=$1
INSTALL_PREFIX=$HOME/miniconda-$EXP_CONDA_VER

if [ -z $EXP_CONDA_VER ]; then
echo "Usage: teardown_conda.sh <version>"
else
INSTALL_PREFIX=$HOME/miniconda-$EXP_CONDA_VER
rm -rf $INSTALL_PREFIX
fi
rm -rf $INSTALL_PREFIX