-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[LX-2365] allows XBlock API users to optionally use LabXchange block types #29517
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
Conversation
|
Thanks for the pull request, @pomegranited! I've created OSPR-6255 to keep track of it in JIRA, where we prioritize reviews. Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
|
@pomegranited Thank you for your contribution. Please let me know once this is ready for our review. |
14a8dce to
3b6b9f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pomegranited I'm not sure about this api - it's not clear how the from and to values relate (as in the order). Both from seeing an example querystring and the docstring here. Also then we need to define in the docs the behaviour when the two lists are not the same length.
?from_block_types=old1,old2,old3&to_block_types=new1,new2,new3
Idk it seems very brittle. Two separate arguments being two parts of the same operation. Need to be the same length and same order, clients and the server need to do fancy things with zip to create or parse. It's not clear what is happening when reading it.
Maybe we could use something like this instead?:
?block_override=old1:new1&block_override=old2:new2
The code would need to look something like:
requested_overrides = request_args.getlist('block_overrides', [])
overrides = {}
for item in requested_overrides:
# split on `:` (or whatever deliminator we want)
# verify there are exactly two non-empty entries in the split list
# (ignore or return 400 on issues?)
# overrides[old] = new
return overridesCC @symbolist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there's pros and cons to both, and no clear convention on what to do in this case. The edx REST API conventions want comma-separated strings for list parameters, but they don't say anything about maps.
I liked this way because it was easy to generate from a dict (since python3 orders keys/values on insertion), and easy to reassemble using zip.
We'd have the same issue with having to check parameter format and empty-strings if we use a separator like : too, so I'm inclined to keep this format as it was what was requested in the ticket. Will change it if the upstream reviewers object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From @bradenmacdonald 's comment:
RE the query string API, my personal preference is strongly for ?block_override=old1:new1&block_override=old2:new2 but don't take that as the final word on the subject.
I'm ok with this approach.. who's the best person at Open edX to ask now that Nimisha's gone? CC @ormsbee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NVM -- we're classifying this as a temporary change, so aren't going to spend more time debating how the query parameters are passed in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NVM again -- for security reasons, we've hardcoded the block override types, and are using a simple boolean argument instead: ?lx_block_types=1.
2115e67 to
cba3a05
Compare
|
@pomegranited Is this ready? |
|
Your PR has finished running tests. There were no failures. |
|
Hi @natabene yep it's ready for review now. We still need to review internally, but it would be good to know if we can use a core committer review for this? i.e. @Agrendalath or @bradenmacdonald |
|
@pomegranited @swalladge Is this temporary code or do you intend this to be a long-term feature of the platform? Because I'm struggling to think of a justification or even another use case for this feature other than the current circumstances that you described. Generally, even two different "video" XBlocks are going to have wildly different fields and data formats and not be interchangeable in this way. Perhaps if this feature allowed rolling out multiple versions of the same XBlock so that one can progressively test it with more users, it would be more generally useful. But I'm not sure that's even possible with python. What are your thoughts? RE the query string API, my personal preference is strongly for |
|
@pomegranited 👍 leaving my thumbsup here, since I tested as part of opencraft/client/LabXchange/labxchange-dev!1578. Note that the design for the api parameters haven't been settled on yet.
|
I think @symbolist has the most context on the longer term plans for this. |
|
@bradenmacdonald I only have the current migration in mind. Agree hard to think of other cases where it would be useful. 🤔 We can also remove the code later. |
Pip doesn't support installing multiple versions of the same repo, but someone could add new versions to the XBlock entry points. E.g. with the Poll XBlock, mapping And I can't think of a way to make this code less intrusive, unfortunately. Should I mark these commits as |
I think so yes. And in that case, I don't think it's worth spending much time on what format the query string is in, if it's just temporary. Anything that works is fine. |
|
Thanks @bradenmacdonald -- I've updated the PR description to note that this is a temporary change, and I'll update my commit messages to Let me know if you need anything else in order to do this review? |
|
Are there security/integrity concerns here? Can I get the answers for something by asking the API to map |
|
@ormsbee CC @symbolist @bradenmacdonald
Hmm.. the answer is yes/maybe. 😦 The only way around this issue I can think of is if we make the type mappings configurable by Admins only (e.g. in a Site configuration or otherwise), and change the API parameter to a boolean like Can you think of any other ways of (safely) achieving the goals here? We're working on a new runtime, but that's a ways off. |
|
I'm not really clear on what the HTML templates are doing in this PR, could you please clarify that? Otherwise I've reviewed the code and as long as this is temporary it's good with me 👍🏻
|
|
Thanks @bradenmacdonald !
The explanation is a little involved, so I've updated the "Author Notes & Concerns" to address your question. Does that make sense? Let me know if you're still ok with this, and I'll rebase and squash these commits down to a |
|
@pomegranited I see, thanks for the clear explanation. It's always been a pain point that those tests don't run on CI. The work to move blockstore into edx-platform should resolve that once and for all, and then we can always run the tests. If you intend to merge those .html template changes temporarily, then revert them along with the rest of this PR after it's done, fine with me. Please proceed with merging :) But if you were thinking of leaving those .html files in the codebase after this, I am a little hesitant; I want the tests passing but I'm worried those template files will be unmaintained and will confuse others as they did me. We should really either (A) do the fix you originally tried and fix the unexpected other test failures, or (B) move the templates to a common place, not duplicate them, or (C) ... not sure, but there's probably another option. In any case, I think that fix belongs in a dedicated PR and is more associate with the "pull blockstore into edx-platform" work |
addcfac to
8d26fbc
Compare
|
Thanks @bradenmacdonald !
Yep -- I'm working on that right now with SE-5256.
I split this into 2 temp commits -- one for the templates, and one for this feature, since the template changes will be reverted soon as part of BD-14, but this feature will need to stay in a little longer. I can't merge edx-platform PRs -- could you schedule the merge with upstream? Thank you! |
|
@bradenmacdonald Ooh actually looks like Monday AM EST is the designated time for merging outside OSPRs now (see (private) Slack message), so if we could get this done this morning, that would be excellent. CC @ormsbee @natabene |
|
@pomegranited Thanks! I think it is a holiday in the US on Monday 17th January? If yes, we may want to wait until tomorrow for the merge. |
|
@pomegranited @symbolist I found out that today is an important day for some online programs so there is a feature freeze for the day (Jan 18). I can merge this for you tomorrow (Jan 19) during east coast working hours. |
|
Lovely, thank you for keeping on top of this @bradenmacdonald :) |
|
Hmm, @symbolist or @pomegranited can you rebase this to trigger the newly required build status on CI? I'm not sure how to trigger it otherwise... |
The content library tests were failing to locate templates when rendering XBlocks, but since these tests are skipped in CI, the issue went undetected. This fix is marked temporary because a proper fix involves adding lms/templates to the cms.envs.test MAKO_TEMPLATE_DIRS_BASE list. This was tried, and caused unrelated tests to fail, and so we took this approach instead. See PR for full details.
when fetching block metadata and rendering blocks while maintaining the original usage IDs/OLX. This change is marked temporary because LabXchange need it during the transition to a custom runtime, but it's not really useful to anyone else. We will revert this change with a future PR.
8d26fbc to
ef8f841
Compare
|
@bradenmacdonald Sure thing -- rebase pushed. |
|
@pomegranited 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
…ring MFE When the XBlock runtime is used in Studio/authoring mode, it needs to use the template path prefix "lms." in order to locate the block templates. (In LMS view, no prefix is required.) Fixes bug introduced by openedx#29354 and removes template workaround added by openedx#29517 (see Author Notes & Concerns)
…ring MFE When the XBlock runtime is used in Studio/authoring mode, it needs to use the template path prefix "lms." in order to locate the block templates. (In LMS view, no prefix is required.) Fixes bug introduced by #29354 and removes template workaround added by #29517 (see Author Notes & Concerns)
Description
Adds an optional parameter to the blockstore runtime REST APIs to request LabXchange's block type overrides so that the custom XBlock implementations can be tested with a subset of users.
This PR adds functionality, and so should not affect other users of these APIs.
Testing instructions
Set up devstack
Note: I tried setting up blockstore + library-authoring MFE in an Ocim sandbox, but was unable to get them to work together. So testing will have to be done on a devstack.
If you have a labxchange devstack, you can use the libraries created by LX, you don't have to do these steps.
gradebookMFE has been renamed tofrontend-app-gradebook:Running automated tests
Manually run the new/fixed tests, which are skipped in CI:
make testserverto launch the test container.This can be run alongside the main blockstore
easyserver.Test APIs
If you are running the labxchange devstack:
Otherwise:
Test the metadata API for each block ID:
Note the returned
block_typeshould be one ofvideo,problem,html, orpoll.Note that the returned
block_typeis now one oflx_video,lx_question,lx_html, orpoll(unchanged)Test the handler URL:
Note that the returned
handler_urlalso has thelx_block_types=1parameter appended.Note the returned
handler_urldoes not have any parameters appended.Note: If you follow the
handler_urllink for a block, it will only work if the returned block type contains that handler. E.g.,student_view_user_statewill work whenproblemis overridden tolx_questionsince the QuestionBlock has that handler. But the ProblemBlock doesn't, so it will return a 500. The VideoBlock hasstudent_view_user_statein both the Open edX and LabXchange versions of the block.Deadline
None
Author Notes & Concerns
This change is temporary, and will be reverted by a future PR from the LabXchange group: LX-2450
This PR also adds HTML templates to the
common/testdir so that the tests intest_content_libraries.pywill succeed.The content library tests are not run as part of the normal CI, and were failing when I ran them in my devstack. As noted under "Running automated tests", these tests must be run using the CMS test settings in order to create content libraries and blocks. Unlike the lms.env.test
MAKO_TEMPLATE_DIRS_BASEsetting, cms.env.testMAKO_TEMPLATE_DIRS_BASEdoes not includelms/templatesin its list of template directories, and so the content library tests were unable to render problems and videos inside the CMS test context.Simply adding
lms/templatesto the list of cms test mako template dirs fixed this issue, but unfortunately broke a number of unrelated tests in the process. So instead, I cpoied the minimum set of templates fromlms/templatestocommon/test, which allowed the CI to succeed and the content libraries tests to pass.We'll try to fix this properly as part of the BD-14 Blockstore Libraries project.