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

Add --manifest-only option to exportcontent command #12059

Merged
merged 4 commits into from
Apr 12, 2024

Conversation

thesujai
Copy link
Contributor

@thesujai thesujai commented Apr 6, 2024

Summary

Adds a new --manifest-only option to just export the manifest.json file instead of entire content data in the exportcontent command

References

Fixes #10384

Reviewer guidance

Run the below command:

kolibri manage exportcontent 0e173fca6e9052f8a474a2fb84055faf <path-to-export> --manifest-only

Observe only manifest.json getting generated, contrary to above command being used without --manifest-only which will also generate content


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added the DEV: backend Python, databases, networking, filesystem... label Apr 6, 2024
@thesujai thesujai changed the title Add --manifest-only option Add --manifest-only option to exportcontent command Apr 6, 2024
@thesujai thesujai marked this pull request as draft April 6, 2024 14:56
@thesujai
Copy link
Contributor Author

thesujai commented Apr 6, 2024

I need to add tests here

logger.info(
"Exporting content for channel id {} to {}".format(channel_id, data_dir)
)
exported_files = []
Copy link
Contributor Author

@thesujai thesujai Apr 6, 2024

Choose a reason for hiding this comment

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

How about moving this copying part to a separate method? It will be more readable

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that seems fine to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright will do that!

@MisRob MisRob requested a review from rtibbles April 8, 2024 02:31
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

This looks like the right change so far! Agree with the small refactor, and this will be good to go with a couple of tests.

See this class for existing tests for this management command, additional tests can be added there! https://github.com/learningequality/kolibri/blob/develop/kolibri/core/content/test/test_import_export.py#L2176

logger.info(
"Exporting content for channel id {} to {}".format(channel_id, data_dir)
)
exported_files = []
Copy link
Member

Choose a reason for hiding this comment

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

Yes, that seems fine to me.

@rtibbles rtibbles self-assigned this Apr 11, 2024
@thesujai
Copy link
Contributor Author

I have included with tests as well

@thesujai thesujai marked this pull request as ready for review April 11, 2024 06:48
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Looks good to me, one optional piece of cleanup.

logger.info(
"Exporting content for channel id {} to {}".format(channel_id, data_dir)
)
exported_files = []
Copy link
Member

Choose a reason for hiding this comment

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

I know you copy pasted this from the original implementation - but it seems like this exported_files value is not actually used? Feels like we could remove it and stop collecting the list if it's unused. At a minimum, it will slightly reduce memory usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!!

"exportcontent", self.the_channel_id, tempfile.mkdtemp(), manifest_only=True
)

copy_content_files_mock.assert_not_called()
Copy link
Member

Choose a reason for hiding this comment

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

Your refactor definitely makes asserting the behaviour here much simpler too!

@rtibbles
Copy link
Member

Excellent work, thanks @thesujai!

@rtibbles rtibbles merged commit 9d8ea58 into learningequality:release-v0.16.x Apr 12, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... SIZE: small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants