Skip to content

feat: Implement taxonomy sample data generation - #1

Merged
yusuf-musleh merged 10 commits into
mainfrom
yusuf-musleh/implement-generate-taxonomy-data
Oct 15, 2023
Merged

feat: Implement taxonomy sample data generation#1
yusuf-musleh merged 10 commits into
mainfrom
yusuf-musleh/implement-generate-taxonomy-data

Conversation

@yusuf-musleh

@yusuf-musleh yusuf-musleh commented Oct 2, 2023

Copy link
Copy Markdown
Contributor

Description

Implements generating sample taxonomy data to be used for testing and development. Repeating what is already mentioned in the README:

Running this script will do the following:

  1. 2 Test Organizations will be created
  2. For each organization created, a sample course is created that is populated with a course export that contains a variety of section/subsections/units and components
  3. For each of these created organizations the following taxonomies will be created:
    1. a disabled taxonomy with 10 Tags
    2. an enabled flat taxonomy with 5000 Tags
    3. an enabled hierarchical taxonomy with three levels and 4^x tags per level (4 root tags, each with 16 child tags, each with 64 grandchild tags)
    4. a small enabled taxonomy with 2 levels with 2 Tags each
  4. A multi org Taxonomy is created and enabled/used by both orgs
  5. (Optional) A 4 level Taxonomy containing data obtained from Open Canada Taxonomy
  6. (Optional) A 3 level Taxonomy containing data obtained from LightCast Skills Taxonomy
  7. Once the Taxonomies and their Tags have been created, the script will Tag each of the courses along with all the components they contain with 1 of each Tag from the the above

Note: This script is designed to be idempotent. Meaning that the end state is the same every time you run it. So if you make modifications to the sample courses on Studio or the Taxonomy data in the shell and run this script again, it will reset all your changes.

Related Tickets:

Testing Instructions

Similar to what is mentioned in the README:

  1. To begin, clone this repo inside a directory so it can be accessed from within the devstack (eg: /edx/src/)

  2. Set the TAXONOMY_SAMPLE_PATH variable inside the generate.py file to point to the cloned repo inside your devstack/tutor environment, eg: /edx/src/taxonomy-sample-data

  3. (Optional) If you would not like to include taxonomy data from real world examples, such as:

    Then set the following flags to False in generate.py accordingly:

    IMPORT_OPEN_CANADA_TAXONOMY = True
    IMPORT_LIGHTCAST_SKILLS_TAXONOMY = True
  4. To run the script, enter the LMS shell (make lms-shell) and run the following command:

    python manage.py cms shell < /path/to/taxonomy-sample-data/generate.py
  5. The script should run to completion, you'll notice it tagging the courses + components in the logs of the script


Private-ref: FAL-3516

@yusuf-musleh yusuf-musleh changed the title feat: Add creating sample orgs, courses + populate feat: Implement taxonomy sample data generation Oct 2, 2023
@yusuf-musleh yusuf-musleh changed the title feat: Implement taxonomy sample data generation [WIP] feat: Implement taxonomy sample data generation Oct 2, 2023
The following sample tags will be generated:
  - 10 Tags for the disabled taxonomy
  - 5000 Tags for the flat taxonomy
  - 4^x Tags with 3 levels for the hierarchical taxonomy
  - 2 Tags with 2 levels for two level taxonomy
  - 5 Tags for the multi org taxonomy

Whenever the generate script is run, it clears the existing tags and
creates fresh new ones
@yusuf-musleh
yusuf-musleh marked this pull request as ready for review October 9, 2023 15:52
@yusuf-musleh yusuf-musleh changed the title [WIP] feat: Implement taxonomy sample data generation feat: Implement taxonomy sample data generation Oct 9, 2023
Comment thread generate.py
create_taxonomy, get_taxonomies_for_org,
set_taxonomy_orgs, tag_content_object, get_content_tags,
resync_object_tags
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, I guess I forgot to point out that we already have an import-export API for taxonomies that can import JSON files? 😬 https://github.com/openedx/openedx-learning/tree/main/openedx_tagging/core/tagging/import_export

Not a big deal, but it would have been nice to re-use the existing import code and JSON file format. No need to change now though, we need to wrap this up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh my bad 😅 didn't know we had that. I can address that in a future ticket for sure.

@bradenmacdonald bradenmacdonald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Generally looks great, thanks! I'll try to test this tomorrow; didn't get time today. If you can make the path customizeable in the meantime, that will make it easier for me to test since I don't use devstack.

Comment thread README.md Outdated
Comment thread generate.py Outdated
Comment thread generate.py Outdated
@yusuf-musleh
yusuf-musleh force-pushed the yusuf-musleh/implement-generate-taxonomy-data branch from d1bc0e4 to 32431b3 Compare October 10, 2023 10:17

@bradenmacdonald bradenmacdonald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great and seems to have worked well! A couple notes:

Comment thread README.md
Comment thread generate.py
@bradenmacdonald

Copy link
Copy Markdown
Member

BTW I also had to change the default user name, because there are no standard users on Tutor devstacks. So the first time I ran it, I saw an error about UserDoesNotExist, but I fixed it easily by changing the variable.

@yusuf-musleh

Copy link
Copy Markdown
Contributor Author

BTW I also had to change the default user name, because there are no standard users on Tutor devstacks. So the first time I ran it, I saw an error about UserDoesNotExist, but I fixed it easily by changing the variable.

Oh I see, I thought edx@example.com was a universally available user. I added a note in the README for folks to modify if needed.

@bradenmacdonald bradenmacdonald left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

  • I tested this: imported it into my devstack
  • I read through the code
  • I checked for accessibility issues: n/a
  • Includes documentation: README

@yusuf-musleh
yusuf-musleh merged commit 973a4c6 into main Oct 15, 2023
@yusuf-musleh
yusuf-musleh deleted the yusuf-musleh/implement-generate-taxonomy-data branch October 15, 2023 07:01
@bradenmacdonald

Copy link
Copy Markdown
Member

@pomegranited @rpenido @ChrisChV Please check out this nice work from @yusuf-musleh! I'd like everyone working on the taxonomy project to import these taxonomies/courses/tags into their devstack please. In FAL-3531 we will soon put these onto the sandbox too.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tagging] Sample taxonomy and org data

2 participants