Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure SERVICE_VARIANT set; pass theme to coffeescript; #3094

Merged
merged 3 commits into from
Apr 19, 2014

Conversation

yarko
Copy link
Contributor

@yarko yarko commented Mar 27, 2014

This enables theming with paver (PR #3075), mirroring similar changes as for rake in PR #2387.

In particular, when the following are set:

edxapp_theme_name: stanford
edxapp_theme_source_repo: https://{{ COMMON_GIT_MIRROR }}/{{ THEME_ACCT }}/edx-theme.git
edxapp_theme_version: master
edxapp_use_custom_theme: true  # false to disable & use std. theme

then:

paver devstack lms

will correctly read and pass the paths to both coffee and sass.

Alternately, the process described in the comment of https://gist.github.com/yarko/8818633 is another way to test this - set the above four theme settings in build-version.yml, then run vagrant provision.

A way to run this on vagrant fullstack is to use build-version.yml, as above, and either include it in, or symlink it to /edx/app/edx_ansible/server-vars.yml (it shows up as /vagrant/build-version.yml), and then using update edx-platform some-version.

Note: currently you will need to completely remove edx-platform in order to clone one from a different repository (since git remotes is not managed thru update).

This PR corrects two deficiencies:

  • no SERVICE_VARIANT set:
  • prevents tasks from reading the appropriate /edx/app/edxapp *.env.json file;
  • FIX (pavelib/utils/env.py):
    • parse command line args for one of 'lms' or 'cms' or 'studio', and set SERVICE_VARIANT appropriately;
  • coffeescript path not update with theme (once vars read from *.env.json):
  • FIX (pavelib/assets.py):
    • add theme path, when appropriate, to the search path for coffee;

Dubious code:

Please review the following aspects:

  • env.py: class variables set at class level (not instantiation level), because of current use, e.g. Env.REPO_ROOT
    • if the use case exists of a single command line instance of paver, with multiple tasks then this could confound proper operation;
    • I rather prefer having None base class attributes, and setting them in __init__(), since this would ensure proper operation. I did not follow this path because it would have meant more code changes (no Env.REPO_ROOT anywhere), and would add instantiation of the class. I prefer consensus on the approach first (so took the path closer to the current code).
  • assets.py:
    • for no particularly good reason, THEME_COFFEE_PATHS and THEME_SASS_PATHS set at module level (not w/in function); not sure I like this.

Goal

My goal and intent is to have Vagrantfile and update both honor build-version.yml files as extra-vars. At that point, a developer's Getting Started guide to Open edX will be an easier thing to write. This will simplify getting started, and maintaining edx instances, since common configurations will not require "deep" repository involvement. Build-version.yml is consistent with and distinct from server-vars.yml (server configuration and settings).

This goal will involve a PR in the configuration repository (w.i.p.) to update the various Vagrantfile instances, and the update script template.

Would you please review, @jzoldak & @singingwolfboy

# consider only words remaining (parse out separators)
p = re.compile(r'\W+')
clean_args = p.split(' '.join(clean_args))
# if lms or cms is among command line words, use it's env
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If your goal here is simply to detect if "lms" or "cms" is one of the arguments, why not do something like if "lms" in sys.argv or if "cms" in sys.argv?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good golly! Because I did a quick port from the rake version?
:-/
Updating PR now...

@jzoldak
Copy link
Contributor

jzoldak commented Mar 28, 2014

@yarko I won't be able to get to this today and I'll be out on Monday and Tuesday. Just to let you know.
@singingwolfboy thx for jumping on this!

@yarko
Copy link
Contributor Author

yarko commented Mar 28, 2014

👍 thanks @jzoldak

if not SERVICE_VARIANT: # this will intentionally catch "";
SERVICE_VARIANT = 'lms' if 'lms' in sys.argv[1:] \
else 'cms' if ('cms' in sys.argv[1:]) or ('studio' in sys.arg[1:]) \
else SERVICE_VARIANT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is way too much logic in one line of code. Can you split this into multiple lines, so it's easier to read?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure ... 3 lines; 4 lines; same logic, different form... not much difference to me - try this on for size (yeah, reads a little nicer - I like the "any").

@singingwolfboy
Copy link
Contributor

@yarko Looks good, but this PR now has conflicts and needs a rebase. :(

@yarko
Copy link
Contributor Author

yarko commented Apr 1, 2014

no worries - will get to it after lunch.

rebased / squashed now.

@yarko
Copy link
Contributor Author

yarko commented Apr 8, 2014

@singingwolfboy @jzoldak - did you get a chance to look at this?

@singingwolfboy
Copy link
Contributor

Thanks for the ping! This looks good to me, but I'd like to get someone from Stanford to test this as well, since this affects their theming capabilities. Maybe @sefk?

@yarko
Copy link
Contributor Author

yarko commented Apr 8, 2014

@sefk, @caesar2164 - would you have a look? - @caesar2164, I know you once had pending changes (Stanford-Online/edx-theme#4).

(sorry - previous comment appeared double-posted;)

@caesar2164
Copy link
Contributor

@yarko - how do I run your branch? It breaks for me with our theme settings set...

@yarko
Copy link
Contributor Author

yarko commented Apr 15, 2014

@caesar2164 - sorry, was a busy during PyCon; just rebased again. See comment on https://gist.github.com/yarko/10711787 for how I use those files to test.

Note: the test uses my fork of Stanford-Online/edx-theme#4; recall you had other changes in the wings;

/cc @sefk @singingwolfboy

@caesar2164
Copy link
Contributor

@yarko - this works great for me, 👍! (@sefk also wants to look at it…)

@@ -131,7 +128,7 @@ def compile_sass(debug=False):
"""
Compile Sass to CSS.
"""
theme_paths = theme_sass_paths()
theme_paths = THEME_SASS_PATHS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason for this local variable before was to keep from calling theme_sass_paths() twice. Now that you're using the THEME_SASS_PATHS list, you may as well just use in the two join()'s below and avoid the extra variable. That would be cleaner and more consistent.

@sefk
Copy link
Contributor

sefk commented Apr 17, 2014

I've tested this as well @yarko and indeed this is a helpful change. It's a bit hacky in that I still don't understand why SERVICE_VARIANT matters with themed assets and not just "normal" assets, but that's OK. Much better to do this change and remove the landmine than to try to untangle that harder issue.

I tested this on my local dev env (devstack) and it works nicely, where master didn't before.

Aside from my one little variable nit above, this LGTM and I'd be in favor of pulling in. 👍

@yarko
Copy link
Contributor Author

yarko commented Apr 18, 2014

@sefk - re: your THEME_SASS_PATHS line comment: yes, I agree (I think originally, I wanted to show how little the change was for reviewers).

I'll make that change, and rebase in a few hrs. Then ask @jzoldak & @singingwolfboy to test / merge.

@jzoldak
Copy link
Contributor

jzoldak commented Apr 18, 2014

@yarko I added you to the whitelist on jenkins so that PRs from your fork will automatically run the tests when you push commits.

@yarko
Copy link
Contributor Author

yarko commented Apr 18, 2014

Ok - rebased, @sefk suggested change made.
@jzoldak @singingwolfboy @caesar2164 - good to go? Once tests pass, can we get this merged?

@caesar2164
Copy link
Contributor

@yarko - 👍 from me once tests pass.

args = sys.argv[1:]
if 'lms' in args:
SERVICE_VARIANT = 'lms'
elif any(i in args for i in ('cms', 'studio')):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commands are failing with: NameError: global name 'args' is not defined

E.g. paver --help which should print the list of available tasks. This fails for me on devstack with no SERVICE_VARIANT set.

Same thing is happening when tests are kicked off by jenkins.

@yarko
Copy link
Contributor Author

yarko commented Apr 19, 2014

@jzoldak @singingwolfboy @sefk @caesar2164 - tests passed; I think this is ready now.

Can we merge?

singingwolfboy added a commit that referenced this pull request Apr 19, 2014
ensure SERVICE_VARIANT set; pass theme to coffeescript;
@singingwolfboy singingwolfboy merged commit b44ed80 into openedx:master Apr 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants