question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exporting an environment

See original GitHub issue

Is it worth adding a couple of util scripts that would export the users current environment (conda or virtual env) and builds a docker image on top of daskdev/dask:latest?

Being able to pass a list of conda/pip packages is fine for relatively simple environments / prototyping but I can see value in something slightly more stable. Building a new image (Shouldn’t need to be done too often) will increase the connection time to the KubeCluster, but will reduce the worker start up time.

I have some basic POC of this, which I am currently using, which looks something like

  • On Jupyterlab, build my conda env / validate locally in notebook
  • Export the environment
  • Build a docker image on top of daskdev/dask:latest, using something like
dockerfile_template = (
    'FROM daskdev/dask:latest\n'
    'ADD {environment_file} /opt/app/environment.yml\n'
    'RUN /opt/conda/bin/conda env update -n dask -f /opt/app/environment.yml && \ \n'
    '    conda clean -tipsy'
)

def build_publish_dockerfile(context_dir, dockerfile_txt, tag):
    with pathlib.Path(os.getcwd()).joinpath('dockerfile').open('w') as f:
        f.write(dockerfile_txt)
    client.images.build(
        path='.', dockerfile='dockerfile', tag='%s/%s' % (DOCKER_HUB_REPO, tag), nocache=True
    )


def image_from_conda_env(env_name, tag, conda_bin='conda'):
    with tempfile.TemporaryDirectory() as tmp_dir:
        env_file = pathlib.Path(tmp_dir).joinpath('environment.yml')
        export_conda_env(env_name, env_file, conda_bin)
        dockerfile = dockerfile_template.format(env_file)
        build_publish_dockerfile(tmp_dir, dockerfile_txt=dockerfile, tag=tag)

image_from_conda_env('myenv', 'dask-worker-myenv')

k = KubeCluster(image='dask-worker-myenv')

Is this in the works? Or any thoughts on the above?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mrocklincommented, Feb 14, 2018

@jcrist 's conda-pack might also be of interest.

Ideally for the workers we can even drop conda and just distribute a zip of an environment.

1reaction
mrocklincommented, Feb 14, 2018

Lets keep it open for now if that’s alright. This is a valuable goal to keep in mind.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing environments - Conda
With conda, you can create, export, list, remove, and update environments that have different versions of Python and/or packages installed in them.
Read more >
How to Export and Load Anaconda Environments for Data ...
There's a way around it. You can use Anaconda to export a Python virtual environment to a YAML file you can then reuse...
Read more >
How to Export and Load Anaconda Environments for Data ...
Did you know you can export and share Anaconda environments? It boils down to a single Terminal command - here's how to get...
Read more >
Exporting an Environment - Python How Tos
Exporting an Environment · Ensure that the repository on your local machine matches the repository in GitHub. · With the proper environment activated...
Read more >
Exporting environment variables - IBM
You can export environment variables to a file (*.env) from the Projects page in the IBM® InfoSphere® DataStage® and QualityStage® Administrator client.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found