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 full names for common.djangoapps imports; warn when using old style #25477

Merged
merged 20 commits into from
Nov 10, 2020

Conversation

kdmccormick
Copy link
Member

@kdmccormick kdmccormick commented Oct 29, 2020

This is of the sys.path modification removal & cleanup, started by https://github.com/edx/edx-platform/pull/24616 . See the ADR for details.

This PR fixes all imports of common/djangoapps code to use the preferred style (import common.djangoapps.myapp..) instead of the deprecated short version (import student...). It also adds those modules to import_shims/lms and import_shims/studio to provide partial and temporary support for the old, shorter import style. Warnings of the class DeprecatedEdxPlatformImportWarning are generated when the old style is used.

Related ARCH-BOM ticket: https://openedx.atlassian.net/browse/ARCHBOM-1550

@kdmccormick kdmccormick force-pushed the kdmccormick/sys-path-hacks-common branch 6 times, most recently from 03b9a3c to 9d3f646 Compare November 4, 2020 15:01
@kdmccormick kdmccormick changed the title [WIP] Stop appending common/djangoapps to sys.path Use full names for common.djangoapps imports; warn when using old style Nov 4, 2020
@kdmccormick kdmccormick force-pushed the kdmccormick/sys-path-hacks-common branch 3 times, most recently from 1c0ab81 to 259768f Compare November 5, 2020 00:51
@kdmccormick
Copy link
Member Author

@nedbat FYI, I amended a silly mistake in the "fix pylint violations" commit and rebased. I did the same for the canary PR.

@kdmccormick kdmccormick force-pushed the kdmccormick/sys-path-hacks-common branch from 259768f to e0b062f Compare November 9, 2020 14:57
@kdmccormick kdmccormick force-pushed the kdmccormick/sys-path-hacks-common branch 3 times, most recently from cc31f67 to e92a6e3 Compare November 9, 2020 17:27
@kdmccormick kdmccormick marked this pull request as ready for review November 9, 2020 18:15
@edx-status-bot
Copy link

Your PR has finished running tests. There were no failures.

@kdmccormick kdmccormick merged commit 151bd13 into master Nov 10, 2020
@kdmccormick kdmccormick deleted the kdmccormick/sys-path-hacks-common branch November 10, 2020 12:02
kdmccormick added a commit that referenced this pull request Nov 10, 2020
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR may have caused e2e tests to fail on Stage. If you're a member of the edX org, please visit #e2e-troubleshooting on Slack to help diagnose the cause of these failures. Otherwise, it is the reviewer's responsibility. E2E tests have failed. https://gocd.tools.edx.org/go/tab/pipeline/history/deploy_to_stage

@kdmccormick
Copy link
Member Author

^ e2e failures should be fixed by https://github.com/edx/edx-platform/pull/25558

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been rolled back from the production environment.

@kdmccormick
Copy link
Member Author

This may smooth the re-rollout: https://github.com/edx/edx-platform/pull/25566

kdmccormick added a commit that referenced this pull request Nov 10, 2020
When rolling out #25477, we dropped hundreds of email activation
tasks due to the renaming of student.send_activation_email
to common.djangoapps.student.send_activation_email,
and lost more when we rolled that PR back.
This happens because of blue/green deployment:
old workers are still online for a while after deploying,
so there is a period of time when the task names are mismatched.

To prevent this from happening again, this will make
it so the import changes don't change the names of
any of the Celery tasks.
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@regisb
Copy link
Contributor

regisb commented Nov 24, 2020

FYI @kdmccormick there is a change in this PR which is causing pylint to crash. To reproduce, run the following command:

$ pylint manage.py
Traceback (most recent call last):
  File "/home/regis/venvs/openedx3.8/bin/pylint", line 8, in <module>
    sys.exit(run_pylint())
  File "/home/regis/venvs/openedx3.8/lib/python3.8/site-packages/pylint/__init__.py", line 23, in run_pylint
    PylintRun(sys.argv[1:])
  File "/home/regis/venvs/openedx3.8/lib/python3.8/site-packages/pylint/lint.py", line 1689, in __init__
    linter.load_config_file()
  File "/home/regis/venvs/openedx3.8/lib/python3.8/site-packages/pylint/config.py", line 736, in load_config_file
    self.global_set_option(option, value)
  File "/home/regis/venvs/openedx3.8/lib/python3.8/site-packages/pylint/config.py", line 629, in global_set_option
    self._all_options[opt].set_option(opt, value)
  File "/home/regis/venvs/openedx3.8/lib/python3.8/site-packages/pylint/lint.py", line 729, in set_option
    checkers.BaseTokenChecker.set_option(self, optname, value, action, optdict)
  File "/home/regis/venvs/openedx3.8/lib/python3.8/site-packages/pylint/config.py", line 825, in set_option
    value = _validate(value, optdict, optname)
  File "/home/regis/venvs/openedx3.8/lib/python3.8/site-packages/pylint/config.py", line 234, in _validate
    return _call_validator(_type, optdict, name, value)
  File "/home/regis/venvs/openedx3.8/lib/python3.8/site-packages/pylint/config.py", line 215, in _call_validator
    return VALIDATORS[opttype](optdict, option, value)
  File "/home/regis/venvs/openedx3.8/lib/python3.8/site-packages/pylint/config.py", line 175, in _regexp_csv_validator
    return [_regexp_validator(_, name, val) for val in _csv_validator(_, name, value)]
  File "/home/regis/venvs/openedx3.8/lib/python3.8/site-packages/pylint/config.py", line 175, in <listcomp>
    return [_regexp_validator(_, name, val) for val in _csv_validator(_, name, value)]
  File "/home/regis/venvs/openedx3.8/lib/python3.8/site-packages/pylint/config.py", line 170, in _regexp_validator
    return re.compile(value)
  File "/home/regis/install/Python-3.8.5/lib/python3.8/re.py", line 252, in compile
    return _compile(pattern, flags)
  File "/home/regis/install/Python-3.8.5/lib/python3.8/re.py", line 304, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/home/regis/install/Python-3.8.5/lib/python3.8/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/home/regis/install/Python-3.8.5/lib/python3.8/sre_parse.py", line 948, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/home/regis/install/Python-3.8.5/lib/python3.8/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/home/regis/install/Python-3.8.5/lib/python3.8/sre_parse.py", line 668, in _parse
    raise source.error("nothing to repeat",
re.error: nothing to repeat at position 0

The regexp that pylint chokes on is ignore-patterns = **/import_shims/**/*.py. I was able to get pylint to work by commenting out this line from pylintrc.

@kdmccormick
Copy link
Member Author

@regisb Yeah, it looks like that ignore pattern fails when linting individual files. I have a fix ready for review in #25632 , which I was going to suggest should be cherry-picked into Koa.

@kdmccormick
Copy link
Member Author

@regisb That PR I just linked is merged now; I can open a PR against koa.master later today.

@regisb
Copy link
Contributor

regisb commented Nov 24, 2020

That PR I just linked is merged now; I can open a PR against koa.master later today.

Yes, I think that would be great. Thanks @kdmccormick!

@kdmccormick
Copy link
Member Author

mrtmm referenced this pull request in mrtmm/hastexo-xblock Mar 25, 2021
mrtmm referenced this pull request in mrtmm/hastexo-xblock Mar 25, 2021
mrtmm referenced this pull request in mrtmm/hastexo-xblock Mar 25, 2021
mrtmm referenced this pull request in mrtmm/hastexo-xblock Mar 26, 2021
mrtmm referenced this pull request in mrtmm/hastexo-xblock Mar 26, 2021
mrtmm referenced this pull request in mrtmm/hastexo-xblock Mar 26, 2021
mrtmm referenced this pull request in mrtmm/hastexo-xblock Mar 26, 2021
fghaas referenced this pull request in fghaas/hastexo-xblock Mar 26, 2021
The short way of defining imports will be deprecated.
(https://github.com/edx/edx-platform/pull/25477)

(cherry picked from commit 472f0d0)
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.

5 participants