Skip to content

Commit

Permalink
add python.defaultInterpreterPath to devcontainer.json config (#6)
Browse files Browse the repository at this point in the history
set ipykernel name and display_name
replaced deprecated c.ServerApp.token with c.IdentityProvider.token in notebook config
updated readme, changelog, notebooks
  • Loading branch information
jakoch committed Feb 14, 2024
1 parent f6d9466 commit 509ce88
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 87 deletions.
34 changes: 18 additions & 16 deletions .devcontainer/amd64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,28 @@ RUN pip config --user set global.disable-pip-version-check true && \
pip install --upgrade wheel

# Install Python Packages
# Note: leave the 2 pip install runs, else pip has a problem resolving the dependencies
# Note: using multiple pip install runs is intentional, else pip has a problem resolving the dependencies
RUN pip install ipykernel docutils jupyter notebook jupyterhub && \
pip install \
watermark pyyaml pylint h5py \
tensorflow \
matplotlib seaborn plotly graphviz \
keras --no-deps \
opencv-python-headless \
imutils \
numpy pandas pandas-datareader bottleneck \
scipy scikit-learn \
duckdb \
sqlalchemy \
pyautogui \
requests_cache \
yfinance alpha_vantage nasdaq-data-link finnhub-python financetoolkit financedatabase \
statsmodels
watermark pyyaml pylint h5py \
tensorflow && \
pip install --prefer-binary \
matplotlib seaborn plotly graphviz \
keras --no-deps \
opencv-python-headless \
imutils && \
pip install --prefer-binary \
numpy pandas pandas-datareader bottleneck \
scipy scikit-learn \
duckdb \
sqlalchemy \
pyautogui \
requests_cache \
yfinance alpha_vantage nasdaq-data-link finnhub-python financetoolkit financedatabase \
statsmodels

# Install ipykernel
RUN /opt/venv/bin/python -m ipykernel install --user --name="Python_3"
RUN /opt/venv/bin/python -m ipykernel install --user --name="jupyter_devbox" --display-name="jupyter_devbox_python3_venv"

# Re-enable dialog mode for apt-get
ENV DEBIAN_FRONTEND=dialog
34 changes: 18 additions & 16 deletions .devcontainer/arm64v8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,26 +105,28 @@ RUN pip config --user set global.disable-pip-version-check true && \

# Install Python Packages
# prefer-binary = prefer to download the precompiled wheel, even if source is newer
# Note: leave the 2 pip install runs, else pip has a problem resolving the dependencies
# Note: using multiple pip install runs is intentional, else pip has a problem resolving the dependencies
RUN pip install ipykernel docutils jupyter notebook jupyterhub && \
pip install --prefer-binary \
watermark pyyaml pylint h5py \
tensorflow \
matplotlib seaborn plotly graphviz \
keras --no-deps \
opencv-python-headless \
imutils \
numpy pandas pandas-datareader bottleneck \
scipy scikit-learn \
duckdb \
sqlalchemy \
pyautogui \
requests_cache \
yfinance alpha_vantage nasdaq-data-link finnhub-python financetoolkit financedatabase \
statsmodels
watermark pyyaml pylint h5py \
tensorflow && \
pip install --prefer-binary \
matplotlib pillow seaborn plotly graphviz \
keras --no-deps \
opencv-python-headless \
imutils && \
pip install --prefer-binary \
numpy pandas pandas-datareader bottleneck \
scipy scikit-learn \
duckdb \
sqlalchemy \
pyautogui \
requests_cache \
yfinance alpha_vantage nasdaq-data-link finnhub-python financetoolkit financedatabase \
statsmodels

# Install ipykernel
RUN /opt/venv/bin/python -m ipykernel install --user --name="Python_3"
RUN /opt/venv/bin/python -m ipykernel install --user --name="jupyter_devbox" --display-name="jupyter_devbox_python3_venv"

# Re-enable dialog mode for apt-get
ENV DEBIAN_FRONTEND=dialog
6 changes: 5 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
"streetsidesoftware.code-spell-checker"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "bash"
"terminal.integrated.defaultProfile.linux": "bash",
// automatic activation of the selected python environment for the terminal = venv activate
"python.terminal.activateEnvironment": true,
// help vscode to find the python in our venv
"python.defaultInterpreterPath": "/opt/venv/bin/python"
}
}
},
Expand Down
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,24 @@ The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html
- ca-certificates
- tzdata
- locales
- devcontainer.json:
- added python.terminal.activateEnvironment
- added python.defaultInterpreterPath ([#6](https://github.com/jakoch/jupyter-devbox/issues/6))

### Changed

- Dockerfile:
- use multiple pip install runs, else the dependencies do not resolve correctly
- reduced number of run sections
- added locale setup
- changed ipykernel name ("jupyter_debvox") and display_name
- jupyter_notebook_config.py:
- used the ipykernel name as c.MultiKernelManager.default_kernel_name
- renamed deprecated c.ServerApp.token to c.IdentityProvider.token
- moved Dockerfile for amd64 into folder ".devcontainer/amd64"
- changed github workflow into build matrix for amd64 and arm64
- with an extra step, which uploads the merged manifest file
- changed github workflow to build a multi-arch container for amd64 and arm64
- firstly, build each container image and a digest/manifest,
- secondly, upload the merged digests as one manifest file
- changed python packages:
- opencv-python to opencv-python-headless

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ FROM ghcr.io/jakoch/jupyter-devbox:latest
- [./devcontainer/amd64/Dockerfile][amd64_dockerfile]
- aarch64 - linux/aarch64, linux/arm64/v8, linux/arm64v8
- [./devcontainer/arm64v8/Dockerfile][arm64_dockerfile]
- not supported: linux/arm64/v7, linux/arm64v7
- not supported:
- armel
- armhf, linux/arm64/v7, linux/arm64v7

- You can check your platform and available features with
- `dpkg --print-architecture`
Expand Down
13 changes: 9 additions & 4 deletions conf/.jupyter/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@

c = get_config() # noqa - get the config object

# for IPython Kernel Options, see https://ipython.readthedocs.io/en/stable/config/options/kernel.html
c.IPKernelApp.pylab = 'inline' # in-line figure when using Matplotlib

c.ServerApp.ip = '*' # Set ip to '*' to bind on all interfaces (ips) for the public server
#c.NotebookApp.ip = '0.0.0.0'
c.ServerApp.port = 8888
c.ServerApp.open_browser = False # do not open a browser window by default when using notebooks
c.ServerApp.token = '' # No token. Always use jupyter over ssh tunnel
c.IdentityProvider.token = '' # No token. Always use jupyter over ssh tunnel (formerly ServerApp.token)
c.LabApp.token = '' # No token. Always use jupyter over ssh tunnel
c.ServerApp.password = ''
c.ServerApp.notebook_dir = "/workspaces/jupyter-devbox/notebooks"
c.ServerApp.allow_root = True # Allow to run Jupyter from root user inside Docker container
c.ServerApp.root_dir = "/workspaces/jupyter-devbox/notebooks"
c.ServerApp.allow_root = True # Allow to run Jupyter from root user inside Docker container
c.ServerApp.allow_origin = '*'
c.ServerApp.allow_remote_access = True
c.ServerApp.tornado_settings = {
Expand All @@ -29,7 +31,10 @@
}
}

c.MultiKernelManager.default_kernel_name = 'python3'
# this name needs to match the kernel name set by "ipykernel install --name" in the Dockerfile
# you can list all available kernels using `jupyter kernelspec list` on the CLI
# you can check for the "default" kernel via jupyter api endpoint http://localhost:8888/api/kernelspecs
c.MultiKernelManager.default_kernel_name = 'jupyter_devbox'

# to output both image/svg+xml and application/pdf plot formats in the notebook file
c.InlineBackend.figure_formats = {"png", "jpeg", "svg", "pdf"}
40 changes: 21 additions & 19 deletions notebooks/check_devbox.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -23,9 +23,9 @@
"IPython version : 8.21.0\n",
"\n",
"pip : 24.0\n",
"notebook : 7.0.8\n",
"notebook : 7.1.0\n",
"jupyterhub : 4.0.2\n",
"jupyterlab : 4.0.12\n",
"jupyterlab : 4.1.1\n",
"ipykernel : 6.29.2\n",
"numpy : 1.26.4\n",
"scipy : 1.12.0\n",
Expand All @@ -37,7 +37,7 @@
"scikit-learn: 1.4.0\n",
"plotly : 5.18.0\n",
"keras : 2.15.0\n",
"sqlalchemy : 2.0.26\n",
"sqlalchemy : 2.0.27\n",
"statsmodels : 0.14.1\n",
"imutils : 0.5.4\n",
"\n",
Expand Down Expand Up @@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -110,7 +110,7 @@
"defusedxml 0.7.1\n",
"dill 0.3.8\n",
"docutils 0.20.1\n",
"duckdb 0.9.2\n",
"duckdb 0.10.0\n",
"executing 2.0.1\n",
"fastjsonschema 2.19.1\n",
"financedatabase 2.2.1\n",
Expand All @@ -119,7 +119,7 @@
"flatbuffers 23.5.26\n",
"fonttools 4.48.1\n",
"fqdn 1.5.1\n",
"frozendict 2.4.0\n",
"frozendict 2.3.10\n",
"frozenlist 1.4.1\n",
"gast 0.5.4\n",
"google-auth 2.27.0\n",
Expand All @@ -128,8 +128,11 @@
"graphviz 0.20.1\n",
"greenlet 3.0.3\n",
"grpcio 1.60.1\n",
"h11 0.14.0\n",
"h5py 3.10.0\n",
"html5lib 1.1\n",
"httpcore 1.0.2\n",
"httpx 0.26.0\n",
"idna 3.6\n",
"importlib-metadata 7.0.1\n",
"imutils 0.5.4\n",
Expand All @@ -156,7 +159,7 @@
"jupyter_server_terminals 0.5.2\n",
"jupyter-telemetry 0.1.0\n",
"jupyterhub 4.0.2\n",
"jupyterlab 4.0.12\n",
"jupyterlab 4.1.1\n",
"jupyterlab_pygments 0.3.0\n",
"jupyterlab_server 2.25.2\n",
"jupyterlab_widgets 3.0.10\n",
Expand All @@ -182,7 +185,7 @@
"nbconvert 7.16.0\n",
"nbformat 5.9.2\n",
"nest-asyncio 1.6.0\n",
"notebook 7.0.8\n",
"notebook 7.1.0\n",
"notebook_shim 0.2.3\n",
"numba 0.59.0\n",
"numexpr 2.9.0\n",
Expand Down Expand Up @@ -238,7 +241,7 @@
"requests-oauthlib 1.3.1\n",
"rfc3339-validator 0.1.4\n",
"rfc3986-validator 0.1.1\n",
"rpds-py 0.17.1\n",
"rpds-py 0.18.0\n",
"rsa 4.9\n",
"ruamel.yaml 0.18.6\n",
"ruamel.yaml.clib 0.2.8\n",
Expand All @@ -250,10 +253,9 @@
"six 1.16.0\n",
"sniffio 1.3.0\n",
"soupsieve 2.5\n",
"SQLAlchemy 2.0.26\n",
"SQLAlchemy 2.0.27\n",
"stack-data 0.6.3\n",
"statsmodels 0.14.1\n",
"tenacity 8.2.3\n",
"tensorboard 2.15.2\n",
"tensorboard-data-server 0.7.2\n",
"tensorflow 2.15.0.post1\n",
Expand Down Expand Up @@ -302,15 +304,15 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" total used free shared buff/cache available\n",
"Mem: 31697 3388 26624 4 2096 28309\n",
"Mem: 31697 4177 14325 5 13647 27520\n",
"Swap: 8192 0 8192\n"
]
}
Expand All @@ -328,7 +330,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand All @@ -354,7 +356,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -504,7 +506,7 @@
"Automagic is ON, % prefix IS NOT needed for line magics."
]
},
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -516,9 +518,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python_3",
"display_name": "jupyter_devbox_python3_venv",
"language": "python",
"name": "python_3"
"name": "jupyter_devbox"
},
"language_info": {
"codemirror_mode": {
Expand Down
15 changes: 11 additions & 4 deletions notebooks/finance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -27,7 +27,14 @@
"text": [
"/opt/venv/lib/python3.11/site-packages/yfinance/utils.py:775: FutureWarning: The 'unit' keyword in TimedeltaIndex construction is deprecated and will be removed in a future version. Use pd.to_timedelta instead.\n",
" df.index += _pd.TimedeltaIndex(dst_error_hours, 'h')\n",
"[*********************100%%**********************] 1 of 1 completed\n"
"[*********************100%%**********************] 1 of 1 completed"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n"
]
},
{
Expand Down Expand Up @@ -107,9 +114,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "jupyter_devbox_python3_venv",
"language": "python",
"name": "python3"
"name": "jupyter_devbox"
},
"language_info": {
"codemirror_mode": {
Expand Down
8 changes: 4 additions & 4 deletions notebooks/statsmodels.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"Dep. Variable: Lottery R-squared: 0.348\n",
"Model: OLS Adj. R-squared: 0.333\n",
"Method: Least Squares F-statistic: 22.20\n",
"Date: Tue, 13 Feb 2024 Prob (F-statistic): 1.90e-08\n",
"Time: 10:46:04 Log-Likelihood: -379.82\n",
"Date: Wed, 14 Feb 2024 Prob (F-statistic): 1.90e-08\n",
"Time: 13:52:32 Log-Likelihood: -379.82\n",
"No. Observations: 86 AIC: 765.6\n",
"Df Residuals: 83 BIC: 773.0\n",
"Df Model: 2 \n",
Expand Down Expand Up @@ -67,9 +67,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python_3",
"display_name": "jupyter_devbox_python3_venv",
"language": "python",
"name": "python_3"
"name": "jupyter_devbox"
},
"language_info": {
"codemirror_mode": {
Expand Down
Loading

0 comments on commit 509ce88

Please sign in to comment.