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

Automatic content syncing: preferred instance tracking and fixes #11083

Merged
merged 31 commits into from
Aug 15, 2023

Conversation

bjester
Copy link
Member

@bjester bjester commented Aug 9, 2023

Summary

Resolves issues with stalled 'My Downloads' through final integration of device settings features and usage of a reserved Network Location for Studio, allowing us to set a preference for which device to source downloads from.

Details

  • Adds source_instance_id to ContentRequest model as the preferred instance to source the content from
  • Updates ContentDownloadRequest API to support source_instance_id
  • Adds validator to automatic content download task, aligned with whether or not it's enabled
  • Adds tests for content_request utilities handling metadata import, peer processing, and total size annotations
  • Corrects issues with total size annotations returning 0
  • Filters out incomplete downloads for learners when learners are disallowed from creating download requests
  • Updates NetworkLocation models to use location_type field instead of dynamic boolean and necessary migrations (planned in Reserved network locations for Studio and KDP #10431)
  • Creates reserved NetworkLocation for Studio using UUID generated from CENTRAL_CONTENT_BASE_URL
  • Updates NetworkLocation API to allow detail retrieval using instance_id assuming lack of conflicts, and excludes reserved locations in list responses
  • Prevents strict comparison of instance_id and overwriting it for reserved NetworkLocations until we can get Studio to return the same instance ID
  • Consolidates duplicate NetworkLocationResource APIs on the frontend
  • Refactors existing canDownload allowing users to download resources externally, to disambiguate between new download feature
  • Updates Learn useDevices composable to compare route and current device by instance_id
  • Adds logging to catch() in learn's routing, and removes potentially duplicate calls to router.replace
  • Integrates allow_learner_download_resources device setting in the frontend to only show the download button when enabled
  • Upgrades le_utils from 0.1.38 to 0.2.1

References

learningequality/le-utils#111
Fixes #10732
Resolves #11022
Contributes to #10386
Starts #10431

Reviewer guidance

  1. Requires you to manually run:
kolibri manage migrate discovery --database networklocation
  1. In order to download from Studio, you need to change the setting in options.ini to the hotfixes server

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 DEV: backend Python, databases, networking, filesystem... APP: Device Re: Device App (content import/export, facility-syncing, user permissions, etc.) APP: Learn Re: Learn App (content, quizzes, lessons, etc.) SIZE: very large labels Aug 9, 2023
@bjester bjester marked this pull request as ready for review August 9, 2023 22:43
@bjester bjester added the TODO: needs review Waiting for review label Aug 9, 2023
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.

Just a couple of questions - but nothing that should be blocking merge.

kolibri/core/content/test/test_content_app.py Outdated Show resolved Hide resolved
is_learner_download=Case(
When(
source_model=FacilityUser.morango_model_name,
then=FixedExists(
Copy link
Member

Choose a reason for hiding this comment

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

Is the error this is fixing specific to using the Exists subquery in a then statement?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure. There seemed to be some mixing of parameter definitions and invocation styles with regards to single args and keyword args in the calls to resolve_expression. The function parameters are indeed all keyword args, but I recall seeing instances in other Django expressions where it was called with plain args, like this Case(then=) does here, but they happened to match the keyword arguments, which would still work right? The Exists wildcarded the keyword args, which seemed to cause the issue.

kolibri/core/content/utils/content_request.py Outdated Show resolved Hide resolved
kolibri/core/content/utils/content_request.py Outdated Show resolved Hide resolved
kolibri/core/content/utils/content_request.py Outdated Show resolved Hide resolved
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.

Code changes make sense, and manual testing checks out (weird local data issues aside!)

@rtibbles rtibbles merged commit 38c3ab2 into learningequality:release-v0.16.x Aug 15, 2023
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APP: Device Re: Device App (content import/export, facility-syncing, user permissions, etc.) APP: Learn Re: Learn App (content, quizzes, lessons, etc.) DEV: backend Python, databases, networking, filesystem... SIZE: very large TODO: needs review Waiting for review
Projects
None yet
2 participants