Added files
This commit is contained in:
parent
21ea76891e
commit
6b6bb902b6
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Set line endings to LF, even on Windows. Otherwise, execution within Docker fails.
|
||||
# See https://help.github.com/articles/dealing-with-line-endings/
|
||||
*.sh text eol=lf
|
93
helper.sh
Normal file
93
helper.sh
Normal file
@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
USAGE="Jupyterlab portable helper
|
||||
Implemented by Pierre Saunders, 2023
|
||||
|
||||
USAGE: $0 FLAG
|
||||
Available flags:
|
||||
i, -i, install, --install Install Jupyterlab locally to the script.
|
||||
k, -k, kernel, --kernel Install the R kernel extension to jupyter
|
||||
u, -u, update, --update Update every python packages of the local virtual environnement.
|
||||
U, -U, uninstall, --uninstall Uninstall Jupyterlab locally to the script.
|
||||
l, -l, launch, --launch Launch Jupyterlab locally to the script (Require installation beforehand).
|
||||
t, -t, tensorboard, --tensorboard Launch Tensorboard locally to the script (Require installation beforehand).
|
||||
h, -h, help, --help Which display this help message."
|
||||
|
||||
VENV_PATH=./venv
|
||||
JUPYTER_ROOT_PATH=./jupyter
|
||||
TENSORBOARD_LOG_DIR=./logs
|
||||
export R_LIBS_SITE=./libs
|
||||
export JUPYTER_ALLOW_INSECURE_WRITES=0
|
||||
export JUPYTERLAB_SETTINGS_DIR="$JUPYTER_ROOT_PATH"/settings
|
||||
export JUPYTERLAB_WORKSPACES_DIR="$JUPYTER_ROOT_PATH"/workspace
|
||||
export JUPYTER_CONFIG_DIR="$JUPYTER_ROOT_PATH"/config
|
||||
export JUPYTER_RUNTIME_DIR="$JUPYTER_ROOT_PATH"/runtime
|
||||
export JUPYTER_DATA_DIR="$JUPYTER_ROOT_PATH"/data
|
||||
|
||||
enable_venv(){
|
||||
test ! -d "$VENV_PATH" && echo 'Python virtual envrionnement not installed' && exit 1
|
||||
|
||||
case "$1" in
|
||||
--windows|-W) ENV_PATH="$VENV_PATH"/Scripts/activate ;;
|
||||
'') ENV_PATH="$VENV_PATH"/bin/activate ;;
|
||||
*) echo 'Invalid selected OS' && exit 1 ;;
|
||||
esac
|
||||
|
||||
test ! -f "$ENV_PATH" && echo 'Installation is corrupted, please reinstall' && exit 1
|
||||
. "$ENV_PATH"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
i|-i|install|--install)
|
||||
python -m venv "$VENV_PATH"
|
||||
mkdir -p "$JUPYTER_ROOT_PATH"/{settings,workspace,config,runtime,data} "$JUPYTERLAB_SETTINGS_DIR"/@jupyterlab/notebook-extension
|
||||
echo '{ "maxNumberOutputs": 0 }' > "$JUPYTERLAB_SETTINGS_DIR"/@jupyterlab/notebook-extension/tracker.jupyterlab-settings
|
||||
enable_venv "$2"
|
||||
python -m pip install --timeout 60 --retries 9999999999999999 -U pip setuptools
|
||||
pip install --timeout 60 --retries 9999999999999999 -r requirements.txt
|
||||
;;
|
||||
|
||||
k|-k|kernel|--kernel)
|
||||
enable_venv "$2"
|
||||
mkdir -p "$R_LIBS_SITE"
|
||||
Rscript -e 'install.packages("IRkernel",repos="http://cran.us.r-project.org");library(IRkernel);IRkernel::installspec()'
|
||||
;;
|
||||
|
||||
c|-c|check|--check)
|
||||
enable_venv "$2"
|
||||
pip check
|
||||
;;
|
||||
|
||||
u|-u|update|--update)
|
||||
enable_venv "$2"
|
||||
python -m pip install -U pip
|
||||
pip freeze | xargs -n1 pip install -U
|
||||
;;
|
||||
|
||||
U|-U|uninstall|--uninstall)
|
||||
rm -rf "$VENV_PATH" "$JUPYTER_ROOT_PATH" "$R_LIBS_SITE"
|
||||
;;
|
||||
|
||||
l|-l|launch|--launch)
|
||||
enable_venv "$2"
|
||||
if command -v jupyter >> /dev/null; then
|
||||
exec jupyter lab
|
||||
else
|
||||
echo "Jupyter lab isn't installed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
t|-t|tensorboard|--tensorboard)
|
||||
enable_venv "$2"
|
||||
if command -v tensorboard >> /dev/null; then
|
||||
tensorboard --logdir="$TENSORBOARD_LOG_DIR"
|
||||
else
|
||||
echo "Tensorboard isn't installed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
h|-h|help|--help) echo "$USAGE" ;;
|
||||
*) echo "$USAGE" && exit 1 ;;
|
||||
esac
|
Loading…
x
Reference in New Issue
Block a user