Merge pull request #36302 from ormsbee/remove-custom-startup

fix: remove custom startup to fix dev reloading
This commit is contained in:
Robert Raposa
2025-03-04 08:35:19 -05:00
committed by GitHub
9 changed files with 5 additions and 76 deletions

View File

@@ -6,10 +6,7 @@ pytest from looking for the conftest.py module in the parent directory when
only running cms tests.
"""
import importlib
import logging
import os
import pytest
@@ -29,13 +26,6 @@ def pytest_configure(config):
else:
logging.info("pytest did not register json_report correctly")
if config.getoption('help'):
return
settings_module = os.environ.get('DJANGO_SETTINGS_MODULE')
startup_module = 'cms.startup' if settings_module.startswith('cms') else 'lms.startup'
startup = importlib.import_module(startup_module)
startup.run()
@pytest.fixture(autouse=True, scope='function')
def _django_clear_site_cache():

View File

@@ -1,20 +0,0 @@
"""
Module for code that should run during Studio startup (deprecated)
"""
import django
from django.conf import settings
# Force settings to run so that the python path is modified
settings.INSTALLED_APPS # pylint: disable=pointless-statement
def run():
"""
Executed during django startup
NOTE: DO **NOT** add additional code to this method or this file! The Platform Team
is moving all startup code to more standard locations using Django best practices.
"""
django.setup()

View File

@@ -18,9 +18,6 @@ defuse_xml_libs()
import os # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cms.envs.aws")
import cms.startup as startup # lint-amnesty, pylint: disable=wrong-import-position
startup.run()
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import get_wsgi_application # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position

View File

@@ -1,20 +0,0 @@
"""
Module for code that should run during LMS startup (deprecated)
"""
import django
from django.conf import settings
# Force settings to run so that the python path is modified
settings.INSTALLED_APPS # pylint: disable=pointless-statement
def run():
"""
Executed during django startup
NOTE: DO **NOT** add additional code to this method or this file! The Platform Team
is moving all startup code to more standard locations using Django best practices.
"""
django.setup()

View File

@@ -15,9 +15,6 @@ defuse_xml_libs()
import os # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.envs.aws")
import lms.startup as startup # lint-amnesty, pylint: disable=wrong-import-position
startup.run()
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import get_wsgi_application # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position

View File

@@ -14,9 +14,6 @@ import os # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-posi
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.envs.aws")
os.environ.setdefault("SERVICE_VARIANT", "lms")
import lms.startup as startup # lint-amnesty, pylint: disable=wrong-import-position
startup.run()
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import get_wsgi_application # lint-amnesty, pylint: disable=wrong-import-order, wrong-import-position

View File

@@ -12,7 +12,6 @@ Any arguments not understood by this manage.py will be passed to django-admin.py
"""
# pylint: disable=wrong-import-order, wrong-import-position
from openedx.core.lib.logsettings import log_python_warnings
log_python_warnings()
@@ -20,7 +19,6 @@ log_python_warnings()
from openedx.core.lib.safe_lxml import defuse_xml_libs # isort:skip
defuse_xml_libs()
import importlib
import os
import sys
from argparse import ArgumentParser
@@ -51,7 +49,6 @@ def parse_args():
help_string=lms.format_help(),
settings_base='lms/envs',
default_settings='lms.envs.devstack_docker',
startup='lms.startup',
)
cms = subparsers.add_parser(
@@ -70,7 +67,6 @@ def parse_args():
settings_base='cms/envs',
default_settings='cms.envs.devstack_docker',
service_variant='cms',
startup='cms.startup',
)
edx_args, django_args = parser.parse_known_args()
@@ -99,8 +95,5 @@ if __name__ == "__main__":
# This will trigger django-admin.py to print out its help
django_args.append('--help')
startup = importlib.import_module(edx_args.startup)
startup.run()
from django.core.management import execute_from_command_line
execute_from_command_line([sys.argv[0]] + django_args)

View File

@@ -1,6 +1,4 @@
"""Models governing integration with the catalog service."""
from config_models.models import ConfigurationModel
from django.conf import settings
from django.contrib.auth import get_user_model
@@ -9,6 +7,8 @@ from django.utils.translation import gettext_lazy as _
from openedx.core.djangoapps.site_configuration import helpers
User = get_user_model()
class CatalogIntegration(ConfigurationModel):
"""
@@ -72,7 +72,4 @@ class CatalogIntegration(ConfigurationModel):
return helpers.get_value('COURSE_CATALOG_API_URL', settings.COURSE_CATALOG_API_URL)
def get_service_user(self):
# NOTE: We load the user model here to avoid issues at startup time that result from the hacks
# in lms/startup.py.
User = get_user_model() # pylint: disable=invalid-name
return User.objects.get(username=self.service_username)

View File

@@ -6,9 +6,8 @@ Here be dragons (and simians!)
* USE WITH CAUTION *
No, but seriously, you probably never really want to make changes here.
This module contains methods to monkey-patch [0] the edx-platform.
Patches are to be applied as early as possible in the callstack
(currently lms/startup.py and cms/startup.py). Consequently, changes
made here will affect the entire platform.
Patches are to be applied as early as possible in the callstack). Consequently,
changes made here will affect the entire platform.
That said, if you've decided you really need to monkey-patch the
platform (and you've convinced enough people that this is best
@@ -25,8 +24,7 @@ solution), kindly follow these guidelines:
- is_patched
- patch
- unpatch
- Add the following code where needed (typically cms/startup.py and
lms/startup.py):
- Add the following code where needed:
```
from openedx.core.djangoapps.monkey_patch import your_module
your_module.patch()