From a128a2e965ad0b00118739355b56eaeac8be8a17 Mon Sep 17 00:00:00 2001 From: Eric Ma Date: Thu, 21 Apr 2022 21:02:45 -0400 Subject: [PATCH] Upgrade environment and devcontainer (#284) * Update devcontainer definition. * Switch to using mambaforge for Docker container base image. * Update environment.yml to use Python=3.9 * Add instructions for VSCode Development Containers. * Released version of NetworkX. * Update docs with Windows/Linux commands. --- .devcontainer/Dockerfile | 3 +-- .devcontainer/devcontainer.json | 4 ++-- environment.yml | 4 ++-- notebooks/00-preface/01-setup.md | 37 +++++++++++++++++++++++++++++++- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 3e9cc813..9ed65baa 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. #------------------------------------------------------------------------------------------------------------- -FROM continuumio/miniconda3 +FROM condaforge/mambaforge # Avoid warnings by switching to noninteractive ENV DEBIAN_FRONTEND=noninteractive @@ -31,7 +31,6 @@ RUN apt-get update \ && /opt/conda/bin/pip install pylint \ # # Update Python environment based on environment.yml (if present) - && /opt/conda/bin/conda install -c conda-forge mamba -y \ && if [ -f "/tmp/conda-tmp/environment.yml" ]; then /opt/conda/bin/mamba env update -n base -f /tmp/conda-tmp/environment.yml; fi \ && rm -rf /tmp/conda-tmp \ # diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6eb91778..5c48ddf2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -16,11 +16,11 @@ "extensions": [ "ms-python.vscode-pylance", "ms-python.python" - ] + ], // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], // Uncomment the next line to run commands after the container is created - for example installing git. - // "postCreateCommand": "apt-get update && apt-get install -y git", + "postCreateCommand": "python -m pip install -e .", // Uncomment when using a ptrace-based debugger like C++, Go, and Rust // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker. diff --git a/environment.yml b/environment.yml index 8aa12f84..ba75fcb7 100644 --- a/environment.yml +++ b/environment.yml @@ -2,7 +2,7 @@ name: nams # Network Analysis Made Simple channels: - conda-forge dependencies: - - python=3.8 + - python=3.9 - black - ffmpeg - gitpython # used by mkdocs @@ -19,7 +19,7 @@ dependencies: - nbconvert-utils>=0.6 - nbconvert>=6.0.7 - nbstripout>=0.3.9 - - networkx=2.6.3 + - networkx>=2.6.3 - numpy - nxviz - pandas>=1.0 diff --git a/notebooks/00-preface/01-setup.md b/notebooks/00-preface/01-setup.md index 0d34f0f6..cde0a42e 100644 --- a/notebooks/00-preface/01-setup.md +++ b/notebooks/00-preface/01-setup.md @@ -29,10 +29,45 @@ which contains data loaders and solutions. python setup.py develop ``` +## VSCode Development Containers + +Assuming that you're using Visual Studio Code +and have attempted to use development containers before, +you can run the Network Analysis Made Simple tutorial content +inside a development container. +After Binder, this is the second easiest way to get set up. +You need to have Docker installed on your computer +but don't worry -- you won't have to execute any Docker commands :). + +### Install the Remote Containers extension + +This is found in the Extensions marketplace. + +![Remote Containers extension.](https://user-images.githubusercontent.com/2631566/164070556-7ca675bc-d700-4e1b-a8e4-f07bc77c79f8.png) + +### Clone the repository to your local drive + +```bash +git clone https://github.com/ericmjl/Network-Analysis-Made-Simple.git +``` + +### Open the repository in VSCode + +Use `Cmd+Shift+P` (on macOS) or `Ctrl+Shift+P` (on Linux/Windows) +to open the command palette, and search for "Rebuild and Reopen in Container" as below: + +![Search for "Rebuild and Reopen in Container"](https://user-images.githubusercontent.com/2631566/164071398-ff115bd0-02fc-4827-935a-2785a354360f.png) + +Hit enter and wait for the container to build automagically. This may take around 10 minutes or so, depending on your system. + +![Development container will be built.](https://user-images.githubusercontent.com/2631566/164071594-d3ddf3fa-9c78-48f3-be56-09a453f8eb0a.png) + ## `conda` environments We also recommend the use of `conda` environments! -If you are feeling confident enough to set up a conda environment at the terminal, +Use this if you're not already using one of the options above. +If you are feeling confident enough to set up +a conda environment at the terminal, then follow along. (We'll be assuming you've already cloned the repository locally.)