Skip to content

Commit

Permalink
feat!: drop support for python3.8 and add support for 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
huniafatima-arbi committed Oct 24, 2024
1 parent 309f147 commit a50c1fc
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 134 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,10 @@ $(foreach asset_service,$(ASSET_SERVICES_LIST),\
dev.static: | $(_asset_compilation_targets)

dev.static.lms:
docker compose exec -T lms bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && paver update_assets lms'
docker compose exec -T lms bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && npm run build && ./manage.py lms collectstatic --noinput'

dev.static.cms:
docker compose exec -T cms bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && paver update_assets cms'
docker compose exec -T cms bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && npm run build && ./manage.py cms collectstatic --no-input'

dev.static.%: ## Rebuild static assets for the specified service's container.
docker compose exec -T $* bash -c 'source /edx/app/$*/$*_env && cd /edx/app/$*/$*/ && make static'
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-watchers.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
lms_watcher:
command: bash -c 'cd /edx/app/edxapp/edx-platform && source ../edxapp_env && while true; do paver watch_assets --w=$$ASSET_WATCHER_TIMEOUT; sleep 2; done'
command: bash -c 'cd /edx/app/edxapp/edx-platform && source ../edxapp_env && while true; do npm run watch --w=$$ASSET_WATCHER_TIMEOUT; sleep 2; done'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.lms_watcher"
environment:
FRONTEND_TEST_SERVER_HOSTNAME: edx.devstack.lms_watcher
Expand All @@ -18,7 +18,7 @@ services:
- edx.devstack.lms_watcher

cms_watcher:
command: bash -c 'cd /edx/app/edxapp/edx-platform && source ../edxapp_env && while true; do paver watch_assets --w=$$ASSET_WATCHER_TIMEOUT; sleep 2; done'
command: bash -c 'cd /edx/app/edxapp/edx-platform && source ../edxapp_env && while true; do npm run watch --w=$$ASSET_WATCHER_TIMEOUT; sleep 2; done'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.cms_watcher"
environment:
FRONTEND_TEST_SERVER_HOSTNAME: edx.devstack.cms_watcher
Expand Down
32 changes: 17 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
chrome:
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.chrome"
hostname: chrome.devstack.edx
image: edxops/chrome:${OPENEDX_RELEASE:-latest}
image: edxops/chrome:latest
shm_size: 2g
networks:
default:
Expand Down Expand Up @@ -89,7 +89,7 @@ services:
firefox:
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.firefox"
hostname: firefox.devstack.edx
image: edxops/firefox:${OPENEDX_RELEASE:-latest}
image: edxops/firefox:latest
shm_size: 2g
networks:
default:
Expand Down Expand Up @@ -290,13 +290,15 @@ services:
SOCIAL_AUTH_EDX_OIDC_URL_ROOT: http://edx.devstack.lms:18000/oauth2
ENABLE_DJANGO_TOOLBAR: 1
DJANGO_WATCHMAN_TIMEOUT: 30
image: openedx/credentials-dev:${OPENEDX_RELEASE:-latest}
image: edxops/credentials-dev:latest
networks:
default:
aliases:
- edx.devstack.credentials
ports:
- "18150:18150"
volumes:
- ${PWD}/py_configuration_files/credentials.py:/edx/app/credentials/credentials/credentials/settings/devstack.py

discovery:
command: bash -c 'source /edx/app/discovery/discovery_env && while true; do python /edx/app/discovery/discovery/manage.py runserver 0.0.0.0:18381; sleep 2; done'
Expand All @@ -319,7 +321,7 @@ services:
TEST_ELASTICSEARCH_URL: "edx.devstack.elasticsearch710"
ENABLE_DJANGO_TOOLBAR: 1
DJANGO_WATCHMAN_TIMEOUT: 30
image: edxops/discovery-dev:${OPENEDX_RELEASE:-latest}
image: edxops/discovery-dev:latest
networks:
default:
aliases:
Expand All @@ -346,7 +348,7 @@ services:
environment:
DJANGO_WATCHMAN_TIMEOUT: 30
ENABLE_DJANGO_TOOLBAR: 1
image: edxops/ecommerce-dev:${OPENEDX_RELEASE:-latest}
image: edxops/ecommerce-dev:latest
networks:
default:
aliases:
Expand All @@ -367,7 +369,7 @@ services:
- lms
- mysql80
- mysql57
image: openedx/edx-notes-api-dev:${OPENEDX_RELEASE:-latest}
image: edxops/edx-notes-api-dev:latest
networks:
default:
aliases:
Expand Down Expand Up @@ -395,7 +397,7 @@ services:
- mongo
- elasticsearch710
- opensearch12
image: edxops/forum:${OPENEDX_RELEASE:-latest}
image: edxops/forum:latest
stdin_open: true
tty: true
networks:
Expand Down Expand Up @@ -432,7 +434,7 @@ services:
CMS_CFG: "/edx/etc/studio.yml"
PATH: "/edx/app/edxapp/venvs/edxapp/bin:/edx/app/edxapp/nodeenv/bin:/edx/app/edxapp/edx-platform/node_modules/.bin:/edx/app/edxapp/edx-platform/bin:${PATH}"
SERVICE_VARIANT: lms
image: openedx/lms-dev:${OPENEDX_RELEASE:-latest}
image: edxops/lms-dev:latest
networks:
default:
aliases:
Expand Down Expand Up @@ -468,7 +470,7 @@ services:
LMS_HOST: http://localhost:18000
DJANGO_SETTINGS_MODULE: analytics_dashboard.settings.devstack
ANALYTICS_DASHBOARD_CFG: /edx/etc/insights.yml
image: edxops/insights-dev:${OPENEDX_RELEASE:-latest}
image: edxops/insights-dev:latest
working_dir: /edx/app/insights/insights
networks:
default:
Expand All @@ -481,7 +483,7 @@ services:
- ${PWD}/configuration_files/insights.yml:/edx/etc/insights.yml

analyticsapi:
image: edxops/analytics-api-dev:${OPENEDX_RELEASE:-latest}
image: edxops/analytics-api-dev:latest
container_name: edx.devstack.analyticsapi
hostname: analyticsapi
depends_on:
Expand Down Expand Up @@ -535,7 +537,7 @@ services:
CELERY_BROKER_PASSWORD: password
DJANGO_WATCHMAN_TIMEOUT: 30
ANALYTICS_DASHBOARD_CFG: /edx/etc/registrar.yml
image: edxops/registrar-dev:${OPENEDX_RELEASE:-latest}
image: edxops/registrar-dev:latest
working_dir: /edx/app/registrar
networks:
default:
Expand Down Expand Up @@ -573,7 +575,7 @@ services:
CELERY_BROKER_VHOST: 10
CELERY_BROKER_PASSWORD: password
DJANGO_WATCHMAN_TIMEOUT: 30
image: edxops/registrar-dev:${OPENEDX_RELEASE:-latest}
image: edxops/registrar-dev:latest
networks:
default:
aliases:
Expand Down Expand Up @@ -609,7 +611,7 @@ services:
LMS_CFG: "/edx/etc/lms.yml"
CMS_CFG: "/edx/etc/studio.yml"
SERVICE_VARIANT: cms
image: openedx/lms-dev:${OPENEDX_RELEASE:-latest}
image: edxops/lms-dev:latest
networks:
default:
aliases:
Expand All @@ -625,7 +627,7 @@ services:

xqueue:
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.xqueue"
image: edxops/xqueue-dev:${OPENEDX_RELEASE:-latest}
image: edxops/xqueue-dev:latest
working_dir: /edx/app/xqueue/xqueue
command: bash -c 'source /edx/app/xqueue/xqueue_env && while true; do python /edx/app/xqueue/xqueue/manage.py runserver 0.0.0.0:18040 ; sleep 2; done'
volumes:
Expand All @@ -645,7 +647,7 @@ services:

xqueue_consumer:
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.xqueue_consumer"
image: edxops/xqueue-dev:${OPENEDX_RELEASE:-latest}
image: edxops/xqueue-dev:latest
working_dir: /edx/app/xqueue/xqueue
command: bash -c 'source /edx/app/xqueue/xqueue_env && while true; do python /edx/app/xqueue/xqueue/manage.py run_consumer ; sleep 2; done'
volumes:
Expand Down
4 changes: 2 additions & 2 deletions docs/devstack_faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Unlike the ``node_modules`` directory, the ``virtualenv`` used to run Python
code in a Docker container only exists inside that container. Changes made to
a container's filesystem are not saved when the container exits, so if you
manually install or upgrade Python packages in a container (via
``pip install``, ``paver install_python_prereqs``, etc.), they will no
``pip install``, ``pip install -r requirements/edx/base.txt``, etc.), they will no
longer be present if you restart the container. (Devstack Docker containers
lose changes made to the filesystem when you reboot your computer, run
``make remove-containers``, restart or upgrade Docker itself, etc.) If you want to ensure
Expand Down Expand Up @@ -78,7 +78,7 @@ JavaScript packages for Node.js are installed into the ``node_modules``
directory of the local git repository checkout which is synced into the
corresponding Docker container. Hence these can be upgraded via any of the
usual methods for that service (``npm install``,
``paver install_node_prereqs``, etc.), and the changes will persist between
``npm clean-install``, etc.), and the changes will persist between
container restarts.

How do I rebuild static assets?
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Prerequisites
You will need to have the following installed:

- make
- Python 3.8
- Python 3.11
- Docker, including ``docker compose``

This project requires **Docker 19.03+ CE**. We recommend Docker Stable, but
Expand Down
4 changes: 2 additions & 2 deletions docs/service_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ Some common service combinations include:
.. _frontend-app-publisher: https://github.com/openedx/frontend-app-publisher
.. _frontend-app-gradebook: https://github.com/openedx/frontend-app-gradebook
.. _lms: https://github.com/openedx/edx-platform
.. _frontend-app-program-console: https://github.com/openedx/frontend-app-program-console
.. _registrar: https://github.com/openedx/registrar
.. _frontend-app-program-console: https://github.com/edx/frontend-app-program-console
.. _registrar: https://github.com/edx/registrar
.. _cms: https://github.com/openedx/edx-platform
.. _frontend-app-learner-dashboard: https://github.com/openedx/frontend-app-learner-dashboard
.. _frontend-app-learner-record: https://github.com/openedx/frontend-app-learner-record
Expand Down
15 changes: 2 additions & 13 deletions docs/testing_and_debugging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,8 @@ Running LMS and CMS Tests
----------------------------

After entering a shell for the appropriate service via ``make lms-shell`` or
``make cms-shell``, you can run any of the usual paver commands from the
`edx-platform testing documentation`_. Examples:

.. code:: sh
paver run_quality
paver test_a11y
paver test_bokchoy
paver test_js
paver test_lib
paver test_python
Tests can also be run individually. Example:
``make cms-shell``, you can run commands from the `edx-platform testing documentation`_
Tests can be run individually. Example:

.. code:: sh
Expand Down
8 changes: 4 additions & 4 deletions docs/troubleshoot_general_tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ To fix this situation, change the owner back to yourself outside of the containe
Running LMS commands within a container
---------------------------------------

Most of the ``paver`` commands require a settings flag. If omitted, the flag defaults to
``devstack``. If you run into issues running ``paver`` commands in a docker container, you should append
Most of the commands require a settings flag. If omitted, the flag defaults to
``devstack``. If you run into issues running commands in a docker container, you should append
the ``devstack_docker`` flag. For example:

.. code:: sh
$ paver update_assets --settings=devstack_docker
$ npm run build && ./manage.py lms collectstatic --no-input --settings=devstack_docker
Resource busy or locked
-----------------------
Expand Down Expand Up @@ -266,7 +266,7 @@ The fix is to get a new auth session. You can do any of the following:
Missing vendor file node_modules/backbone.paginator/lib/backbone.paginator.js
-----------------------------------------------------------------------------
This message sometimes appears when provisioning. The root cause of this is as yet unknown but the most effective workaround seems to be
to shell into the LMS (``make lms-shell`` in devstack) and run ``npm ci``, followed by ``paver update_assets``.
to shell into the LMS (``make lms-shell`` in devstack) and run ``npm ci``, followed by ``npm run build && ./manage.py lms collectstatic --no-input && ./manage.py cms collectstatic``.
See `the github issue`_ to follow the work being done on the resolution.

.. _the github issue: https://github.com/openedx/devstack/issues/1072
Expand Down
6 changes: 3 additions & 3 deletions provision-lms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ done
for app in "${apps[@]}"; do
docker compose exec -T $app bash -e -c 'apt-get update && apt-get -y install --no-install-recommends git'

docker compose exec -T $app bash -e -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && NO_PYTHON_UNINSTALL=1 paver install_prereqs'
docker compose exec -T $app bash -e -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && NO_PYTHON_UNINSTALL=1 pip install -e . -r requirements/edx/base.txt -r requirements/edx/assets.txt && npm clean-install'

#Installing prereqs crashes the process
docker compose restart $app
Expand Down Expand Up @@ -75,11 +75,11 @@ done


# Fix missing vendor file by clearing the cache
docker compose exec -T lms bash -e -c 'rm /edx/app/edxapp/edx-platform/.prereqs_cache/Node_prereqs.sha1'
# docker compose exec -T lms bash -e -c 'rm /edx/app/edxapp/edx-platform/.prereqs_cache/Node_prereqs.sha1'

# Create static assets for both LMS and CMS
for app in "${apps[@]}"; do
docker compose exec -T $app bash -e -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && paver update_assets --settings devstack_docker'
docker compose exec -T $app bash -e -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && npm run build && ./manage.py lms collectstatic --noinput --settings devstack_docker && ./manage.py cms collectstatic --noinput --settings devstack_docker'
done

# Allow LMS SSO for CMS
Expand Down
115 changes: 115 additions & 0 deletions py_configuration_files/credentials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
from edx_django_utils.plugins import add_plugins
from credentials.settings._debug_toolbar import *
from credentials.settings.base import *
from credentials.apps.plugins.constants import PROJECT_TYPE, SettingsType
from credentials.settings.utils import get_logger_config, str2bool

DEBUG = str2bool(os.environ.get("DEBUG", True))

ALLOWED_HOSTS = ["*"]

LOGGING = get_logger_config(debug=True, dev_env=True, local_loglevel="DEBUG")
del LOGGING["handlers"]["local"]

SECRET_KEY = os.environ.get("SECRET_KEY", "change-me")
LANGUAGE_CODE = os.environ.get("LANGUAGE_CODE", "en")

CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
"LOCATION": os.environ.get("CACHE_LOCATION", "edx.devstack.memcached:11211"),
"OPTIONS": {"no_delay": True, "ignore_exc": True, "use_pooling": True},
}
}

CREDENTIALS_SERVICE_USER = os.environ.get("CREDENTIALS_SERVICE_USER", "credentials_service_user")

DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": os.environ.get("DB_NAME", "credentials"),
"USER": os.environ.get("DB_USER", "credentials001"),
"PASSWORD": os.environ.get("DB_PASSWORD", "password"),
"HOST": os.environ.get("DB_HOST", "db"),
"PORT": os.environ.get("DB_PORT", 3306),
"ATOMIC_REQUESTS": False,
"CONN_MAX_AGE": 60,
}
}

INSTALLED_APPS += ["credentials.apps.edx_credentials_extensions"]

EMAIL_BACKEND = "django.core.mail.backends.filebased.EmailBackend"
EMAIL_FILE_PATH = "/tmp/credentials-emails"

DEFAULT_FILE_STORAGE = os.environ.get("DEFAULT_FILE_STORAGE", "django.core.files.storage.FileSystemStorage")
MEDIA_URL = os.environ.get("MEDIA_URL", "/media/")

STATICFILES_STORAGE = os.environ.get("STATICFILES_STORAGE", "django.contrib.staticfiles.storage.StaticFilesStorage")
STATIC_URL = os.environ.get("STATIC_URL", "/static/")

# OAuth2 variables specific to social-auth/SSO login use case.
SOCIAL_AUTH_EDX_OAUTH2_KEY = os.environ.get("SOCIAL_AUTH_EDX_OAUTH2_KEY", "credentials-sso-key")
SOCIAL_AUTH_EDX_OAUTH2_SECRET = os.environ.get("SOCIAL_AUTH_EDX_OAUTH2_SECRET", "credentials-sso-secret")
SOCIAL_AUTH_EDX_OAUTH2_ISSUER = os.environ.get("SOCIAL_AUTH_EDX_OAUTH2_ISSUER", "http://localhost:18000")
SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT = os.environ.get("SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT", "http://edx.devstack.lms:18000")
SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL = os.environ.get("SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL", "http://localhost:18000/logout")
SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT = os.environ.get(
"SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT",
"http://localhost:18000",
)

# OAuth2 variables specific to backend service API calls.
BACKEND_SERVICE_EDX_OAUTH2_KEY = os.environ.get("BACKEND_SERVICE_EDX_OAUTH2_KEY", "credentials-backend-service-key")
BACKEND_SERVICE_EDX_OAUTH2_SECRET = os.environ.get(
"BACKEND_SERVICE_EDX_OAUTH2_SECRET", "credentials-backend-service-secret"
)
BACKEND_SERVICE_EDX_OAUTH2_PROVIDER_URL = os.environ.get(
"BACKEND_SERVICE_EDX_OAUTH2_PROVIDER_URL",
"http://edx.devstack.lms:18000/oauth2",
)

CORS_ORIGIN_WHITELIST = [
"http://localhost:1990", # Learner Record MFE
"http://localhost:18450", # Subscriptions IDA
]
CSRF_TRUSTED_ORIGINS = [
"http://localhost:1990", # Learner Record MFE
]

SOCIAL_AUTH_REDIRECT_IS_HTTPS = str2bool(os.environ.get("SOCIAL_AUTH_REDIRECT_IS_HTTPS", False))

JWT_AUTH.update(
{
"JWT_SECRET_KEY": "lms-secret",
"JWT_ISSUER": "http://localhost:18000/oauth2",
"JWT_AUDIENCE": None,
"JWT_VERIFY_AUDIENCE": False,
"JWT_PUBLIC_SIGNING_JWK_SET": (
'{"keys": [{"kid": "devstack_key", "e": "AQAB", "kty": "RSA", "n": "smKFSYowG6nNUAdeqH1jQQnH1PmIHphzBmwJ5vRf1vu'
"48BUI5VcVtUWIPqzRK_LDSlZYh9D0YFL0ZTxIrlb6Tn3Xz7pYvpIAeYuQv3_H5p8tbz7Fb8r63c1828wXPITVTv8f7oxx5W3lFFgpFAyYMmROC"
"4Ee9qG5T38LFe8_oAuFCEntimWxN9F3P-FJQy43TL7wG54WodgiM0EgzkeLr5K6cDnyckWjTuZbWI-4ffcTgTZsL_Kq1owa_J2ngEfxMCObnzG"
'y5ZLcTUomo4rZLjghVpq6KZxfS6I1Vz79ZsMVUWEdXOYePCKKsrQG20ogQEkmTf9FT_SouC6jPcHLXw"}]}'
),
"JWT_ISSUERS": [
{
"AUDIENCE": "lms-key",
"ISSUER": "http://localhost:18000/oauth2",
"SECRET_KEY": "lms-secret",
}
],
}
)

SEND_EMAIL_ON_PROGRAM_COMPLETION = True

LEARNER_RECORD_MFE_RECORDS_PAGE_URL = "http://localhost:1990/"

add_plugins(__name__, PROJECT_TYPE, SettingsType.DEVSTACK)

#####################################################################
# Lastly, see if the developer has any local overrides.
try:
from .private import * # pylint: disable=import-error
except ImportError:
pass
Loading

0 comments on commit a50c1fc

Please sign in to comment.