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

Taxonomy import templates [FC-0036] #89

Merged
merged 5 commits into from
Oct 9, 2023

Conversation

pomegranited
Copy link
Contributor

@pomegranited pomegranited commented Oct 2, 2023

This PR adds CSV and JSON templates which demonstrate the format for Taxonomy Administrators to use when importing the tags to a taxonomy.

The templates use an ignored "comments" fields to explain how to use the template inline with the example. To support this, I altered the taxonomy import code to ignore any unexpected fields. Ignoring unexpected fields will also make it easier for users to import files provided by external taxonomy suppliers, as these are likely to contain more fields than we need.

Also adds tests to ensure that the templates import without error.

Closes openedx/modular-learning#137

Private-ref: FAL-3520

Testing instructions

  1. Using this branch, run the dev server: python manage.py runserver
  2. Download the template files:
    http://127.0.0.1:8000/tagging/rest_api/v1/import/template.csv
    http://127.0.0.1:8000/tagging/rest_api/v1/import/template.json
  3. Check that the files download as expected.

TO DO BEFORE MERGE

  • Bump version to 0.2.2

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

openedx-webhooks commented Oct 2, 2023

Thanks for the pull request, @pomegranited! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Oct 2, 2023
@pomegranited pomegranited force-pushed the jill/taxonomy-templates branch 4 times, most recently from 7c82a49 to d302a98 Compare October 4, 2023 00:53
This allows us to add comments to our template import files, but more
importantly, allows users to import tags from an external source which
may have extra data we don't care about.
These files are annotated with a "comments" field, explaining how taxonomy tag imports work.

The tests verify that these files are imported without error, and that they create the expected tags.
@pomegranited pomegranited force-pushed the jill/taxonomy-templates branch from fe72564 to 1476d44 Compare October 5, 2023 03:37
@pomegranited pomegranited marked this pull request as ready for review October 5, 2023 03:42
@rpenido
Copy link
Contributor

rpenido commented Oct 5, 2023

Hi @pomegranited! Good work here!

I really like how you always came up with meaningful sample data, instead of "tag 1", "tag 2", etc.. 😃

I made a comment about our parser that I think we should be aware, but is not related to this PR.

  • I read through the code
  • I checkout the branch and run the tests
  • I run the server and downloaded both templates

for opt_field in cls.optional_fields:
if opt_field in tag and not tag.get(opt_field):
tag[opt_field] = None
tag_data[opt_field] = tag.get(opt_field) or None
Copy link
Contributor

Choose a reason for hiding this comment

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

If tag_data[opt_field] is falsy (i.e. 0), we are overriding with None.

I don't think this is a problem because our optional_fields only have the external_id, but we may have some issues using this parser for other things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rpenido Yeah, I was preserving the previous behavior with that change, since the CSV parser will send us empty strings for parent_id, when what we really want is None.
I think that if we ever need the parser to do something different, then there will be a clear use case, and the code and tests can be modified then.

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

Very nice work!

@pomegranited pomegranited merged commit b2767fa into openedx:main Oct 9, 2023
6 checks passed
@openedx-webhooks
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FC Relates to an Axim Funded Contribution project 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.

[Tagging] Create Taxonomy Templates
5 participants