-
Notifications
You must be signed in to change notification settings - Fork 3
/
jupyter_config.sh
125 lines (108 loc) · 3.49 KB
/
jupyter_config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash
set -o errexit
set -o nounset
# Installs and configures jupyter notebook
JUPYTER_DEPS=(
requests pyyaml tqdm pycron ruamel.yaml pytest
google-cloud-bigquery
markdown pelican==3.6.3 numpy pandas db-dtypes matplotlib graphviz arrow seaborn
jupyter ipython dask jupyter_contrib_nbextensions jupyterlab qgrid
'pystan==3.*'
jupyter_nbextensions_configurator jupyter_contrib_nbextensions jupyter_http_over_ws
plotly dash
jupyter_dashboards jupyter_nbextensions_configurator nteract_on_jupyter
grpcio google-cloud-bigquery-storage pyarrow
nbconvert
prophet
piecash
pygwalker
)
check() {
local -r python_version=$(python3 --version)
if [[ "$python_version" != "Python 3."* ]]; then
echo "Got Python version $python_version"
echo "Check https://docs.brew.sh/Homebrew-and-Python"
# brew install [email protected] pyenv
# brew link --overwrite [email protected]
exit 99
fi
}
pyenv_setup() {
# Use pyenv to setup a stable python version
# Avoid brew, otherwise brew upgrade can break pipx apps with invalid/bad interpreter
pyenv --version
pyenv install --skip-existing 3.11.2
pyenv global 3.11.2
pyenv versions
"$(pyenv prefix)/bin/python" --version
"$(pyenv prefix)/bin/python" -m pip --version
export PATH="$(pyenv prefix)/bin:$PATH"
}
python_prepare() {
pyenv_setup
python -m pip install --upgrade pip setuptools pipx requests
python --version
python -m pip --version
python -m pipx --version
}
install() {
python_prepare
python -m pip install --upgrade "${JUPYTER_DEPS[@]}"
}
pipx_jupyter_check() {
set -o xtrace
pipx runpip jupyterlab check
jupyter-lab --version
jupyter --version
python --version
# Check python version used by jupyter executable
# We want to avoid brew versions
which jupyter
$(head -1 "$(which jupyter)" | cut -c3-) --version
}
pipx_install() {
#https://www.twoistoomany.com/blog/2020/11/24/how-i-work-pipx/
time python_prepare
#time pip download "${JUPYTER_DEPS[@]}"
time pipx install --force --verbose jupyterlab --python="$(which python3.11)" || pipx reinstall --verbose jupyterlab --python="$(which python3.11)"
time pipx inject --verbose --include-apps jupyterlab jupyter-core nbconvert
time "$HOME/.local/pipx/venvs/jupyterlab/bin/python" -m pip install "${JUPYTER_DEPS[@]}"
pipx_jupyter_check
}
config() {
# https://ndres.me/post/best-jupyter-notebook-extensions/
# https://codeburst.io/jupyter-notebook-tricks-for-data-science-that-enhance-your-efficiency-95f98d3adee4
jupyter dashboards quick-setup --sys-prefix
jupyter nbextensions_configurator enable --sys-prefix
jupyter contrib nbextension install --sys-prefix
for e in execute_time/ExecuteTime collapsible_headings/main autosavetime/main scratchpad/main notify/notify google.cloud.bigquery jupytemplate/main; do
jupyter nbextension enable "$e";
done
# https://research.google.com/colaboratory/local-runtimes.html
a
jupyter serverextension enable --sys-prefix jupyter_http_over_ws
}
setup() {
pipx_install
#config
}
server() {
jupyter notebook \
--NotebookApp.allow_origin='https://colab.research.google.com' \
--port=8888
}
main() {
if [[ $# -gt 0 ]]; then
"$@"
else
pipx_install
#setup
fi
}
time main "$@"
# It can be installed from within Jupyter with:
# ! curl https://raw.githubusercontent.com/labianchin/dotfiles/master/jupyter_config.sh | bash -x
# Then restart Kernel/Jupyter
# Ideas to try:
# https://github.com/quantopian/qgrid
# https://ipywidgets.readthedocs.io/en/latest/user_install.html