GithubHelp home page GithubHelp logo

nickeubank / coursera-labs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from coursera/coursera-labs

0.0 1.0 0.0 31.04 MB

License: Apache License 2.0

Dockerfile 14.93% CSS 1.00% JavaScript 50.09% Python 12.37% Shell 7.92% HTML 1.81% Smarty 7.09% Jupyter Notebook 4.80%

coursera-labs's Introduction

Coursera Labs

This repository provides resources for creating custom images on Coursera Labs. It includes files to build and run images on Coursera Labs, including the source files to set up our (5) base images.

This resource may be particularly helpful for those looking to:

  1. add small modifications to the existing default images on Coursera Labs
  2. add a submit button or bypass the token authentication flow for your own Jupyter Notebook images

Quick Start

  1. Install Docker if not installed already

  2. Build run-lab image

    docker build -t run-lab -f run-lab/Dockerfile .
    

    The run-lab image is a Dockerized version of run-lab/coursera-lab.py script. run-lab/coursera-lab.py script simulates Coursera Labs Docker build and run procedures.

  3. Create a folder with your custom image files and manifest.json

    The folders jupyter/datascience-notebook/v2, jupyter/scipy-notebook/v2 and jupyter/tensorflow-notebook/v2 include the files that build our v2 base images. Please feel free to use these folders to test out this build flow.

    We also strongly recommend using the provided images as the basis for your custom images.

    Additionally, Coursera Labs script uses manifest.json to read configurations specific to your image. Details about manifest.json can be found here.

  4. Build your image locally

    Jupyter Notebook images: Build Jupyter Notebook image by running the following command. The --add-submit-button option also takes care of the token authentication flow, so you should use this option for all Jupyter Notebook images you plan on using on Coursera Labs.

    ./run-lab/run.sh build <path to image folder> --add-submit-button
    

    This will create a new folder called /generated under your <path to image folder>.

    Other web app images: Build image of an application other than Jupyter Notebook by running the following command:

    ./run-lab/run.sh build <path to image folder>
    
  5. Test your image locally Run an instance of the built custom image by running the following command:

    ./run-lab/run.sh run <path to image folder>
    

    For example, if you built the tensorflow-notebook image that we provided,

    ./run-lab/run.sh run jupyter/tensorflow-notebook/v2
    

    If you see a message that asks: Tell me which volumes to mount for the following container volumes, enter the local machine path from which files are to be mounted at that specific mount path.

    You'll see a message that says Starting instance of <image-name> listening on localhost:<port>. Then go to localhost:<port> in your browser to play with the custom image.

  6. Upload your image to the platform

    The build step should have created a folder called /generated under your <path to image folder>. In this folder, there will be a Dockerfile with all the relevant commands to build the image on the platform.

    If you do not need any folders or files outside of the Dockerfile, you can create a .zip of the Dockerfile and then upload it as a Custom Image to the Lab Manager using the "Upload Build Files" button.

    If you do need any folders or files to successfully build the image (e.g. requirements.txt), make sure to include these files in the .zip file such that the Dockerfile can reference it successfully during the build process. Make sure the Dockerfile is located in the root directory.

    You do not need to add manifest.json to the .zip file to upload successfully to the platform, unless your Dockerfile explicitly uses this.

Image configurations using manifest.json

Coursera Labs script uses manifest.json to read configurations specific to your image. Below is an example of manifest.json file.

{
  "name": "coursera/tensorflow-notebook",
  "version": "1.0",
  "httpPort": 8888,
  "mounts": [
    {
      "path": "/home/jovyan/work"
    }
  ],
  "environmentVars": [
    {
      "name": "NAME",
      "value": "VALUE"
    }
  ]
}
  • name: the image name
  • version: optional, the image tag
  • httpPort: the exposed port of the container
  • mounts: mount list of volumes to the container. Files mounted at these mount paths persist across lab sessions in Coursera Labs. In other words, you need at least one mount path to persist files across lab sessions.
  • environmentVars: optional, list of environment variables of the container

Unit Tests

We're adding in unit testing frameworks to give us more confidence that our images do what we want them to do. For now, we only have unit tests in place for our nbgrader images, to verify that traceback redaction is working as expected. You can take advantage of these unit-tests with the command

./run-lab/run.sh test jupyter/nbgrader

You will be prompted to enter a filepath to which the rich feedback file will generated.

Examples

Example #1: Build tensorflow-notebook v2 image under build directory jupyter/tensorflow-notebook/v2. Dockerfile and manifest.json are required to start the build.

./run-lab/run.sh build jupyter/tensorflow-notebook/v2

Example #2: Build tensorflow-notebook image with Coursera submit button. This only works with Jupyter Notebook images.

./run-lab/run.sh build jupyter/tensorflow-notebook/v2 --add-submit-button

Example #3: Run an instance of the built tensorflow-notebook image.

./run-lab/run.sh run jupyter/tensorflow-notebook/v2

coursera-labs's People

Contributors

alyang-coursera avatar ji-su-lee avatar josephl310 avatar nickeubank avatar pxu-coursera avatar rbenkar-coursera avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.