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

New locators for content libraries #46

Merged
merged 5 commits into from
Oct 30, 2014

Conversation

bradenmacdonald
Copy link
Contributor

This PR implements two new types of locators necessary to facilitate content libraries. I'll be posting a separate PR to edx-platform for the content libraries prototype soon, but for now I'd like to start the review process for this locator code.

The new locators are described in detail under the "New Locators" heading at https://openedx.atlassian.net/wiki/display/SOL/Content+Libraries

@openedx-webhooks
Copy link

Thanks for the pull request, @bradenmacdonald! I've created OSPR-167 to keep track of it in JIRA. JIRA is a place for product owners to prioritize feature reviews by the engineering development teams. Feel free to add information to the ticket which can help Product understand the context for the PR - supporting documentation, edx-code email threads, timeline information ('this must be merged by XX date', and why that is), partner information (this is for a course on edx.org, for example), etc.

All technical communication about the code itself will still be done via the Github pull request interface. As a reminder, our process documentation is here.

We can't start reviewing your pull request until you've added yourself to the AUTHORS file. Please see the CONTRIBUTING file for more information.

@singingwolfboy
Copy link
Contributor

Thanks! Can you fix up the pylint violations, so that this branch passes the Travis build?

@sarina
Copy link
Contributor

sarina commented Oct 24, 2014

Hey @bradenmacdonald : this makes sense to me. I'm wondering if there's any supporting documentation you might have to add to this (ie did you discuss this on edx-code?) - also be sure to add yourself to AUTHORS for this new repo.

Also check your diff-cover report and see if you can up your coverage:
opaque_keys/edx/locator.py (78.5%): Missing lines 449,454,459-460,464,473,490-495,558,569,579,588,596,608,1093,1097,1109,1126,1138,1144,1150,1172,1177,1181,1186

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.44%) when pulling 602ffb3 on open-craft:library-locators into a70af7c on edx:master.

@bradenmacdonald bradenmacdonald force-pushed the library-locators branch 2 times, most recently from 621cef7 to e1bb028 Compare October 27, 2014 01:22
@coveralls
Copy link

Coverage Status

Coverage increased (+1.4%) when pulling e1bb028 on open-craft:library-locators into a70af7c on edx:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.4%) when pulling 0c49a27 on open-craft:library-locators into a70af7c on edx:master.

@bradenmacdonald
Copy link
Contributor Author

Ok, I have fixed the quality issues and increased the coverage to 100%.

@sarina The technical design is at https://openedx.atlassian.net/wiki/display/SOL/Content+Libraries . It was posted to the mailing list but virtually all the discussion happened on that wiki page. I then presented it to the Arch Council and this got the green light after a fruitful discussion.

This is for an edX solutions client and we are hoping to get it approved and ASAP so that we can use it in the content libraries prototype coming soon to edx-platform.

block_id = self._parse_block_ref(block_id, False)

if not all(self.ALLOWED_ID_RE.match(val) for val in (block_type, block_id)):
raise InvalidKeyError(self.__class__, "Invalid block_type or block_id")

Choose a reason for hiding this comment

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

Would be great if actual block_type and block_id are somehow incorporated into exception, or at least logged

@e-kolpakov
Copy link

@bradenmacdonald most of the test can be converted to data-driven tests (I've marked some of them explicitly). The benefit of using ddt is that the test code is much DRY-er and allows for adding new test cases much simpler. Other than that - looks good.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.33%) when pulling 6d7533d on open-craft:library-locators into a70af7c on edx:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.34%) when pulling 8bfec4d on open-craft:library-locators into a70af7c on edx:master.

@sarina
Copy link
Contributor

sarina commented Oct 27, 2014

@bradenmacdonald tests & code looks clean, moving this forward to team review.

({BRANCH_PREFIX}@(?P<branch>{ALLOWED_ID_CHARS}+)\+?)?
({VERSION_PREFIX}@(?P<version_guid>[A-F0-9]+)\+?)?
({BLOCK_TYPE_PREFIX}@(?P<block_type>{ALLOWED_ID_CHARS}+)\+?)?
((?P<org>{ALLOWED_ID_CHARS}+)\+(?P<course>{ALLOWED_ID_CHARS}+)(\+(?P<run>{ALLOWED_ID_CHARS}+))?(\+(?=.))?)??
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why you added ?=. which seems to be a noop: "there may be a plus sign here or anything else. If plus sign, eat it, if it's anything else, don't read it in" seems equivalent to "there may be a plus sign here. If so, eat it."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed this pattern would match URLs with a trailing plus, e.g. course-v1:BradenX+PHYS200+2014+ which seems weird - with this change to add a lookahead, a lone trailing + is no longer matched. It's not important for the libraries, just something I saw while re-working to make run optional.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, I misread the pattern. Perhaps add a comment string as w/ all the ? it gets hard to humanly read? Anyway, good catch.

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like we're getting past the point where a regex for parsing makes this easier to read. I almost implemented imperative to parse the same, but held off. Still, seems like it might be worth considering a different parsing solution (combinators, maybe?)

self.assertEqual(version_only_lib_key.package_id, None)
with self.assertRaises(InvalidKeyError):
version_only_lib_key.for_branch("test")

Copy link
Contributor

Choose a reason for hiding this comment

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

at this point my eyes glaze over and I assume you've continued this systematic thoroughness through the rest :-)

@dmitchell
Copy link
Contributor

👍

@coveralls
Copy link

Coverage Status

Coverage increased (+1.33%) when pulling 644f1bc on open-craft:library-locators into a70af7c on edx:master.

@bradenmacdonald
Copy link
Contributor Author

Thanks for the review! I've pushed two new commits with the suggested changes. Highlights are:

  • Made URL_RE_SOURCE regex easier to read, fixed another bug, updated tests
  • Took the branch='library' default out of LibraryLocator and moved it into split_draft (tested this on the prototype and it's working fine)
  • Cleaned up LibraryLocator docstring

@openedx-webhooks openedx-webhooks added the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Oct 30, 2014
dmitchell added a commit that referenced this pull request Oct 30, 2014
New locators for content libraries
@dmitchell dmitchell merged commit b124013 into openedx:master Oct 30, 2014
@bradenmacdonald bradenmacdonald deleted the library-locators branch October 30, 2014 18:29
@sarina sarina added the open-source-contribution PR author is not from Axim or 2U label Apr 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engineering review open-source-contribution PR author is not from Axim or 2U waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants