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

Test PR | Enable Extracted Word Cloud #35983

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

farhan
Copy link
Contributor

@farhan farhan commented Dec 7, 2024

It's the test PR for this xblocks-contrib repo PR

Steps done in this PR:

  1. Enabled Extracted Block in lms/envs/common.py settings
  2. Enable fail-fast: false in .github/workflows/unit-tests.yml
  3. Replace pip installed version of xblocks-contrib with following git branched installation.
git+https://github.com/openedx/xblocks-contrib.git@farhan/word-cloud-xblock

Fix all the failed test case ✅


PR sandbox

Username: openedx
PW: openedx

Settings

TUTOR_GROVE_COMMON_SETTINGS : |
    USE_EXTRACTED_WORD_CLOUD_BLOCK = True

@farhan farhan force-pushed the farhan/test-extracted-word-cloud branch from 8cf696a to 988cb0c Compare January 13, 2025 14:28
@farhan farhan closed this Jan 15, 2025
@farhan farhan reopened this Jan 15, 2025
@farhan farhan force-pushed the farhan/test-extracted-word-cloud branch 4 times, most recently from ad5a8b7 to 02848a2 Compare January 16, 2025 10:40
@farhan farhan marked this pull request as ready for review January 16, 2025 11:09
@farhan farhan closed this Jan 17, 2025
@farhan farhan reopened this Jan 17, 2025
Copy link
Contributor

@feanil feanil left a comment

Choose a reason for hiding this comment

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

I took a pass but since I'm not as familiar with the Xblock framework, forgive me if some of the questions have obvious answers. I'm in particular confused about why the tests need to change and if that indicates any sort of breakage that we need to handle elsewhere?

'element_id': self.block.location.html_id(),
'num_inputs': 5, # default value
'submitted': False, # default value,
}

assert fragment.content == self.runtime.render_template('word_cloud.html', expected_context)
if settings.USE_EXTRACTED_WORD_CLOUD_BLOCK:
expected_context['range_num_inputs'] = range(5)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not check the block type in this case?

Copy link
Contributor Author

@farhan farhan Jan 22, 2025

Choose a reason for hiding this comment

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

Fixed, checking for both (Builtin & Extracted) XBlocks now.

if settings.USE_EXTRACTED_WORD_CLOUD_BLOCK:
def_id = runtime.id_generator.create_definition(olx_element.tag, olx_element.get('url_name'))
keys = ScopeIds(None, olx_element.tag, def_id, runtime.id_generator.create_usage(def_id))
block = WordCloudBlock.parse_xml(olx_element, runtime, keys)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do keys need to be provided for one instantiation but not the other?

Copy link
Contributor Author

@farhan farhan Jan 22, 2025

Choose a reason for hiding this comment

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

Update:
I have added keys for both builtin and extracted implementation to avoid If condition.

Why It's not needed in case of builtin xblock implementation?
In BuiltIn xblock implementation WordCloud block has XmlMixin and in its parse_xml method implementation, there is a check at start that if keys are None then it creates the keys.
I have copied the same lines of code and added them in test case.
In Extracted XBlock implementation parse_xml method of xblocks/core.py calls which doesn't have this check and expecting keys values in params.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Further discussion:
#35983 (comment)

# This will export the olx to a separate file.
block.add_xml_to_node(node)
if settings.USE_EXTRACTED_WORD_CLOUD_BLOCK:
filepath = 'word_cloud/block_id.xml'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use the same method as below to export the file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because add_xml_to_node is defined in XmlMixin class.
BuiltIn XBlocks are using this mixin

In Extracted XBlocks we are preferring to use Xblock.core functionalities and using export_to_xml method which doesn't have export_to_file funcationlity like add_xml_to_node method of XmlMixin has

@kdmccormick kdmccormick marked this pull request as draft January 21, 2025 17:54
@farhan
Copy link
Contributor Author

farhan commented Jan 22, 2025

I took a pass but since I'm not as familiar with the Xblock framework, forgive me if some of the questions have obvious answers. I'm in particular confused about why the tests need to change and if that indicates any sort of breakage that we need to handle elsewhere?

@feanil Thanks for the pass.
Let me review my implementation, rethink on them, and address your rightful queries.

Let's keep this PR in draft until I make this PR and Extracted Word Cloud PR openedx/xblocks-contrib#4 fully ready.

@farhan farhan force-pushed the farhan/test-extracted-word-cloud branch from 3f0447a to add935e Compare January 22, 2025 12:19

def_id = runtime.id_generator.create_definition(olx_element.tag, olx_element.get('url_name'))
keys = ScopeIds(None, olx_element.tag, def_id, runtime.id_generator.create_usage(def_id))
block = WordCloudBlock.parse_xml(olx_element, runtime, keys)
Copy link
Contributor Author

@farhan farhan Jan 24, 2025

Choose a reason for hiding this comment

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

As per discussion in pair programming session (@kdmccormick , @ttqureshi ) we are creating scope ids here which shouldn't happen and is a potential bug

@farhan farhan force-pushed the farhan/test-extracted-word-cloud branch from 5768e3b to d23a0a6 Compare January 28, 2025 07:38
@farhan farhan requested a review from feanil January 28, 2025 13:23
@farhan
Copy link
Contributor Author

farhan commented Jan 28, 2025

@feanil You can consider this PR to be ready for next pass

@kdmccormick kdmccormick added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Jan 30, 2025
@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-sandbox open-craft-grove should create a sandbox environment from this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants