Skip to content

Commit 7f9fa14

Browse files
author
Denis Jelovina
committed
Enhance installation instructions and add run script for exercise 9
1 parent 398eb78 commit 7f9fa14

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

beamer-tutorial.tex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,12 +1020,16 @@ \subsection{5) Interoperability with existing code: Transition Paths \& Python}
10201020
10211021
\href{https://pypi.org/project/alp-graphblas/}{PyPI project: alp-graphblas}
10221022
1023-
Install with:
1023+
Install from public PyPI repository:
10241024
\begin{lstlisting}[style=terminal,language=bash]
1025-
conda activate py311 # make sure to have > python3.11 version
10261025
pip install "alp-graphblas"
10271026
\end{lstlisting}
10281027
1028+
For offline installation, download the wheel file from PyPI and install from the file.
1029+
Example, this scripts created a temp conda env, installs pyalp, runs the scripts and cleans up:
1030+
\textbf{solutions/ex9/run.sh}
1031+
use this script to run the examples in an isolated environment with proper python version.
1032+
10291033
\begin{lstlisting}[language=Python, basicstyle=\ttfamily\tiny, frame=single, showstringspaces=false]
10301034
import numpy as np
10311035
N, M = 5, 5

exercises/ex9/run.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# -------------------------------
2+
# CONFIGURATION
3+
# -------------------------------
4+
BASE_ENV="py311"
5+
WHEEL_DIR="$HOME/download"
6+
SCRIPT_PATH="$HOME/download/GitHub/ALP-Tutorial/exercises/ex9/exercise9_starter.py"
7+
PKG_NAME="alp_graphblas"
8+
9+
# -------------------------------
10+
# CREATE UNIQUE TEMP ENV NAME
11+
# -------------------------------
12+
RAND_SUFFIX=$(tr -dc 'a-z0-9' < /dev/urandom | head -c 6)
13+
TMP_ENV="tmp_env_${RAND_SUFFIX}"
14+
15+
echo ">>> Creating temporary environment: $TMP_ENV"
16+
17+
# -------------------------------
18+
# CLONE BASE ENV
19+
# -------------------------------
20+
conda create --name "$TMP_ENV" --clone "$BASE_ENV" -y
21+
22+
# -------------------------------
23+
# ACTIVATE TEMP ENV AND INSTALL WHEEL
24+
# -------------------------------
25+
source "$(conda info --base)/etc/profile.d/conda.sh"
26+
conda activate "$TMP_ENV"
27+
28+
echo ">>> Installing wheel $PKG_NAME from $WHEEL_DIR"
29+
pip install --no-index --find-links "$WHEEL_DIR" "$PKG_NAME"
30+
31+
# -------------------------------
32+
# RUN SCRIPT
33+
# -------------------------------
34+
echo ">>> Running script: $SCRIPT_PATH"
35+
python3 "$SCRIPT_PATH"
36+
37+
# -------------------------------
38+
# CLEAN UP
39+
# -------------------------------
40+
echo ">>> Deactivating and deleting temporary environment: $TMP_ENV"
41+
conda deactivate
42+
conda remove -y --name "$TMP_ENV" --all
43+
44+
echo ">>> Done."

0 commit comments

Comments
 (0)