Commit Graph

93 Commits

Author SHA1 Message Date
Raul Gallegos
e1614b5324 fix: revert back the bundle_draft_files cache key (#26897)
Changes the LMS/Studio bundle cache key,
thus invalidating all 47hr-TTL entries
in favor of new 50min-TTL entries.

TNL-7771
2021-03-08 12:34:51 -05:00
Kyle McCormick
9aefd6f986 style: django-not-configured is not a sensible lint-amnesty value (#26862)
django-not-configured is an error raised by pylint (with
the pylint-django plugin) when it's not correctly configured.

We should not be applying lint amnesty for such a violation.
2021-03-05 08:11:58 -05:00
Aarif
c21ac0c3df replaced unittest assertions pytest assertions (#26573) 2021-02-22 20:04:27 +05:00
usamasadiq
297dfd9718 Applied pylint amnesty 2021-02-04 19:14:40 +05:00
Jawayria
1e0655d26b Resolved pep8 errors 2021-02-02 21:15:43 +05:00
Jawayria
9909b933a7 Applied pylint-amnesty to openedx/core/{djangolib, lib, tests, *.py 2021-02-02 21:13:24 +05:00
Raul Gallegos
d3584ad559 SE-3764: adds a new bundle_draft_files cache key (#25881)
Updates the bundle_draft_files cache key to be _v2 so we avoid reading
invalid values cached by a past version of this code with no timeout.

TNL-7771
2020-12-15 11:09:04 -05:00
Raul Gallegos
5279975483 [TNL-7771][LX-1409] sets blockstore values timeouts to avoid S3 links expiration (#25830) 2020-12-11 09:35:45 -05:00
Kyle McCormick
151bd13666 Use full names for common.djangoapps imports; warn when using old style (#25477)
* Generate common/djangoapps import shims for LMS
* Generate common/djangoapps import shims for Studio
* Stop appending project root to sys.path
* Stop appending common/djangoapps to sys.path
* Import from common.djangoapps.course_action_state instead of course_action_state
* Import from common.djangoapps.course_modes instead of course_modes
* Import from common.djangoapps.database_fixups instead of database_fixups
* Import from common.djangoapps.edxmako instead of edxmako
* Import from common.djangoapps.entitlements instead of entitlements
* Import from common.djangoapps.pipline_mako instead of pipeline_mako
* Import from common.djangoapps.static_replace instead of static_replace
* Import from common.djangoapps.student instead of student
* Import from common.djangoapps.terrain instead of terrain
* Import from common.djangoapps.third_party_auth instead of third_party_auth
* Import from common.djangoapps.track instead of track
* Import from common.djangoapps.util instead of util
* Import from common.djangoapps.xblock_django instead of xblock_django
* Add empty common/djangoapps/__init__.py to fix pytest collection
* Fix pylint formatting violations
* Exclude import_shims/ directory tree from linting
2020-11-10 07:02:01 -05:00
David Ormsbee
bfce2af065 Merge pull request #24058 from open-craft/arbrandes/optimize-blockstore-cache-v2
Optimize blockstore cache
2020-06-19 12:11:59 -04:00
Leonardo Martinez
b4fee68283 Fix the DeprecationWarning for unescape (#23936)
This PR solves the DeprecationWarning mentioned in:
https://build.testeng.edx.org/job/edx-platform-python-pipeline-master/warning_5freport_5fall_2ehtml/

HTMLParser was renamed in html.parser in Python3:
https://docs.python.org/2/library/htmlparser.html#module-HTMLParser

* html_parser.HTMLParser().unescape from six.moves has been deprecated

* instead use html.unescape from Python3

Documentation for unescape in Python3:
https://docs.python.org/3/library/html.html#html.unescape

- html_parser from six.moves has been deprecated

- instead use html.parser from Python3

- Order imports using isort

- Delete unused import crum
2020-06-19 09:27:45 -04:00
Adolfo R. Brandes
b2e90bc442 Optimize blockstore cache
First off, this fixes a bug where BundleCache would only set caches for
the duration of the default timeout, defeating the cache versioning
strategy.

Second, this adds an optimization so that bundle draft files are cached
as soon as possible.
2020-05-27 21:28:25 -03:00
Aarif
6ee2089077 fixed warnings for wrong-import-order 2020-04-08 23:43:06 +05:00
Braden MacDonald
4bb5cb52a6 Improve caching of blockstore data
This includes an optimization to the get_bundle_version_files_cached method, which is used very often when loading blockstore data; it was previously being cached only in a process-local cache (lru_cache). My hunch is that in production, with many appservers and LMS workers and frequent deployments and a large number of bundles, the process-local cache is not being hit very often.

I also increased the MAX_BLOCKSTORE_CACHE_DELAY from 60s to 300s; this reduces the frequency with which we check if either (A) an external system modified the blockstore bundle and/or (B) we have a cache invalidation bug somewhere. I am increasing it because that check is more expensive than I thought (calling blockstore API to ascertain latest version of a particular bundle), and I haven't seen any cache invalidation errors that this would help to work around. (Plus, increasing this will make such bugs more obvious.)
2020-03-13 14:25:21 -07:00
Braden MacDonald
a8d5749b6b Fix: transient S3 errors were not being reported properly
Also improve usefulness of some blockstore runtime logs for debugging

Context:

Sometimes when trying to load an XBlock's XML file from Amazon S3, AWS will return a 4xx or 5xx response along with error XML like:

    <Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>foo/bar</Key>...</Error>

A bug in the get_bundle_file_data_with_cache method would cause this XML to be returned to the runtime anyways, as if it were the expected OLX. This would then (obviously) lead to strange parsing bugs, e.g. when trying to interpret <Code> as an <xblock-include>.

This fixes the bug and improves the logging, both to make this sort of issue easier to debug in the future and to return whatever detailed error code S3 provides (or Blockstore, if S3 is not being used).
2020-03-12 16:29:43 -07:00
David Ormsbee
09c5432415 Revert "Fix Blockstore XBlock Runtime's handling of occasional S3 errors" 2020-03-12 15:09:23 -04:00
Braden MacDonald
8b9594e7dd Improve caching of blockstore data
This includes an optimization to the get_bundle_version_files_cached method, which is used very often when loading blockstore data; it was previously being cached only in a process-local cache (lru_cache). My hunch is that in production, with many appservers and LMS workers and frequent deployments and a large number of bundles, the process-local cache is not being hit very often.

I also increased the MAX_BLOCKSTORE_CACHE_DELAY from 60s to 300s; this reduces the frequency with which we check if either (A) an external system modified the blockstore bundle and/or (B) we have a cache invalidation bug somewhere. I am increasing it because that check is more expensive than I thought (calling blockstore API to ascertain latest version of a particular bundle), and I haven't seen any cache invalidation errors that this would help to work around. (Plus, increasing this will make such bugs more obvious.)
2020-03-11 11:15:59 -07:00
Braden MacDonald
4ddb02eff8 Fix: transient S3 errors were not being reported properly
Also improve usefulness of some blockstore runtime logs for debugging

Context:

Sometimes when trying to load an XBlock's XML file from Amazon S3, AWS will return a 4xx or 5xx response along with error XML like:

    <Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>foo/bar</Key>...</Error>

A bug in the get_bundle_file_data_with_cache method would cause this XML to be returned to the runtime anyways, as if it were the expected OLX. This would then (obviously) lead to strange parsing bugs, e.g. when trying to interpret <Code> as an <xblock-include>.

This fixes the bug and improves the logging, both to make this sort of issue easier to debug in the future and to return whatever detailed error code S3 provides (or Blockstore, if S3 is not being used).
2020-03-11 11:15:59 -07:00
Manjinder Singh
d08cd9ce04 Removing provider imports from edx-platform (#23229)
* Removing from provider imports from openedx

 * removed all uses of retire_dop_oauth2_models

* Removing provider library from lms, common, and cms

Created/copied function short_token(from django-oauth-provider) and create_hash256 to help with conversion
2020-03-02 08:56:54 -05:00
Feanil Patel
2df8b8226b Merge pull request #22643 from edx/feanil/2to3_asserts
Run `2to3 -f asserts . -w` on edx-platform.
2019-12-30 12:13:42 -05:00
Feanil Patel
9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00
Feanil Patel
70294b0ad2 Run 2to3 -f asserts . -w on edx-platform.
https://docs.python.org/3.5/library/2to3.html#2to3fixer-asserts
2019-12-30 10:22:19 -05:00
Taranjeet Singh
00653433a5 Adds optional "unsubscribe" link and api support to let users opt out of email updates.
Scheduled emails show "unsubscribe" link if waffle switch
`schedules.course_update_show_unsubscribe` is enabled, and
settings.ACE_ENABLED_POLICIES respects `bulk_email_optout`.

API endpoint allows GET/POST requests, which:

* GET asks for confirmation of opt-out
* POST accepts "unsubscribe" or "cancel", where "unsubscribe" creates the
  Optout entry, and "cancel" does nothing.

Fixes flaky tests:

* The resolvers handle users in "bins", which are groups that depend on the user ID.
* The test user ID varies depending on the test order.
* This change ensures that the bin requested matches the user for the test.
2019-12-09 22:49:57 +10:30
Braden MacDonald
1ea3c032d3 Fixes for the blockstore API client / XBlock runtime under python 3 2019-12-05 09:24:24 -08:00
jinder1s
93dcd26118 quality fixes 2019-10-09 09:30:52 -04:00
jinder1s
d8b7a2e1fe quality fixes 2019-10-09 08:53:22 -04:00
jinder1s
075faede22 Modifying test to work in both py2 and 3 2019-10-09 08:53:22 -04:00
aarif
13afdbb84c python 3 fixes
minor changes
2019-09-27 15:59:03 +05:00
Ayub khan
f0a16d2aea BOM-455
python3 compatibility
2019-09-13 15:35:18 +05:00
Awais Qureshi
98ec44b56c BOM-404
Fixing python3
2019-09-11 12:52:56 +05:00
Braden MacDonald
d3f6ed09d8 Learning Contexts, New XBlock Runtime, Blockstore API Client + Content Libraries
https://github.com/edx/edx-platform/pull/20645

This introduces:
* A new XBlock runtime that can read and write XBlocks that are persisted using
  Blockstore instead of Modulestore. The new runtime is currently isolated so
  that it can be tested without risk to the current courseware/runtime.
* Content Libraries v2, which store XBlocks in Blockstore not modulestore
* An API Client for Blockstore
* "Learning Context" plugin API. A learning context is a more abstract concept
  than a course; it's a collection of XBlocks that serves some learning purpose.
2019-08-30 10:31:15 -07:00
Hammad Ahmad Waqas
63d7b7d6fa applying filter to remove dangerous html content before rendering in
course_about page on course overview field
2019-06-21 16:06:26 +05:00
aliciaerwin
140fb1394e INCR-166 Run python-modernize on openedx/core/djangolib (#20473)
* INCR-166 Run python-modernize on openedx/core/djangolib

* INCR-166 disabled harmless errors and added docstring
2019-05-09 13:59:48 -04:00
Jeremy Bowman
5c7a8e3ac1 Merge pull request #19622 from cclauss/Fix-parens-for-Python3
Fix explicit tuple parameters for Python 3
2019-02-21 15:45:09 -05:00
Calen Pennington
78c8950ea3 Clean up a few remaining unicode format string errors 2019-02-20 15:28:14 -05:00
cclauss
44d62fac75 Fix explicit tuple parameters for Python 3 2019-02-19 12:37:34 +01:00
Matthew Piatetsky
444799fb0e fix unicode strings in openedx/ part 2 2019-02-15 10:15:51 -05:00
Michael Youngstrom
4bbd1dee0b Remove shards from commonlib-unit tests 2019-02-12 14:28:35 -05:00
Calen Pennington
9ff9c33f59 Add a test that shows how bad course api query counts are 2019-02-06 10:11:15 -05:00
Calen Pennington
805f32a357 Revert "Allow courses api to return data incrementally" 2019-01-25 12:56:57 -05:00
Calen Pennington
ee75db2703 Add a test that shows how bad course api query counts are 2019-01-24 22:54:01 -05:00
Robert Raposa
ba4cc62ff8 Retire deprecated RequestCache (Take 2)
ARCH-223
2018-09-08 15:09:28 -04:00
Michael Youngstrom
bc1d883e1a Dont let DarkLangConfig cache interfere with other tests 2018-09-06 10:33:54 -04:00
Nimisha Asthagiri
4ca165f690 Revert "ARCH-223: Retire deprecated RequestCache." 2018-08-30 16:33:03 -04:00
Robert Raposa
3df339a56a Retire deprecated RequestCache.
ARCH-223
2018-08-30 08:55:19 -04:00
Michael Youngstrom
8aed0ff719 Clean up after any get_mock_request or set_current_request calls 2018-08-22 17:23:39 -04:00
Jeremy Bowman
3ff3eee2f2 TE-2689 Remove useless pylint suppressions part 4 2018-08-20 12:54:22 -04:00
Robert Raposa
99c9eb7343 Migrate to edx-django-utils monitoring.
ARCH-220
2018-08-17 15:39:04 -04:00
Jeremy Bowman
c290bf8a07 TE-2524 Stop using nose.plugins - openedx 2018-08-02 14:54:50 -04:00
Alessandro Roux
197f1fb17a Merge pull request #18012 from edx/roux/oauth2-retire
EDUCATOR-2703: adds user retirement to OAuth2 tables
2018-05-03 09:18:56 -04:00