* Python code cleanup by the cleanup-python-code Jenkins job.
This pull request was generated by the cleanup-python-code Jenkins job, which ran
```
cd lms/djangoapps/dashboard; find . -type f -name '*.py' | while read fname; do sed -i 's/ # lint-amnesty, pylint: disable=super-with-arguments//; s/ # lint-amnesty, pylint: disable=import-error, wrong-import-order//; s/ # lint-amnesty, pylint: disable=wrong-import-order//' "$fname"; done; find . -type f -name '*.py' | while read fname; do pyupgrade --exit-zero-even-if-changed --py3-plus --py36-plus --py38-plus "$fname"; done; isort --recursive .
```
The following packages were installed:
`pyupgrade,isort`
* feedback done
Co-authored-by: Zulqarnain <muhammad.zulqarnain@arbisoft.com>
* 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
* Use full LMS imports paths in LMS settings and urls modules
* Use full LMS import paths in Studio settings and urls modules
* Import from lms.djangoapps.badges instead of badges
* Import from lms.djangoapps.branding instead of branding
* Import from lms.djangoapps.bulk_email instead of bulk_email
* Import from lms.djangoapps.bulk_enroll instead of bulk_enroll
* Import from lms.djangoapps.ccx instead of ccx
* Import from lms.djangoapps.course_api instead of course_api
* Import from lms.djangoapps.course_blocks instead of course_blocks
* Import from lms.djangoapps.course_wiki instead of course_wiki
* Import from lms.djangoapps.courseware instead of courseware
* Import from lms.djangoapps.dashboard instead of dashboard
* Import from lms.djangoapps.discussion import discussion
* Import from lms.djangoapps.email_marketing instead of email_marketing
* Import from lms.djangoapps.experiments instead of experiments
* Import from lms.djangoapps.gating instead of gating
* Import from lms.djangoapps.grades instead of grades
* Import from lms.djangoapps.instructor_analytics instead of instructor_analytics
* Import form lms.djangoapps.lms_xblock instead of lms_xblock
* Import from lms.djangoapps.lti_provider instead of lti_provider
* Import from lms.djangoapps.mobile_api instead of mobile_api
* Import from lms.djangoapps.rss_proxy instead of rss_proxy
* Import from lms.djangoapps.static_template_view instead of static_template_view
* Import from lms.djangoapps.survey instead of survey
* Import from lms.djangoapps.verify_student instead of verify_student
* Stop suppressing EdxPlatformDeprecatedImportWarnings
This commit upgrades the version of pymongo from 2.x to 3.x, removing usages to deprecated functions usage and fixing tests where necessary.
This version of pymongo supports MongoDB 2.x all the way up to 4.2, and this ensures that the platform will be able to run on a supported MongoDB version in the next release.
There is no significant impact to this change;
it's just some general cleanup that I made while cleaning up this file..
We don't need to store these as instance variables,
since we never use them as such.
And since we've already factored out the remaining code from this
initialization method, we can drop it entirely.
We were performing this lookup multiple times in the POST handler;
this should increase speed and memory use, which has been problematic
with this feature.
I'm admittedly unclear why we decided to include a listing of _courses_
in the _users_ tab, when this listing is already available via the
_courses_ tab, which is where you'd expect to find it.
Particularly problematic here is the impact this has on page loads..
For instances with a large number of courses [1], pulling and rendering
adds a nontrivial amount of overhead and leads to longer load times.
In our case, this often leads to a page timeout. Since this is the main
landing page for the sysadmin dashboard, it presents the appearance that
the entire dashboard has crashed. In not being able to access the main
page, you can't access any of the other tabs via navigation, unless you
manually enter the URL :\
[1] ~750 courses, in one example
We've been running into OoM issues with this functionality while
executing on one of our smaller application servers.
- Sometimes this manifests by preventing the entire page from loading
(exception during the GET).
- At others, it occurs using the `Delete course from site` functionality
by breaking during the POST handler. This case is particularly
frustrating because the course actually is deleted, but looks like it
may not have been. Internally, this is because the 500 error occurs
_after_ the course has been successfully deleted, though this is
opaque to the end-user.
While this doesn't address the underlying memory issue,
it does at least allow the app to recover gracefully.
Use the course key as the primary key for storing coure import logs in
mongo, instead of the deprecated course key (this only applies to
courses imported via git_import.py).
No effort is made to migrate existing logs, since they are ephemeral.
The old line:
from path import path
produced pylint errors because of the baroque way that path.py defined
"path". We tried to get them to change how they defined it, but they
deleted the name instead: https://github.com/jaraco/path.py/issues/102
(Jason then changed his mind, but this is a better way to use path.py,
it avoids the pylint error at least.)
only require ccx-keys once
get_current_ccx will now expect a CourseKey instance as its argument, and will raise a value error if this expectation is not met.
document reason for local import
add special methods to pass attribute setting and deletion through to the wrapped modulestore
add __setattr__ and __delattr__ per code review, update __init__ to work with new methods
style change per code review
clean up context manager usage as recommended by code review
remove unused code and imports
convert modulestore type tests to use the `get_modulestore_type` api, remove unused imports
code quality: add docstrings
increase coverage for utils tests
fix bug found in testing.
increase test coverage on modulestore wrapper
code quality fixes
code-quality: ignore import error, but mark site for future consideration
remove references to middleware that were missed previously
use key apis rather than local implementation of key conversion. remove local implementationa
remove spurious test for attribute
fix test setUp to avoid unneeded flattening
code quality fixes
add security check ensuring that the coach is coach for *this* CCX.
prevent ccx/deprecated course id problems
1. do not allow ccx objects to be created if the course id is deprecated
2. filter out any ccx memberships that involve deprecated course ids (in case there are bad ccxs in the database)
Fix test failures and errors arising from incorrect code path execution
Create context manager to handle unwrapping and restoring ccx values for the modulestore wrapper, employ it throughout modulestore wrapper implementation