Giter VIP home page Giter VIP logo

jiffylab's Introduction

JiffyLab

JiffyLab is a project to provide an entirely web based environment for the instruction, or lightweight use of, Python and UNIX shell environment with zero-configuration of the user's machine.

Currently in early development status

The Problem

Python is a wonderful first language, but sometimes introducing people to Python is bogged down by making sure that everyone has a usable development environment. This can often set a tone of frustration for beginners, as well as completely drain instructor and assistant's time, instead of letting everyone "dive in".

There are other advantages to having a standardized environment:

  • If the instructor is projecting the same thing as what the student sees, the student will be less likely to be thrown off by inconsequential details such as differences in the shell prompt (> vs $ etc), different syntax highlighting colors, or the use of some tool or feature not installed on the student's machine.
  • When all students are using the same exact setup, they are more likely to be capable of helping their neighbor, because if they got it working on their screen, they can probably get it working on their neighbor's - peers and instructors can more effectively visually "diff" what might be different.
  • Even if the setup of a student machine goes smoothly at a technical level, it can still take time, especially if a significant number of material needs to be downloaded over slow links, or requires significant build time.

Trade-offs

Messing around with tools and your machine's setup is of course part of being a developer - learning how to manage your system and Python 'PATH', learning an editor, virtualenvs, pip etc all need to happen. But not in your first hours as a new developer.

Another reason to have students work through the challenge of getting a working dev environment on their own machines is so that they can continue to teach themselves and learn on their own once past the introduction. This is very important, and should be built into any worthwhile instruction, it just doesn't need to happen at the beginning. Once students have learned some material, they will have much more context to understand what it is they are setting up, and will potentially have a greater motivation for getting it all working. So in the end I believe this trade-off is a bit of a red herring, as it is not about "either or", but "which comes first".

Finally there is some advantage to working in a "tunneled" environment if the primary way you may interact with tools or data is remotely on a server. When you have only learned with the aid of local GUI tools on hand, it can be a very difficult transition to doing things remotely.

Short Screencast

Direct link if embedding disabled

Quickstart

JiffyLab uses Docker which provides each student a sandboxed environment through the use of linux containers (think lightweight, process level virtual machines). Note that this technology is Linux specific, so does NOT run on Mac OS X. You can run this quite effectively inside a Linux virtual machine using vagrant (in fact, this project was developed on a Mac). A simple Flask app runs on the same machine as Docker and uses the Docker remote API to create or restart containers as needed.

Once you have a linux machine setup (see below for more details on Vagrant), you can execute the steps in the linux-setup.sh file. This will install Docker, and some python tools, pull the base Docker images needed, and start the webapp. You can then connect on port 80 to that machine. It is recommended you not run this on a server also used for any "Very Important Things", but instead run it on some sort of VM on its own.

Running on a Mac with Vagrant

Note - running this on a cloud based vagrant provider ends up getting set up much faster, usually due to the excellent speeds on cloud providers.

You will need Vagrant and Virtualbox (make sure you are using the latest version that is known to support vagrant, sometimes virtualbox breaks vagrant).

cd into the jiffylab folder and just run vagrant up in a terminal. Note that with the 'Ubuntu Raring' image used, I found that Vagrant would hang on first boot. If you are stuck on "waiting for VM to boot" for more than several minutes, ctrl-C, then do a vagrant halt followed by another vagrant up.

If you had this stalling issue, vagrant may not have provisioned properly, so you will have to run the linux-setup script, which should be found at /vagrant/linux-setup.sh

Running on Rackspace with Vagrant

You will need a an account and API key on Rackspace. You will also need to install the vagrant rackspace plugin:

$ vagrant plugin install vagrant-rackspace
$ vagrant box add dummy https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box

You will need to set some environment variables for Rackspace - an easy way to do this is to follow the directions in cloud-credentials.sh, fill out your information, then:

$ source cloud-credentials.sh
$ vagrant up --provider=rackspace

After server building and provisioning, you should be able to access your instance on the IP address listed in your Rackspace dashboard.

Running on DigitalOcean with Vagrant

Install the DigitalOcean vagrant provider and dummy box:

$vagrant plugin install vagrant-digitalocean
$vagrant box add dummy https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box

# see notes on DigitalOcean plugin readme if you get errors

Sign up if you haven't already, then grab your client id and api key from DigitalOcean.

Plug these into cloud-credentials.sh, then:

$ source cloud-credentials.sh
$ vagrant up --provider=digital_ocean

Similar or related projects

  • wakari A really well done and far more complete version of this concept, using the ACE editor, OpenVZ linux containers instead of Docker, and the GateOne shell. The only knocks against it is that it is commercial (with a free EDU option) and not open source, but hey, well done.
  • notebookcloud is an app_engine app that will manage the spin up of EC2 instances. Requires you to upload your AWS credentials.
  • IPython-hydra a set of scripts to launch IPython notebook processes under dynamically created users.

This project still has plenty of rough edges, check out the current issues, submit a new one, feedback welcome.

jiffylab's People

Contributors

davclark avatar ptone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jiffylab's Issues

Fix ShellInABox to use iFrame

Currently works pretty well, main limitation is that it does not display the 'login:' prompt, as it is getting drawn off screen.

Can "fix" in the dev-browser by switching JS console context to the iFrame, and calling "new ShellInABox();"

which triggers the refresh - this is the call that originally generates the shellinabox UI - but this technique can't be used from parent page to iFrame outside the dev console context due to browser security policies (shellinabox is served on a different port).

Fix permissions in install script

Currently, the linux-setup.sh does not execute properly as a normal user. There's a mix of sudo and non-sudo commands, which confuses me on how to install jiffylab.

Probably, the problem is fixed when adding 'sudo' in front of some of the commands that usually require elevated permissions, such as the stop/start/useradd, and writing towards /etc/init/jiffylabweb.conf and /etc/init/dockerd.conf.

I'm not sure about the actual purpose of this install script (should it be run as root user, i.e., after removing all sudo's from the install script, or should it be run as a normal user).

I can make a pull request if I'm sure about the strategy of this file (and after testing on my PC).

Regards,
Martin

Wakari offered free plan

Hi, just checked Wakari service and I saw that they offer a free plan with limited resources, but it's OK for educational purposes. It's a really great service thanks for pointing it out. You can update README file about the free plan

allow specifying username and password at login

This could be set as the default user for the container

Problem is that we DON'T want to have to worry too much about security - and we can't trust users not to reuse real passwords which could be exposed.

Adding SSL would help, but would have to be self-signed, which causes problems with iFrames, and in general the errors of "untrusted" cert isn't putting forward a great face.

Signed SSL is not an option - as these "labs" are meant to be created on demand, not run as a permanent service on a fixed IP.

Error fetching docker (and stdin error that may not be related)

I'm not sure at this point if these are problems, but upon doing vagrant up I get a variety of warnings that seem to relate to this:

stdin: is not a tty

In particular, I get a number of these:

dpkg-preconfigure: unable to re-open stdin: No such file or directory

I also get a (strangely formatted, with extra linebreaks amongst the characters in curl) error, though other network connections via apt-get seem to work:

curl: (6) Couldn't resolve host 'get.docker.io'

Then I get the following issues, which seem fairly fatal:

/tmp/vagrant-shell: 16: [: 
root: unexpected operator

cp: 
cannot stat ‘./*’
: No such file or directory

Could not open requirements file: [Errno 2] No such file or directory: '/usr/local/etc/jiffylab/webapp/requirements.txt'
Storing complete log in /root/.pip/pip.log
stop: Unknown job: dockerd
start: Job failed to start
chown: 
cannot access ‘/usr/local/etc/jiffylab/webapp/’
: No such file or directory

/tmp/vagrant-shell: 36: /tmp/vagrant-shell: 
docker: not found

So, I'm guessing the failure to fetch docker is fatal. I don't know why that's happening, while other network access appears to work fine...

If it matters, I'm on VBox 4.2.16, vagrant 1.2.4, OS X 10.8.4. I've ssh'd into the virtualbox (with vagrant ssh) and there does seem to be a problem using curl for get.docker.io. As I said, it resolves fine from the host OS, and a host get.docker.io also resolves from within the vbox. You can't use that IP address directly with curl, though, as S3 demands something more textual.

provide for a roster

In addition to integrating basic auth per #1 there should be some way to limit the logins to a roster, perhaps a simple CSV upload with R/O display of current roster, or a more complete admin.

Default setup: problems connecting to docker API

Hello,

When following the installation instructions from the linux-setup.sh file, I get the following error from the flask web-site when trying to log in:

https://gist.github.com/anonymous/dee890e89e7ecd984d26

After some searching, I found out how to solve it, although I don't exactly understand why this is needed. Solution:

In the /etc/init/docker.conf file, there's this line:

exec /usr/local/bin/docker -d

Running docker as such gives the following:

test@test:~$ docker -H 127.0.0.1:4243 ps
2013/08/15 11:22:38 dial tcp 127.0.0.1:4243: connection refused
test@test:~$ sudo docker  ps
ID                  IMAGE               COMMAND             CREATED             STATUS              PORTS

This is exactly what the app.py tries (through the python docker API): to access docker on 127.0.0.1:4243 (just like on the command-line, docker -H 127.0.0.1:4243).

I solved the problem by modifying the exec line in /etc/init/docker.conf

exec /usr/local/bin/docker -H 0.0.0.0:4243 -d

Probably, there's a better solution, because when you install docker on a default ubuntu setup (13.04), you don't want to modify the docker.conf file to reduce setup time. I tried to start up the docker client:

docker_client = client.Client(url),

where for url I tried '0.0.0.0:4243', 'my.ip.add.ress:4243', and '127.0.0.1:4243', but none of them works.

With kind regards

Add editor component

Right now the only option is nano/vi in the shell - and these suck for beginners.

Best current option is: http://github.com/zefhemel/zed/

which is geared towards a chrome app for packaging, but will work as regular html/js


Some notes on running it outside of chrome app:

editor.html is the main vehicle

To start up in regular chrome mode:

open chrome with same origin disabled:
open -a '/Applications/Google Chrome.app' --args --disable-web-security

switch to zed/app and then:
python -m SimpleHTTPServer 9999

in another terminal open zed/server and then:
python webfs.py

in chrome open:
http://localhost:9999/editor.html?url=http://localhost:1338/tmp/zedproject

will open or create project at ~/tmp/zedproject

integrate persona auth

It is easy to integrate Persona with Flask, this should be something that is enabled through a config option.

Option to stop container on logout

This should be on by default

Bonus feature - would be to allow this as an option on logout, but it is more of an advanced (non teaching) use case.

Would like to see a way of cleaning up unsaved notebooks on exit as well

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.