Open Course, Open Source, Openshift

Ryan S. Brown
Software Engineer, OpenStack

The seeds of courseware

  • There should be FOSS for teaching classes on FOSS
  • Github Native courseware. Homework? No, pull requests.

Version 1

  • Flask
  • YAML
  • Single repo
  • OpenShift

Students

  • Make pull requests
  • Can fix bugs
  • Hands-on with FOSS

Flask

@app.route('/syllabus')
def syllabus():
    """
    Render the syllabus page.

    """

    with open(app_path('schedule.yaml')) as schedule_yaml:
        schedule = yaml.load(schedule_yaml)
    return render_template('syllabus.mak', schedule=schedule, name='mako')

More Flask

@app.route('/participants/<year>/<term>/<username>')
def participant_page(year, term, username):
    participant_data = {}
    yaml_dir = app_path('people')
    participant_yaml = os.path.join(yaml_dir, year, term, username + '.yaml')
    with open(participant_yaml) as participant_data:
        participant_data = yaml.load(participant_data)

    return render_template(
        'participant.mak', name='make',
        participant_data=participant_data,
        gravatar=gravatar
    )

The Template

<div class='jumbotron'>
    <h1>${participant_data['irc']}</h1>
    <p>${participant_data['name']}</p>
</div>
%if 'github' in participant_data:
<h2><a href="https://github.com/${participant_data['github']}">GitHub</a></h2>
%endif

YAML Flat-a-base

  • Pull requests for student profiles
  • Course schedule
  • Helpful links

YAML

blog: http://gearchicken.com/blog/
feed: http://gearchicken.com/blog/rss.xml
forges:
  - http://github.com/liam-middlebrook
  - http://bitbucket.org/liam-middlebrook
irc: loothelion
name: Liam Middlebrook
rit_dce: ljm2906
hw:
  litreview1: http://gearchicken.com/....
  quiz1: http://gearchicken.com/blog/....
  litreview2: http://gearchicken.com/....
  quiz2: http://gearchicken.com/blog/....
  bugfix: http://gearchicken.com/blog/....
bio: Born hacking.
twitter: liammiddlebrook

Blog Scraper

  • Count student blog posts in real time
  • Blog posts & community participation are graded
  • Example

Curse of success

  • More ...
  • courses
  • students
  • content
  • bugfixes
  • porting bugfixes :(

The next generation

  • Available on PyPi
  • TravisCI validates YAML
  • Repo per course
  • CLI tool
  • Even simpler OpenShift deploys

pip install hflossk

  • Faster bootstrapping for students
  • Automatically add CLI tools to $PATH

IRC Hooks

  • Show progress in #rit-foss IRC channel

TravisCI hflossk

  • Checks the YAML for every commit
  • Helps with student onboarding
  • TODO: test the site itself

Using tox

[tox]
minversion = 1.6
envlist = py27,py33,pep8
language: python
install: pip install tox
script: tox

Command Line

  • hflossk new
  • hflossk run
  • hflossk openshift

Magic OpenShift

  • Hide complexity
  • Add Openshift boilerplate
  • Make a scratch commit
  • push it

Talking to git

def is_dirty():
    """Check for uncommitted changes. True if dirty."""
    repo = git.Repo(os.getcwd())
    s = git.status(repo)
    return any(s.staged.values() + [s.unstaged])

Branching Out

with TempBranch(branch, repo, delete=True):
    for name, body in openshift_files.items():
        with open(name, 'w') as f:
            f.write(body.get("contents", ""))
        repo.stage(fname)
    repo.do_commit("Commit openshift files")

The Future

  • Get more feedback, iterate!
  • Other providers
  • Better onboarding
  • Caching + speed improvements

Q & A