-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat!: remove block handling from runtime initialization of ReplaceURLService [FC-0026] #32368
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
feat!: remove block handling from runtime initialization of ReplaceURLService [FC-0026] #32368
Conversation
|
Thanks for the pull request, @Agrendalath! As a core committer in this repo, you can merge this once the pull request is approved per the core committer reviewer requirements and according to the agreement with your edX Champion. |
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.
This is an interesting part. Removing the call to block.static_asset_path changed where the field-data cache is initialized. This altered the block runtime initialization order, and the staff_debug_info became overridden by parent blocks. However, adding this missing argument here fixes the issue.
Commit with a temporary fix I used for the verification: open-craft@655e104.
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.
Actually, we should not pass this, as it hides staff debug buttons in other places (which is not caught by tests). See the description of the HACK in the PR.
89d748d to
5e44057
Compare
|
@0x29a, this is ready for review. |
0x29a
left a comment
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.
👍
- I tested this: set up
edx-sgaand checked that both image and link are replaced and rendered / work correctly. - I read through the code.
- Includes documentation
695a9cc to
83cf4f0
Compare
|
@bradenmacdonald, @ormsbee, this is ready for your check. |
83cf4f0 to
e6982cb
Compare
bradenmacdonald
left a comment
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.
The code looks good to me, though I'm a little concerned about this hack for the field_data/parent blocks. I don't quite understand the issue. But your approach seems fine if it will be temporary.
By the way, it seems like we're now initializing a ton of services for every XBlock, regardless of whether or not they actually get used. I know the services are pretty lightweight but it might be good in the future to check block.service_declaration(...) before initializing services, or initialize them on demand like I did in the new runtime.
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.
So we don't want the parent XBlock's runtimes to be bound to user-specific data?
Also can you clarify exactly what is meant by "until we remove all XBlock-specific code from here" ?
|
@bradenmacdonald, I'll answer all your comments here to keep the context in a single place, as these items are related. Part 1: Explanation of the problem
I added an explanation to this part as a Without this PR, we are accessing the With the changes in this PR, we're moving this access here: This seems like a harmless change, as we only access an XBlock field. However, this field comes from the Therefore, to access it, we're traversing the course structure to check if the XBlock's parents declare a value for this field. Accessing an XBlock's parent looks like this: As we can see, parents are cached once they are obtained for the first time. Let's return to the failing test I mentioned in this As you can see, this loop uses the The thing is - the comment you see in this part of the code is only partially true. When we unified the As we can see in the definition of the This comment is already loaded with information, so I won't dig into why this specific test failed - it was just an example where we could observe this behavior. Part 2: Q/A
"The goal of FC-0026 is to remove the XBlock-specific handling from the prepare_runtime_for_user function." Currently, the order of runtime binding can affect the arguments passed to services in XBlocks we are initializing through an existing runtime. This is what was happening in #32165. Once we remove all the code that pulls data from a specific XBlock, the binding order won't matter anymore. That's why we're getting all data from the XBlocks directly within services. If a service uses some attributes of an XBlock, we're not initializing it in the
This is the part I'm still investigating. That's why I wanted to retain the current behavior in this PR. In the mentioned test - yes, we don't want to bind it because it causes some side effects. However, once there is no XBlock-specific code in the Part 3: Follow-up
As a follow-up to my explanation from the last part, I have a WIP PR (#32420) with service caching. Only the last two commits are relevant - others are pulled from existing PRs to check the complete solution. In short - we're using the |
|
Thanks for the very detailed response @Agrendalath. 👍🏻 I think we need to eventually get rid of having "bound" or "unbound" blocks within a runtime. The runtime should either be initialized with a user ID or without. If with a user ID, then regardless of what API is used, blocks should always be "bound" and have |
|
@bradenmacdonald, I agree - removing this distinction is a logical next step. Technically, we could remove all user-specific (and even course-specific) handling from the runtime services and pull this information directly from XBlocks during the service initialization. Once done, changes to the LTI and Instructor Dashboard tasks (that use a workaround to access the runtime) should be minimal. Some more work will be required to handle access, expirations, and masquerading, though. Is there anything left in this PR before we can call it ready? |
|
@ormsbee, would you like to review this before we schedule the merge? |
c682697 to
814151c
Compare
…LService BREAKING CHANGE: This removes the following deprecated shims from the runtime: `replace_urls`, `replace_course_urls`, `replace_jump_to_id_urls`. XBlocks need to use the `replace_urls` service instead.
814151c to
4b1f475
Compare
|
@Agrendalath 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
|
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
|
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
|
2U Release Notice: This PR has been deployed to the edX production environment. |
|
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
Description
The goal of FC-0026 is to remove the XBlock-specific handling from the prepare_runtime_for_user function. This part handles the
ReplaceURLService.Supporting information
Private-ref: BB-7448
Testing instructions
xblock-utilsfrom fix!: use TinyMCE 5 as HTML editor openedx-unsupported/xblock-utils#207.edx-sga==0.22.0(refactor!: remove deprecated runtime attributes [FC-0026] mitodl/edx-sga#339).edx-sgaXBlock and test that replacing URLs in theSolutionfield:<img src="/static/images_course_image.jpg" />and check that the image is rendered in Studio, Preview, and LMS. If you're using a custom course, you can upload an image underContent -> Files & Uploadsin Studio.<a href="/jump_to_id/vertical_0270f6de40fc">link</a>link and see if it's redirecting users to the "Introduction: Video and Sequences" unit in LMS and Preview. This feature doesn't work in Studio.Other information
This change is backward-incompatible with the deprecated shims for replacing URLs directly from the runtime. We're removing them to make the runtime block-agnostic.