Skip to content

Conversation

@tecoholic
Copy link
Contributor

@tecoholic tecoholic commented Dec 1, 2022

Description

Currently, there are various terms used to refer to XBlocks: xblocks (or blocks), descriptors, modules, or items. This makes the code a lot less approachable and understandable. Since we are getting rid of a lot of tech debt it is a good time to do a quick update of the terminology in the edx-platform to make it consistent.

In this PR:

Convert references using item to refer to XBlocks to use block (e.g. in ItemFactory).

Supporting information

This ticket was created from the work started with #31113

Testing instructions

There is nothing specific to be tested, as we are not adding or changing any functionality. However, we can just perform a general testing of LMS and Studio using the following sandbox.

Sandbox LMS: https://pr31384.sandbox.opencraft.hosting/
Sandbox Studio: https://studio.pr31384.sandbox.opencraft.hosting/

Deadline

"None"

Other information

Related PR: mitodl/edx-sga#332 (it's not a blocker, as these integration tests do not seem to be used anywhere).

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Dec 1, 2022
@openedx-webhooks
Copy link

openedx-webhooks commented Dec 1, 2022

Thanks for the pull request, @tecoholic!

When this pull request is ready, tag your edX technical lead.

@tecoholic tecoholic force-pushed the tecoholic/unify-xblock-naming-item branch from 70a0ceb to c8c0abb Compare December 1, 2022 07:57
@tecoholic
Copy link
Contributor Author

@Agrendalath I was able to replace item the ItemFactory and the get_display_items and displayable_items of the XModuleMixin. Other uses of item like load_item seem to have links to the modulestore. Should we tackle these?

Other heavy use of item is from the modulestore functions themselves. I guess, we are not touching these.

@Agrendalath Agrendalath changed the title Unify XBlock naming: item refactor: unify XBlock naming: item [BD-13] Dec 2, 2022
@openedx-webhooks openedx-webhooks added blended PR is managed through 2U's blended developmnt program and removed open-source-contribution PR author is not from Axim or 2U labels Dec 2, 2022
@Agrendalath
Copy link
Member

Agrendalath commented Dec 2, 2022

@tecoholic,

Other uses of item like load_item seem to have links to the modulestore. Should we tackle these?

We already have the get_block which uses self.load_item. We could replace all uses of *.load_item with runtime.get_block (or self.get_block in a few cases) and change self.load_item in DescriptorSystem to self._load_item, to avoid using it directly.

Regarding the name of the load_item argument of the DescriptorSystem: it makes sense to keep this name in sync with the methods passed to it. However, according to this TODO, it might be a good idea to rename these methods to get_instance. I'm specifically talking about the following occurrences:

  1. xmodule.x_module.DescriptorSystem
  2. xmodule.modulestore.mongo.base:CachingDescriptorSystem
  3. xmodule.modulestore.split_mongo.split:SplitMongoModuleStore
  4. xmodule.modulestore.xml:ImportSystem
  5. xmodule.tests.xml.__init__:InMemorySystem

Other heavy use of item is from the modulestore functions themselves. I guess, we are not touching these.

There are external packages that use these methods. For example, ORA2 and LTI_Consumer use get_item directly. I don't think we can safely rename these without proper deprecation, so we can omit them.

@ormsbee, what do you think about these points?

@ormsbee
Copy link
Contributor

ormsbee commented Dec 5, 2022

@Agrendalath: I don't really have an opinion on the get_instance thing. That TODO was from 2012, and I honestly wouldn't read too much into it. I think it's fine to keep thing in sync with the methods passed to it.

Absolutely agree that we cannot break compatibility by changing the modulestore functions. We can add new methods and have the old ones call into them with deprecation warnings, but I'm honestly not sure if the long term simplification is worth having both methods around for the same thing for one or two release cycles.

@tecoholic
Copy link
Contributor Author

tecoholic commented Dec 5, 2022

@Agrendalath @ormsbee Thank you for your inputs. I have changes most of the system/runtime.load_item calls to get_block. But making the load_item private by renaming it to _load_item breaks the system due to:

  1. CachingDescriptorSystem defining the load_item function with a different signature by adding extra kwargs. It's usage cannot be replaced with the get_block without changing its signature.
  2. The private property overshadowing the CachingDescriptorSystem's private memeber - Lint Error

Venturing further into renaming the load_item argument and syncing all the referencing functions seems a bit unfeasible at the moment, given we can't fully get rid of the load_item calls. And also, there doesn't seem to be any references to runtime.load_item outside of the xmodule

$ ack "load_item\(" -l
xmodule/tests/test_conditional.py
xmodule/tests/xml/__init__.py
xmodule/modulestore/split_mongo/split.py
xmodule/modulestore/split_mongo/caching_descriptor_system.py
xmodule/modulestore/xml.py
xmodule/modulestore/mongo/base.py
xmodule/x_module.py

tecoholic added a commit to open-craft/edx-sga that referenced this pull request Dec 15, 2022
As a part of naming unification, the ItemFactory class in edx-platform
has been renamed to BlockFactory. This commit updates the references to
ItemFactory in this repo to BlockFactory.

Ref: openedx/openedx-platform#31384
@tecoholic tecoholic force-pushed the tecoholic/unify-xblock-naming-item branch 2 times, most recently from 51ed0c5 to 2daa8ad Compare December 20, 2022 05:29
Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

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

👍

  • I tested this: verified that XBlocks work correctly (especially the LibraryContentBlock)
  • I read through the code
  • I checked for accessibility issues: n/a
  • Includes documentation: n/a
  • I made sure any change in configuration variables is reflected in the corresponding client's configuration-secure repository: n/a

@Agrendalath
Copy link
Member

Agrendalath commented Dec 21, 2022

@tecoholic, please rebase the PR and squash the commits into logical chunks.

@ormsbee, would you mind doing a sanity check on this PR? Unlike in #31113, we're not breaking any compatibility here.

The only external usage of the ItemFactory was in the edx-sga XBlock's integration tests that are not a part of any pipeline. We have already opened a PR to synchronize these names there.

@ormsbee
Copy link
Contributor

ormsbee commented Dec 21, 2022

@Agrendalath: Looks sane to me. It's only changing test-related files, right? Nothing in the modulestore itself? Aside from the load_item -> get_block change, which is equivalent...?

@ormsbee
Copy link
Contributor

ormsbee commented Dec 21, 2022

FWIW, this is another change that's worth broadcasting loudly, since it will likely break folks who are actively working on branches.

@Agrendalath
Copy link
Member

Agrendalath commented Dec 21, 2022

@ormsbee, we have additionally (as described here):

  1. Replaced iterations over displayable_items with self, as this method was returning [self].
  2. Replaced displayable_items with get_children, as the result is identical.
  3. Removed these two (already deprecated) methods, as they were not used outside of the edx-platform.

These changes do not affect the modulestore, though.

FWIW, this is another change that's worth broadcasting loudly, since it will likely break folks who are actively working on branches.

Good point. I will post an announcement once we merge this.

@tecoholic tecoholic force-pushed the tecoholic/unify-xblock-naming-item branch 3 times, most recently from ef51c95 to f8698c5 Compare December 23, 2022 06:41
@tecoholic
Copy link
Contributor Author

@Agrendalath Thanks for the review. I have squashed the commits and rebased it on the latest changes. This is ready for merging.

@tecoholic tecoholic force-pushed the tecoholic/unify-xblock-naming-item branch 2 times, most recently from 7d1f581 to 5d06fec Compare December 23, 2022 07:14
tecoholic added a commit to open-craft/edx-sga that referenced this pull request Dec 23, 2022
As a part of naming unification, the ItemFactory class in edx-platform
has been renamed to BlockFactory. This commit updates the references to
ItemFactory in this repo to BlockFactory.

Ref: openedx/openedx-platform#31384
@tecoholic
Copy link
Contributor Author

@Agrendalath Gentle reminder about merging this before some conflict with the master branch is introduced.

@Agrendalath
Copy link
Member

@ormsbee, I'm just checking if you had a chance to see my previous comment and if there is anything else to do before we schedule the merge.

arslanashraf7 pushed a commit to mitodl/edx-sga that referenced this pull request Jan 13, 2023
As a part of naming unification, the ItemFactory class in edx-platform
has been renamed to BlockFactory. This commit updates the references to
ItemFactory in this repo to BlockFactory.

Ref: openedx/openedx-platform#31384
@ormsbee
Copy link
Contributor

ormsbee commented Jan 20, 2023

@Agrendalath: No, go ahead and schedule the merge, ty

@Agrendalath Agrendalath force-pushed the tecoholic/unify-xblock-naming-item branch from 5d06fec to dca23ca Compare January 20, 2023 19:39
@Agrendalath Agrendalath force-pushed the tecoholic/unify-xblock-naming-item branch from dca23ca to 41e2f25 Compare January 23, 2023 13:48
@Agrendalath Agrendalath merged commit 600219b into openedx:master Jan 23, 2023
@Agrendalath Agrendalath deleted the tecoholic/unify-xblock-naming-item branch January 23, 2023 14:04
@openedx-webhooks
Copy link

@tecoholic 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@Agrendalath
Copy link
Member

Forum announcement for this change: https://discuss.openedx.org/t/refactoring-xblock-references/9194.

@edx-pipeline-bot
Copy link
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
Contributor

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

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

Labels

blended PR is managed through 2U's blended developmnt program

Projects

Archived in project
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants