Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo2docker dask fixes #49

Merged
merged 5 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions base-notebook/binder/dask_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,33 @@ distributed:
limit: 5s

kubernetes:
name: dask-{JUPYTERHUB_USER}-{uuid}
worker-template:
metadata:
spec:
restartPolicy: Never
containers:
- args:
- dask-worker
- --nthreads
- '2'
- --no-bokeh
- --memory-limit
- 7GB
- --death-timeout
- '60'
image: ${JUPYTER_IMAGE_SPEC}
name: dask-worker
resources:
limits:
cpu: "1.75"
memory: 7G
requests:
cpu: 1
memory: 7G
- name: dask-${JUPYTERHUB_USER}
image: ${JUPYTER_IMAGE_SPEC}
args:
- dask-worker
- --nthreads
- '2'
- --no-bokeh
- --memory-limit
- 7GB
- --death-timeout
- '60'
resources:
limits:
cpu: "1.75"
memory: 7G
requests:
cpu: 1
memory: 7G

labextension:
factory:
module: dask_kubernetes
class: KubeCluster
args: []
kwargs: {}
4 changes: 2 additions & 2 deletions base-notebook/binder/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- dask-kubernetes>=0.8.0
- nbserverproxy
- ipywidgets
- graphviz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to try this again but I have a seem to remember this not working in a recent test. We'll see.

- pip
- pip:
- dask_labextension==0.3.3
- graphviz
- dask_labextension==0.3.1
8 changes: 8 additions & 0 deletions base-notebook/binder/tests/test_dask_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ def client():
def test_check_dask_version(client):
print(client)
versions = client.get_versions(check=True)


def test_dask_config():
import dask

assert '/srv/conda/envs/notebook/etc/dask' in dask.config.paths
assert dask.config.config['labextension']['factory']['class'] == 'KubeCluster'
assert 'worker-template' in dask.config.config['kubernetes']
17 changes: 16 additions & 1 deletion base-notebook/binder/tests/test_imports.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import importlib

import sys
from distutils.version import LooseVersion
import pytest

packages = [
Expand All @@ -10,3 +11,17 @@
@pytest.mark.parametrize('package_name', packages, ids=packages)
def test_import(package_name):
importlib.import_module(package_name)

# for current repo2docker config
def test_conda_environment():
assert sys.prefix == '/srv/conda/envs/notebook'

# would be better to automatically get these from environment.yml
def test_pinned_versions():
import tornado
import dask_kubernetes
import dask_labextension

assert LooseVersion(tornado.version) == LooseVersion('5.1.1')
assert LooseVersion(dask_kubernetes.__version__) >= LooseVersion('0.8')
assert LooseVersion(dask_labextension.__version__) == LooseVersion('0.3.1')
13 changes: 7 additions & 6 deletions onbuild/r2d_overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ def binder_path(path):

@become(NB_UID)
def apply_environment():
NB_PYTHON_PREFIX = os.environ['NB_PYTHON_PREFIX']
env_path = binder_path('environment.yml')
if os.path.exists(env_path):
return [
f'conda env update -n root -f {env_path}',
f'conda clean -tipsy',
f'conda list -n root',
f'conda env update -p {NB_PYTHON_PREFIX} -f {env_path}',
f'conda clean --all -f -y',
f'conda list -p {NB_PYTHON_PREFIX}',
f'rm -rf /srv/conda/pkgs'
]

Expand All @@ -46,10 +47,10 @@ def apply_environment():
def apply_requirements():
req_path = binder_path('requirements.txt')
env_path = binder_path('environment.yml')

NB_PYTHON_PREFIX = os.environ['NB_PYTHON_PREFIX']
if os.path.exists(req_path) and not os.path.exists(env_path):
return [
f'python3 -m pip install --no-cache-dir -r {req_path}'
f'{NB_PYTHON_PREFIX}/bin/pip install --no-cache-dir -r {req_path}'
]


Expand Down Expand Up @@ -124,4 +125,4 @@ def main():
raise Exception("start isn't implemented yet")

if __name__ == '__main__':
main()
main()
1 change: 1 addition & 0 deletions pangeo-notebook/binder/apt.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
graphviz
vim