Skip to content

feat: remove field-data binding from the runtime [FC-0026] - #32357

Merged
Agrendalath merged 2 commits into
openedx:masterfrom
open-craft:agrendalath/fc-0026-field-data
Jun 30, 2023
Merged

feat: remove field-data binding from the runtime [FC-0026]#32357
Agrendalath merged 2 commits into
openedx:masterfrom
open-craft:agrendalath/fc-0026-field-data

Conversation

@Agrendalath

@Agrendalath Agrendalath commented Jun 2, 2023

Copy link
Copy Markdown
Member

Description

The goal of FC-0026 is to remove the XBlock-specific handling from the prepare_runtime_for_user function. This part handles the field-data. Please take a look at the review comments that explain each significant change.

Supporting information

Private-ref: BB-7448

Testing instructions

Ensure that XBlocks work correctly in the LMS, Preview, and Studio. Check that importing and exporting the course works.

@Agrendalath Agrendalath self-assigned this Jun 2, 2023
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core committer labels Jun 2, 2023
@openedx-webhooks

openedx-webhooks commented Jun 2, 2023

Copy link
Copy Markdown

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.

@Agrendalath Agrendalath changed the title feat: remove field data binding from the runtime [FC-0026] feat: remove field-data binding from the runtime [FC-0026] Jun 2, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We're removing lots of these block-agnostic queries by moving out the DateLookupFieldData initialization out of the runtime preparation:

SELECT "schedules_schedule"."id", "schedules_schedule"."created", "schedules_schedule"."modified", "schedules_schedule"."enrollment_id", "schedules_schedule"."active", "schedules_schedule"."start_date", "schedules_schedule"."upgrade_deadline" FROM "schedules_schedule" INNER JOIN "student_courseenrollment" ON ("schedules_schedule"."enrollment_id" = "student_courseenrollment"."id") WHERE ("student_courseenrollment"."course_id" = 'course-v1:org.0+course_0+Run_0' AND "student_courseenrollment"."user_id" = 1) LIMIT 21

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@Agrendalath
Agrendalath force-pushed the agrendalath/fc-0026-field-data branch 4 times, most recently from 4254929 to 3413277 Compare June 21, 2023 15:10
Comment on lines 551 to 528

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Agrendalath, since the service is being removed, do we need @XBlock.needs("field-data")?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Regarding removing @XBlock.needs('field-data'): The field-data service in general is still used; it's just this particular way of setting the student-bound wrapped field data that is no longer used. I think :)

Though I also think that the field-data service is always "needed" so it's probably not necessary to use the @XBlock.needs decorator.

@Agrendalath Agrendalath Jun 23, 2023

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nice catch! We use field-data as a service but never reach the service declaration checks because of its special handling.

I removed these decorators in cca07d635fcc8001515704647fd713f46626c8b5.

Comment thread xmodule/services.py Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Agrendalath

Copy link
Copy Markdown
Member Author

@0x29a, @bradenmacdonald, this is ready for review. I did plenty of regression checks, but please let me know if you are aware of some specific edge cases we should verify.

@Agrendalath
Agrendalath marked this pull request as ready for review June 21, 2023 15:41
@Agrendalath
Agrendalath force-pushed the agrendalath/fc-0026-field-data branch from 3413277 to 4719ca9 Compare June 21, 2023 19:38

@0x29a 0x29a left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: let's remove this too.

Otherwise 👍

  • I tested every built-in problem, course import and export.
  • I read through the code, also I don't remember finding any place that uses field-data service.

@bradenmacdonald bradenmacdonald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I just read through the code and will rely on you two for testing... This looks great though. A very nice cleanup and I'm pleasantly surprised that we can just remove and simplify things like this, with no other changes. Excellent.

Comment thread cms/djangoapps/contentstore/tests/test_i18n.py Outdated
Comment thread cms/djangoapps/contentstore/views/tests/test_preview.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Regarding removing @XBlock.needs('field-data'): The field-data service in general is still used; it's just this particular way of setting the student-bound wrapped field data that is no longer used. I think :)

Though I also think that the field-data service is always "needed" so it's probably not necessary to use the @XBlock.needs decorator.

@Agrendalath

Copy link
Copy Markdown
Member Author

Thank you for your reviews, @0x29a and @bradenmacdonald!

@ormsbee, would you like to take a look at this before we schedule the merge?

@ormsbee ormsbee left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have pretty much exactly @bradenmacdonald's reaction to this.

@Agrendalath
Agrendalath force-pushed the agrendalath/fc-0026-field-data branch from 0ffd938 to d492163 Compare June 26, 2023 17:19
@Agrendalath
Agrendalath force-pushed the agrendalath/fc-0026-field-data branch from d492163 to 6c435bb Compare June 26, 2023 17:21
@Agrendalath
Agrendalath merged commit 80374ed into openedx:master Jun 30, 2023
@Agrendalath
Agrendalath deleted the agrendalath/fc-0026-field-data branch June 30, 2023 13:06
@openedx-webhooks

Copy link
Copy Markdown

@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.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core committer open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants