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

Use manifest.json files to download collections #436

Merged
merged 9 commits into from
Jul 14, 2022
Merged

Conversation

danigm
Copy link
Contributor

@danigm danigm commented Jun 29, 2022

@erikos erikos requested a review from dylanmccall July 5, 2022 20:21
@danigm danigm force-pushed the manifest-import branch 2 times, most recently from 8d3a5fe to fed0380 Compare July 8, 2022 08:37
@danigm
Copy link
Contributor Author

danigm commented Jul 8, 2022

This is a custom build of the plugin for testing:
kolibri_explore_plugin-2.0.17-py2.py3-none-any.zip

@danigm danigm force-pushed the manifest-import branch 2 times, most recently from fad508a to ce50571 Compare July 11, 2022 10:38
@danigm danigm marked this pull request as ready for review July 11, 2022 16:45
@danigm danigm force-pushed the manifest-import branch from ce50571 to f7cc19f Compare July 13, 2022 06:38
@erikos erikos requested a review from starnight July 13, 2022 09:58
@downloadCollection="downloadCollection"
@goBack="visibleModal = 'grade'"
/>
<InstallContentModal
:visible="contentModalVisible"
:collection="downloadingCollection"
:grade="grade"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like "grade" is an awkward word to use here since it's very specific to our current implementation, but at the same time the alternatives I can think of ("group", "category") would be terrrible and confusing, so 🤷

Comment on lines 190 to 191
for _grade, collections in self.COLLECTIONS.items():
for _k, v in collections.items():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Two small nitpicks: this collections variable is a narrower scope than COLLECTIONS, so I think it would be clearer if it was named grade_collections; and I'm wondering why we're using COLLECTIONS.items() instead of COLLECTIONS.values()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, it's better to use values instead of items and ignoring the key.

Comment on lines 259 to 266
else:
# Fallback, download full collection using the token
token = self.COLLECTIONS[grade][collection]["token"]

channel_viewset = RemoteChannelViewSet()
channels = channel_viewset._make_channel_endpoint_request(
identifier=token
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we keep this fallback around? I can see the awkwardness we're avoiding since the manifest files are included as extra data, but the fallback only really kicks in if something goes wrong, and it behaves differently from the regular case. I can see it leading to confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's better to remove this fallback, because as you said it could hide some error and will make it more difficult to debug. I'll replace with an error in the interface.

Comment on lines +283 to +286
# Done this way to convert [] to None
node_ids=channel.get("include_node_ids") or None,
# Done this way to convert [] to None
exclude_node_ids=channel.get("exclude_node_ids") or None,
Copy link
Collaborator

@dylanmccall dylanmccall Jul 13, 2022

Choose a reason for hiding this comment

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

👍 there's a subtle difference in how node_ids=[] is handled between the code that copies data and the code that marks nodes as available, so this is a useful way to deal with that.

It's worth noting this behaviour will be different with learningequality/kolibri#9460. Setting include_node_ids: [] is the same as saying "no nodes", while include_node_ids: None means "the default, which is all of the nodes".

Once we have Kolibri with my changes applied, the manifest file code should actually never create a manifest file with the latter: if it includes all the nodes from a channel, it ends up with include_node_ids: [${channel_id}]. If a manifest file has include_node_ids: [], it's probably wrong but there's no need arguing with it.

Hopefully in a future iteration we can pass a manifest file directly to the remoteimport task so we don't need to deal with all this :)

@dylanmccall
Copy link
Collaborator

Just a couple small suggestions, but nothing showstopping :) Feel free to merge this when you're happy with it, @danigm!

@danigm danigm force-pushed the manifest-import branch from ebc1b8a to 4068f9b Compare July 14, 2022 06:18
@danigm danigm merged commit 4652183 into master Jul 14, 2022
@danigm danigm deleted the manifest-import branch July 14, 2022 07:41
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.

2 participants