mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Merge pull request #111 from yuvipanda/nbresuse
Install nbresuse by default
This commit is contained in:
15
docs/howto/nbresuse.rst
Normal file
15
docs/howto/nbresuse.rst
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
.. _howto/nbresuse:
|
||||||
|
|
||||||
|
=======================
|
||||||
|
Check your memory usage
|
||||||
|
=======================
|
||||||
|
|
||||||
|
The `nbresuse <https://github.com/yuvipanda/nbresuse>`_ extension is part of
|
||||||
|
the default installation, and tells you how much memory your user is using
|
||||||
|
right now, and what the memory limit for your user is. It is shown in the
|
||||||
|
top right corner of the notebook interface. Note that this is memory usage
|
||||||
|
for everything your user is running through the Jupyter notebook interface,
|
||||||
|
not just the specific notebook it is shown on.
|
||||||
|
|
||||||
|
.. image:: ../images/nbresuse.png
|
||||||
|
:alt: Memory limit / usage shown with nbresuse
|
||||||
@@ -40,16 +40,14 @@ Maximum memory allowed per user
|
|||||||
|
|
||||||
Depending on what kinda work your users are doing, they will use different amounts
|
Depending on what kinda work your users are doing, they will use different amounts
|
||||||
of memory. The easiest way to determine this is to run through a typical user
|
of memory. The easiest way to determine this is to run through a typical user
|
||||||
workflow yourself, and measure how much memory is used.
|
workflow yourself, and measure how much memory is used. You can use :ref:`howto/nbresuse`
|
||||||
|
to determine how much memory your user is using.
|
||||||
|
|
||||||
For example, you can begin running a Jupyter Notebook session on your JupyterHub, then open a
|
A good rule of thumb is to take the maximum amount of memory you used during
|
||||||
terminal on the JupyterHub and use ``top`` to track how much memory you use
|
|
||||||
as you go through the material. A good rule of thumb is to take the maximum amount of memory you used during
|
|
||||||
your session, and add 20-40% headroom for users to 'play around'. This is the
|
your session, and add 20-40% headroom for users to 'play around'. This is the
|
||||||
maximum amount of memory that should be given to each user.
|
maximum amount of memory that should be given to each user.
|
||||||
|
|
||||||
If users use *more* than this alloted amount of memory, their kernel will restart (and all
|
If users use *more* than this alloted amount of memory, their notebook kernel will restart.
|
||||||
their progress in the current session will be lost).
|
|
||||||
|
|
||||||
CPU
|
CPU
|
||||||
===
|
===
|
||||||
|
|||||||
BIN
docs/images/nbresuse.png
Normal file
BIN
docs/images/nbresuse.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
@@ -61,6 +61,7 @@ How-To guides answer the question 'How do I...?' for a lot of topics.
|
|||||||
howto/share-data
|
howto/share-data
|
||||||
howto/notebook-interfaces
|
howto/notebook-interfaces
|
||||||
howto/resource-estimation
|
howto/resource-estimation
|
||||||
|
howto/nbresuse
|
||||||
|
|
||||||
Authentication
|
Authentication
|
||||||
--------------
|
--------------
|
||||||
|
|||||||
42
integration-tests/test_extensions.py
Normal file
42
integration-tests/test_extensions.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
def test_serverextensions():
|
||||||
|
"""
|
||||||
|
Validate serverextensions we want are installed
|
||||||
|
"""
|
||||||
|
# jupyter-serverextension writes to stdout and stderr weirdly
|
||||||
|
proc = subprocess.run([
|
||||||
|
'/opt/tljh/user/bin/jupyter-serverextension',
|
||||||
|
'list', '--sys-prefix'
|
||||||
|
], stderr=subprocess.PIPE)
|
||||||
|
|
||||||
|
extensions = [
|
||||||
|
'jupyterlab 0.32.1',
|
||||||
|
'nbgitpuller 0.6.1',
|
||||||
|
'nteract_on_jupyter 1.8.1',
|
||||||
|
'nbresuse '
|
||||||
|
]
|
||||||
|
|
||||||
|
for e in extensions:
|
||||||
|
assert '{} \x1b[32mOK\x1b[0m'.format(e) in proc.stderr.decode()
|
||||||
|
|
||||||
|
def test_nbextensions():
|
||||||
|
"""
|
||||||
|
Validate nbextensions we want are installed & enabled
|
||||||
|
"""
|
||||||
|
# jupyter-nbextension writes to stdout and stderr weirdly
|
||||||
|
proc = subprocess.run([
|
||||||
|
'/opt/tljh/user/bin/jupyter-nbextension',
|
||||||
|
'list', '--sys-prefix'
|
||||||
|
], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||||
|
|
||||||
|
extensions = [
|
||||||
|
'nbresuse/main',
|
||||||
|
]
|
||||||
|
|
||||||
|
for e in extensions:
|
||||||
|
assert '{} \x1b[32m enabled \x1b[0m'.format(e) in proc.stdout.decode()
|
||||||
|
|
||||||
|
# Ensure we have 'OK' messages in our stdout, to make sure everything is importable
|
||||||
|
proc.stderr.decode() == ' - Validating: \x1b[32mOK\x1b[0m\n' * len(extensions)
|
||||||
@@ -203,6 +203,11 @@ def ensure_user_environment(user_requirements_txt_file):
|
|||||||
with conda.download_miniconda_installer(miniconda_version, miniconda_installer_md5) as installer_path:
|
with conda.download_miniconda_installer(miniconda_version, miniconda_installer_md5) as installer_path:
|
||||||
conda.install_miniconda(installer_path, USER_ENV_PREFIX)
|
conda.install_miniconda(installer_path, USER_ENV_PREFIX)
|
||||||
|
|
||||||
|
# nbresuse needs psutil, which requires gcc
|
||||||
|
apt.install_packages([
|
||||||
|
'gcc'
|
||||||
|
])
|
||||||
|
|
||||||
conda.ensure_conda_packages(USER_ENV_PREFIX, [
|
conda.ensure_conda_packages(USER_ENV_PREFIX, [
|
||||||
# Conda's latest version is on conda much more so than on PyPI.
|
# Conda's latest version is on conda much more so than on PyPI.
|
||||||
'conda==4.5.8'
|
'conda==4.5.8'
|
||||||
@@ -216,7 +221,9 @@ def ensure_user_environment(user_requirements_txt_file):
|
|||||||
'jupyterlab==0.32.1',
|
'jupyterlab==0.32.1',
|
||||||
'nteract-on-jupyter==1.8.1',
|
'nteract-on-jupyter==1.8.1',
|
||||||
# nbgitpuller for easily pulling in Git repositories
|
# nbgitpuller for easily pulling in Git repositories
|
||||||
'nbgitpuller==0.6.1'
|
'nbgitpuller==0.6.1',
|
||||||
|
# nbresuse to show people how much RAM they are using
|
||||||
|
'nbresuse==0.3.0'
|
||||||
])
|
])
|
||||||
|
|
||||||
if user_requirements_txt_file:
|
if user_requirements_txt_file:
|
||||||
|
|||||||
Reference in New Issue
Block a user