Skip to content

create openedx envs common settings - #36941

Merged
kdmccormick merged 3 commits into
openedx:masterfrom
WGU-Open-edX:tpayne/create-openedx-envs-common-settings
Jul 21, 2025
Merged

create openedx envs common settings#36941
kdmccormick merged 3 commits into
openedx:masterfrom
WGU-Open-edX:tpayne/create-openedx-envs-common-settings

Conversation

@wgu-taylor-payne

@wgu-taylor-payne wgu-taylor-payne commented Jun 23, 2025

Copy link
Copy Markdown
Contributor

Description

Pull settings explicitly shared by the LMS and CMS into a common settings module at openedx/envs/common.py that lms/envs/common.py and cms/envs/common.py inherit from. For now, only settings explicitly shared settings (via import in cms/envs/common.py) were targeted to move up into the new shared module.

This is one of the initial steps in the effort to simplify Django settings in the edx-platform (see the related ADR: 0022-settings-simplification).

Documented settings in openedx/envs/common.py will be included on the settings reference page.

Supporting information

Resolves #36889.

Testing instructions

diff_settings.py

I've used the diff_settings.sh script as a foundation to create a diff_settings.py script that can be found here (documentation here). I've used this script to test the rendered settings for this branch against the rendered settings in the master branch.

Modification to cms/envs/production.py required

To get all runs of dump_settings to work (specifically running the command with DJANGO_SETTINGS_MODULE=cms.envs.production and CMS_CFG=cms/envs/mock.yml) I needed to make a small patch to cms/envs/production.py in both master and my branch:

-CSRF_TRUSTED_ORIGINS = _YAML_TOKENS.get("CSRF_TRUSTED_ORIGINS", [])
+CSRF_TRUSTED_ORIGINS = _YAML_TOKENS.get('CSRF_TRUSTED_ORIGINS_WITH_SCHEME', [])

Without this, the command would fail and output this error:

As of Django 4.0, the values in the CSRF_TRUSTED_ORIGINS setting must start with a scheme (usually http:// or https://) but found .localhost. See the release notes for details.

Results from running diff_settings.py

Running python diff_settings.py master tpayne/create-openedx-envs-common-settings in a tutor dev environment, I get the following results:

Starting Django settings dump comparison...
Comparing master -> tpayne/create-openedx-envs-common-settings
Output: main_settings_dump/ and feature_settings_dump/

Cleaning existing directory: main_settings_dump
Cleaning existing directory: feature_settings_dump
=== Processing branch: master ===
Processing configurations  [####################################]  100%
Completed processing branch: master

=== Processing branch: tpayne/create-openedx-envs-common-settings ===
Processing configurations  [####################################]  100%
Completed processing branch: tpayne/create-openedx-envs-common-settings

=== Running diff comparison ===
diff main_settings_dump/cms.envs.production__cms_envs_mock.json feature_settings_dump/cms.envs.production__cms_envs_mock.json
4360c4360
<             "module": "lms.envs.common",
---
>             "module": "openedx.envs.common",
4889c4889
<                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffff86001fd0>"
---
>                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffff7e80bf90>"
5847a5848
>     "USAGE_ID_PATTERN": "(?P<usage_id>(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))",
diff main_settings_dump/cms.envs.tutor.development__openedx_config_cms.json feature_settings_dump/cms.envs.tutor.development__openedx_config_cms.json
2084c2084
<             "module": "lms.envs.common",
---
>             "module": "openedx.envs.common",
2607c2607
<                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffffa6389fd0>"
---
>                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffff828d9fd0>"
3477a3478
>     "USAGE_ID_PATTERN": "(?P<usage_id>(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))",
diff main_settings_dump/cms.envs.tutor.production__openedx_config_cms.json feature_settings_dump/cms.envs.tutor.production__openedx_config_cms.json
2048c2048
<             "module": "lms.envs.common",
---
>             "module": "openedx.envs.common",
2571c2571
<                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffff7f8f9fd0>"
---
>                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffffaa8f9fd0>"
3440a3441
>     "USAGE_ID_PATTERN": "(?P<usage_id>(?:i4x://?[^/]+/[^/]+/[^/]+/[^@]+(?:@[^/]+)?)|(?:[^/]+))",
diff main_settings_dump/lms.envs.production__lms_envs_minimal.json feature_settings_dump/lms.envs.production__lms_envs_minimal.json
2365c2365
<             "module": "lms.envs.common",
---
>             "module": "openedx.envs.common",
2863c2863
<                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffffa753af90>"
---
>                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffff8c23dc90>"
diff main_settings_dump/lms.envs.production__lms_envs_mock.json feature_settings_dump/lms.envs.production__lms_envs_mock.json
5856c5856
<             "module": "lms.envs.common",
---
>             "module": "openedx.envs.common",
6365c6365
<                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffff91eadc50>"
---
>                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffffbcef3910>"
diff main_settings_dump/lms.envs.tutor.development__openedx_config_lms.json feature_settings_dump/lms.envs.tutor.development__openedx_config_lms.json
2689c2689
<             "module": "lms.envs.common",
---
>             "module": "openedx.envs.common",
3381c3381
<                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffffba7d9e90>"
---
>                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffff9e9cdc50>"
diff main_settings_dump/lms.envs.tutor.production__openedx_config_lms.json feature_settings_dump/lms.envs.tutor.production__openedx_config_lms.json
2414c2414
<             "module": "lms.envs.common",
---
>             "module": "openedx.envs.common",
2914c2914
<                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffffb61cafd0>"
---
>                 "stream": "<colorama.ansitowin32.StreamWrapper object at 0xffffa4a3ed50>"

Differences found between branches (shown above)

The "module" lines are describing where the lambda for the JWT_AUTH setting JWT_PAYLOAD_GET_USERNAME_HANDLER is being defined.

Also, I decided to bring USAGE_ID_PATTERN, which historically hasn't been imported in the CMS settings, into openedx/envs/common.py along with USAGE_KEY_PATTERN and ASSET_KEY_PATTERN, which have been imported into the CMS settings. These settings are similar and I thought it would make sense to declare them in the same place.

I also made a modification to HEARTBEAT_CELERY_ROUTING_KEY in cms/envs/common.py where it will contain 'cms' rather than 'lms' in the value, if SERVICE_VARIANT is not set (I don't know if this would be a common scenario or not). To test the difference with this setting I had to modify manage.py to not set SERVICE_VARIANT if unset. I also had to modify diff_settings.py to unset the SERVICE_VARIANT before running the dump_settings management command. With those changes in place these differences appeared:

diff main_settings_dump/cms.envs.production__cms_envs_mock.json feature_settings_dump/cms.envs.production__cms_envs_mock.json
4154c4154
<     "HEARTBEAT_CELERY_ROUTING_KEY": "edx.lms.core.high",
---
>     "HEARTBEAT_CELERY_ROUTING_KEY": "edx.cms.core.high",

diff main_settings_dump/cms.envs.tutor.development__openedx_config_cms.json feature_settings_dump/cms.envs.tutor.development__openedx_config_cms.json
1883c1883
<     "HEARTBEAT_CELERY_ROUTING_KEY": "edx.lms.core.high",
---
>     "HEARTBEAT_CELERY_ROUTING_KEY": "edx.cms.core.high",

diff main_settings_dump/cms.envs.tutor.production__openedx_config_cms.json feature_settings_dump/cms.envs.tutor.production__openedx_config_cms.json
1853c1853
<     "HEARTBEAT_CELERY_ROUTING_KEY": "edx.lms.core.high",
---
>     "HEARTBEAT_CELERY_ROUTING_KEY": "edx.cms.core.high",

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jun 23, 2025
@openedx-webhooks

openedx-webhooks commented Jun 23, 2025

Copy link
Copy Markdown

Thanks for the pull request, @wgu-taylor-payne!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jun 23, 2025
@wgu-taylor-payne
wgu-taylor-payne marked this pull request as draft June 23, 2025 15:50
@wgu-taylor-payne wgu-taylor-payne self-assigned this Jun 23, 2025
@wgu-taylor-payne
wgu-taylor-payne force-pushed the tpayne/create-openedx-envs-common-settings branch from 48c86a1 to 9c610f5 Compare June 23, 2025 19:52
Comment thread cms/envs/common.py
@wgu-taylor-payne
wgu-taylor-payne force-pushed the tpayne/create-openedx-envs-common-settings branch from 8b509eb to eaea6f7 Compare June 24, 2025 18:43
@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Jun 24, 2025
Comment thread openedx/envs/common.py
Comment thread openedx/envs/common.py
Comment thread openedx/envs/common.py Outdated
Comment thread openedx/envs/common.py
Comment thread openedx/envs/common.py
Comment thread openedx/envs/common.py Outdated
Comment thread docs/references/settings.rst Outdated
Comment thread cms/envs/common.py
@wgu-taylor-payne

Copy link
Copy Markdown
Contributor Author

I have left in 'DIRS': lms.envs.common.MAKO_TEMPLATE_DIRS_BASE, (see here) in cms/envs/common.py:664 because it is using a setting that is explicitly set for the LMS.

@wgu-taylor-payne
wgu-taylor-payne marked this pull request as ready for review June 24, 2025 20:40
@wgu-taylor-payne
wgu-taylor-payne requested a review from a team as a code owner June 24, 2025 20:40
@wgu-taylor-payne
wgu-taylor-payne marked this pull request as draft June 25, 2025 18:08
@wgu-taylor-payne
wgu-taylor-payne marked this pull request as ready for review June 26, 2025 01:37
@kdmccormick kdmccormick moved this from Needs Triage to Ready for Review in Contributions Jun 26, 2025
@kdmccormick

Copy link
Copy Markdown
Member

Excellent work. I'm busy for the next couple days with conference preparation, so I'll see if any other CCs are available to review. If not, I'll review as soon as I'm able to.

@kdmccormick kdmccormick added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Jun 26, 2025
@open-craft-grove

Copy link
Copy Markdown

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove

Copy link
Copy Markdown

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove

Copy link
Copy Markdown

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@wgu-taylor-payne
wgu-taylor-payne force-pushed the tpayne/create-openedx-envs-common-settings branch from eaea6f7 to 4ba8298 Compare July 2, 2025 18:19
@open-craft-grove

Copy link
Copy Markdown

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@kdmccormick kdmccormick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for you for the comprehensive testing report, new documentation, and explanatory comments. Just a few small changes, then this is good to go.

Comment thread cms/envs/common.py
Comment thread openedx/envs/common.py
Comment thread openedx/envs/common.py Outdated
@wgu-taylor-payne
wgu-taylor-payne force-pushed the tpayne/create-openedx-envs-common-settings branch from 4ba8298 to 7a4cbdf Compare July 7, 2025 16:20
@open-craft-grove

Copy link
Copy Markdown

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove

Copy link
Copy Markdown

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@feanil

feanil commented Jul 17, 2025

Copy link
Copy Markdown
Contributor

@wgu-taylor-payne looks like there are some conflicts that need to be resolved but then it looks like this can be merged.

The sandbox failures seem un-related so hopefully we can get one running after the conflicts have been resolved.

@wgu-taylor-payne
wgu-taylor-payne force-pushed the tpayne/create-openedx-envs-common-settings branch from 6d5892d to 6cef2de Compare July 17, 2025 19:47
@open-craft-grove

Copy link
Copy Markdown

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@wgu-taylor-payne
wgu-taylor-payne requested a review from feanil July 17, 2025 21:50
@feanil
feanil dismissed kdmccormick’s stale review July 18, 2025 17:12

The issues that Kyle brought up have been resolved.

@kdmccormick kdmccormick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I smoke-tested on the PR sandbox, ensuring I could create a library, use its content in a course, publish that course, and enroll in that course.

@kdmccormick
kdmccormick merged commit 36327ff into openedx:master Jul 21, 2025
49 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for Review to Done in Contributions Jul 21, 2025
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

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

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-sandbox open-craft-grove should create a sandbox environment from this PR mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Create initial openedx/envs/common.py

8 participants