Wednesday, May 21, 2014

edx-platform - A first look at paver in Open edX

Yesterday, I noted that the edx team has moved the edx-platform build system away from rake and use paver instead:

https://groups.google.com/d/msg/edx-code/0duQswYtjqg/A6HOFR_npjcJ

And when I was trying to create a script to update my custom theme from the git repo, I got some feedback and advice to use the paver tool of edx-platform instead for the sake of simplicity :

https://groups.google.com/d/msg/edx-code/ozqkmW3ll10/dsr4TbG3fAUJ

So, I took a while to look into the /edx-platfrom/paverlib/ to see how to use paver, what are the available options of paver in Open edX? Here they are:

edxapp@demo:/edx/app/edxapp/edx-platform$ paver help
---> paver.tasks.help
Usage: paver [global options] taskname [task options] [taskname [taskoptions]]

Options:
  --version             show program's version number and exit
  -n, --dry-run         don't actually do anything
  -v, --verbose         display all logging output
  -q, --quiet           display only errors
  -i, --interactive     enable prompting
  -f FILE, --file=FILE  read tasks from FILE [pavement.py]
  -h, --help            display this help information
  --propagate-traceback
                        propagate traceback, do not hide it under
                        BuildFailure(for debugging)

Tasks from paver.misctasks:
  paverdocs       - Open your web browser and display Paver's documentation.
                                                                                                                                                        
Tasks from paver.tasks:
  help            - This help display.

Tasks from pavelib.servers:
  devstack        - Start the devstack lms or studio server

Tasks from pavelib.assets:
  watch_assets    - Watch for changes to asset files, and regenerate js/css

Tasks from pavelib.servers:
  celery          - Runs Celery workers
  check_settings  - Checks settings files

Tasks from pavelib.assets:
  update_assets   - Compile CoffeeScript and Sass, then collect static assets

Tasks from pavelib.servers:
  lms             - Run the LMS server

Tasks from paver.misctasks:
  generate_setup  - Generates a setup.py file that uses paver behind the scenes

Tasks from pavelib.servers:
  update_db       - Runs syncdb and then migrate

Tasks from pavelib.prereqs:
  install_prereqs - Installs Ruby, Node and Python prerequisites

Tasks from paver.misctasks:
  minilib         - Create a Paver mini library that contains enough for a simple
    pavement.py to be installed using a generated setup.py

Tasks from pavelib.servers:
  run_all_servers - Runs Celery workers, Studio, and LMS
  studio          - Run the Studio server

Tasks from pavelib.docs:
  build_docs      - Invoke sphinx 'make build' to generate docs

For example, to compile the assets (theme):

paver update_assets lms --settings=aws

I also tried to add an option to pavelib/assets.py update_assets to allow me to pull theme from the git repo:

+ https://github.com/dangtrinh/edx-platform/commit/ab8b315bc304478d76bef7f5c764f7986bd80444
https://github.com/dangtrinh/edx-platform/commit/650fbcdbe5ff9a49da66bc885a12479d9694683f

paver update_assets lms --settings=aws --pull-repo

The above command will pull the theme from master branch of the git repo, and then doing the assets compiling.


References:

[0] https://github.com/edx/edx-platform/tree/master/pavelib
[1] https://github.com/edx/edx-platform/blob/master/pavelib/assets.py
[2] https://github.com/edx/edx-platform/blob/master/pavelib/servers.py
[3] https://github.com/edx/edx-platform/blob/master/pavelib/prereqs.py