-
Notifications
You must be signed in to change notification settings - Fork 18
[FC-0049] fix: Issues when importing a large taxonomy #189
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
Merged
bradenmacdonald
merged 5 commits into
openedx:main
from
open-craft:chris/FAL-3721-issues-importing-large-taxonomy
May 17, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7d29d81
feat: Add elpased time to import taxonomy process
ChrisChV 1fe1bfd
fix: Time & Memory performance of import taxonomies
ChrisChV 7163bce
style: Some nits to improve the import taxonomy code
ChrisChV afa0977
chore: Bump version
ChrisChV 2130c8f
style: Update comment on import_export
ChrisChV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| """ | ||
| Open edX Learning ("Learning Core"). | ||
| """ | ||
| __version__ = "0.9.3" | ||
| __version__ = "0.9.4" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -244,16 +244,13 @@ def execute(self) -> None: | |
| """ | ||
| Creates a Tag | ||
| """ | ||
| parent = None | ||
| if self.tag.parent_id: | ||
| parent = self.taxonomy.tag_set.get(external_id=self.tag.parent_id) | ||
| taxonomy_tag = Tag( | ||
| Tag.objects.create( | ||
| taxonomy=self.taxonomy, | ||
| parent=parent, | ||
| parent=self.taxonomy.tag_set.get(external_id=self.tag.parent_id) | ||
| if self.tag.parent_id is not None else None, | ||
| value=self.tag.value, | ||
| external_id=self.tag.id, | ||
| ) | ||
| taxonomy_tag.save() | ||
|
|
||
|
|
||
| class UpdateParentTag(ImportAction): | ||
|
|
@@ -409,8 +406,7 @@ def execute(self) -> None: | |
| Delete a tag | ||
| """ | ||
| try: | ||
| taxonomy_tag = self._get_tag() | ||
| taxonomy_tag.delete() | ||
| self._get_tag().delete() | ||
|
Comment on lines
-412
to
+409
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: similar to the above, if this had any performance improvement or just code style changes?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
| except Tag.DoesNotExist: | ||
| pass # The tag may be already cascade deleted if the parent tag was deleted | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Just curious if this had an impact on improving the performance or is it mainly making the code cleaner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It improves memory a little because it does not create an instance of Tag, but uses the create function. It was the first thing I tried, but it wasn't the root of the problem. I left it like this because it looks cleaner.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tag.objects.create(...)still creates aTaginstance and calls.save()on it for you, and returns it. It may be garbage-collected slightly better if you don't keep the returned Tag instance here, but I wouldn't expect any major difference. I do like thecreate()version more though - it is cleaner.