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
19 changes: 19 additions & 0 deletions dependencies/compile-generax.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@ if [ -z "$CONDA_PREFIX" ]; then
exit 1
fi

KEEP_EXISTING=0
while [[ $# -gt 0 ]]; do
case $1 in
--keep-existing)
KEEP_EXISTING=1
shift ;;
*)
shift ;;
esac
done

# Check if binary already exists in final location
if [ $KEEP_EXISTING -eq 1 ]; then
if [ -f "$CONDA_PREFIX/bin/generax" ]; then
echo "Using existing generax binary in \$CONDA_PREFIX/bin/ (skip compile)"
exit 0
fi
fi

# Clean up environment
rm -rf generax

Expand Down
21 changes: 20 additions & 1 deletion dependencies/compile-raxml-ng.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ if [ -z "$CONDA_PREFIX" ]; then
exit 1
fi

KEEP_EXISTING=0
while [[ $# -gt 0 ]]; do
case $1 in
--keep-existing)
KEEP_EXISTING=1
shift ;;
*)
shift ;;
esac
done

# Check if binary already exists in final location
if [ $KEEP_EXISTING -eq 1 ]; then
if [ -f "$CONDA_PREFIX/bin/raxml-ng" ]; then
echo "Using existing raxml-ng binary in \$CONDA_PREFIX/bin/ (skip compile)"
exit 0
fi
fi

# Clean up environment
rm -rf raxml-ng

Expand All @@ -21,7 +40,7 @@ git submodule update --init --recursive
# Build binary
mkdir build
cd build
cmake -DTERRAPHAST_ARCH_NATIVE=OFF -DENABLE_RAXML_SIMD=OFF -DENABLE_PLLMOD_SIMD=OFF ..
cmake -DTERRAPHAST_ARCH_NATIVE=OFF -DENABLE_RAXML_SIMD=OFF -DENABLE_PLLMOD_SIMD=OFF -DENABLE_SSE=OFF -DENABLE_AVX=OFF -DENABLE_AVX2=OFF ..
make -j 4

# Copy binary to final location
Expand Down
2 changes: 1 addition & 1 deletion docs/badges/coverage-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions docs/badges/ghwf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 90 additions & 39 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,104 @@ if [ $? -ne 0 ]; then
exit 1
fi

# Default environment name
# Default values
ENV_NAME="topiary"
NCBI_KEY=""
is_cluster="n"
overwrite="ignore"
NON_INTERACTIVE=0
KEEP_EXISTING=0

# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
-n|--name)
ENV_NAME="$2"
NON_INTERACTIVE=1
shift; shift ;;
-k|--ncbi-key)
NCBI_KEY="$2"
NON_INTERACTIVE=1
shift; shift ;;
--no-cluster)
is_cluster="n"
NON_INTERACTIVE=1
shift ;;
-y|--yes)
overwrite="y"
NON_INTERACTIVE=1
shift ;;
--keep-existing)
KEEP_EXISTING=1
NON_INTERACTIVE=1
shift ;;
*)
shift ;;
esac
done

# 1. Ask for environment name
echo
read -p "Enter conda environment name [$ENV_NAME]: " input_env
if [ ! -z "$input_env" ]; then
ENV_NAME=$input_env
if [ $NON_INTERACTIVE -eq 0 ]; then
echo
read -p "Enter conda environment name [$ENV_NAME]: " input_env
if [ ! -z "$input_env" ]; then
ENV_NAME=$input_env
fi
fi

# Check if environment already exists
ENV_EXISTS=0
conda env list | grep -q "^$ENV_NAME "
if [ $? -eq 0 ]; then
echo
read -p "Conda environment '$ENV_NAME' already exists. Overwrite? (y/N): " overwrite
if [[ ! "$overwrite" =~ ^[Yy]$ ]]; then
echo "Installation cancelled to avoid overwriting existing environment."
exit 0
ENV_EXISTS=1
if [ $NON_INTERACTIVE -eq 0 ]; then
echo
read -p "Conda environment '$ENV_NAME' already exists. Overwrite? (y/N): " input_overwrite
if [[ "$input_overwrite" =~ ^[Yy]$ ]]; then
overwrite="y"
fi
fi
else
overwrite="ignore"
fi

# 2. Ask for NCBI API key
echo
echo "--------------------------------------------------------------------------------"
echo "An NCBI key allows users to make more requests against the NCBI servers"
echo "when running BLAST etc. Using one is highly recommended to prevent "
echo "throttling. You may obtain one for free from the NCBI website."
echo "https://ncbiinsights.ncbi.nlm.nih.gov/2017/11/02/new-api-keys-for-the-e-utilities/"
echo "--------------------------------------------------------------------------------"
read -p "Enter NCBI API key (optional, press Enter to skip): " NCBI_KEY

# 3. Cluster installation prompt
echo
read -p "Are you installing on a cluster? (y/N): " is_cluster
if [[ "$is_cluster" =~ ^[Yy]$ ]]; then
if [ $NON_INTERACTIVE -eq 0 ]; then
echo
echo "--------------------------------------------------------------------------------"
echo "To run topiary on a cluster, you need to make sure that the generax and raxml-ng"
echo "components are compiled using your cluster's compilers and MPI. You will need"
echo "to modify the 'dependencies/compile-generax.sh' script to do so. More details"
echo "are at the top of the script. If you have already modified this script, please"
echo "proceed with the installation."
echo "An NCBI key allows users to make more requests against the NCBI servers"
echo "when running BLAST etc. Using one is highly recommended to prevent "
echo "throttling. You may obtain one for free from the NCBI website."
echo "https://ncbiinsights.ncbi.nlm.nih.gov/2017/11/02/new-api-keys-for-the-e-utilities/"
echo "--------------------------------------------------------------------------------"
read -p "Do you want to proceed with the installation? (Y/n): " is_cluster_proceed
if [[ "$is_cluster_proceed" =~ ^[Nn]$ ]]; then
echo "Installation cancelled."
exit 0
read -p "Enter NCBI API key (optional, press Enter to skip): " NCBI_KEY
fi

# 3. Cluster installation prompt
if [ $NON_INTERACTIVE -eq 0 ]; then
echo
read -p "Are you installing on a cluster? (y/N): " input_cluster
if [[ "$input_cluster" =~ ^[Yy]$ ]]; then
is_cluster="y"
echo "--------------------------------------------------------------------------------"
echo "To run topiary on a cluster, you need to make sure that the generax and raxml-ng"
echo "components are compiled using your cluster's compilers and MPI. You will need"
echo "to modify the 'dependencies/compile-generax.sh' script to do so. More details"
echo "are at the top of the script. If you have already modified this script, please"
echo "proceed with the installation."
echo "--------------------------------------------------------------------------------"
read -p "Do you want to proceed with the installation? (Y/n): " is_cluster_proceed
if [[ "$is_cluster_proceed" =~ ^[Nn]$ ]]; then
echo "Installation cancelled."
exit 0
fi
fi
fi

# Overwrite if we have to
if [[ "$overwrite" =~ ^[Yy]$ ]]; then
echo "Removing existing environment '$ENV_NAME'..."
conda deactivate
conda deactivate > /dev/null 2>&1
conda env remove -n $ENV_NAME -y
ENV_EXISTS=0
fi

# wipe local builds
Expand All @@ -72,8 +114,13 @@ for x in `find . -iname "__pycache__"`; do rm -rf $x; done
# Nuke conda environment (now handled by overwrite check above if it exists)
conda deactivate > /dev/null 2>&1

# Create new conda environment
conda env create -f environment.yml -n $ENV_NAME -y
# Create/Update conda environment
if [ $ENV_EXISTS -eq 0 ]; then
conda env create -f environment.yml -n $ENV_NAME -y
else
echo "Updating existing environment '$ENV_NAME'..."
conda env update -f environment.yml -n $ENV_NAME --prune
fi

# Set NCBI API key if provided
if [ ! -z "$NCBI_KEY" ]; then
Expand All @@ -86,8 +133,12 @@ conda run -n $ENV_NAME pip install coverage flake8 pytest genbadge[tests] pytest

# compile raxml and generax
cd dependencies
conda run -n $ENV_NAME bash compile-generax.sh
conda run -n $ENV_NAME bash compile-raxml-ng.sh
args=""
if [ $KEEP_EXISTING -eq 1 ]; then
args="--keep-existing"
fi
conda run -n $ENV_NAME bash compile-generax.sh $args
conda run -n $ENV_NAME bash compile-raxml-ng.sh $args

#return to start
cd ..
Expand Down
14 changes: 14 additions & 0 deletions src/topiary/_private/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
import multiprocessing as mp
import functools

try:
import resource
except ImportError:
resource = None

from topiary._private.mpi import get_mpi_env

class WrappedFunctionException(Exception):
Expand Down Expand Up @@ -265,6 +270,15 @@ def launch(cmd,
If the command terminates unexpectedly.
"""

# Attempt to increase stack size for child processes to avoid segfaults
# on large calculations (consistent with RAxML-NG recommendations).
if resource is not None:
try:
soft, hard = resource.getrlimit(resource.RLIMIT_STACK)
resource.setrlimit(resource.RLIMIT_STACK, (hard, hard))
except (resource.error, ValueError):
pass

# Go into working directory
cwd = os.getcwd()
os.chdir(run_directory)
Expand Down
Loading