-
Notifications
You must be signed in to change notification settings - Fork 4.2k
refactor: bring common settings into common module #37746
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
refactor: bring common settings into common module #37746
Conversation
|
Thanks for the pull request, @wgu-taylor-payne! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
dce6a63 to
34baf2d
Compare
cms/envs/common.py
Outdated
| XModuleMixin, | ||
| EditInfoMixin, | ||
| # DO NOT EXPAND THIS LIST!! See declaration in openedx/envs/common.py for more information | ||
| XBLOCK_MIXINS.insert(2, ResourceTemplates) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to append ResourceTemplates with the others added here in the CMS, but this caused an issue with method resolution in the tests (TypeError: Cannot create a consistent method resolution).
cms/envs/common.py
Outdated
| # prefix. | ||
| CONFIG_PREFIX = SERVICE_VARIANT + "." if SERVICE_VARIANT else "" | ||
|
|
||
| SERVICE_NAME = 'cms' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought at first to use SERVICE_VARIANT to stand in place of 'lms' and 'cms', but SERVICE_VARIANT as it has been defined historically is not guaranteed to have these values. So, I introduce this new value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you say more about this? What do you mean it's not gauranteed to have these values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is how it is declared in the common.py modules (along with the variables that first depend on it and my commentary):
# we get the value from the environment, or fall back on "lms" (or "cms")
# we don't validate the value from the environment
SERVICE_VARIANT = os.environ.get('SERVICE_VARIANT', "lms")
# this line anticipates that SERVICE_VARIANT could be falsy
CONFIG_PREFIX = SERVICE_VARIANT + "." if SERVICE_VARIANT else ""
# this line anticipates that SERVICE_VARIANT might not be lowercase
QUEUE_VARIANT = CONFIG_PREFIX.lower()And then I noticed in manage.py, that the lms service-variant argument assumes more choices that just lms:
lms.add_argument(
'--service-variant',
choices=['lms', 'lms-xml', 'lms-preview'],
default='lms',
help='Which service variant to run, when using the production environment')In practice today, it might just be 'lms' and 'cms' for this value, but I wasn't fully sure if that was the case or not., so I decided to err on the safe side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification. Yea, I can see how you would think it could be other values. But in practice, you can assume it's going to be either lms or cms, the value must be set for manage.py to run and the lms-xml and lms-preview variants are historic and not expected to work anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I'm cleaning up manage.py in #37790 to reduce confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying that. I'm trying to think through the implications, and am left wondering if SERVICE_VARIANT should just be declared 'lms' in lms/envs/common.py and 'cms' in cms/envs/common.py, not allowing the value to be set in the environment. The service variant would just be dependent on the DJANGO_SETTINGS_MODULE (the settings module inherits from a cms or lms settings module, and the appropriate value will be set in the respective common.py file).
I'm happy to make that change, but want to make sure I'm not missing anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
am left wondering if SERVICE_VARIANT should just be declared 'lms' in lms/envs/common.py and 'cms' in cms/envs/common.py, not allowing the value to be set in the environment.
Yes, I think this is exactly right. Back when lms-preview and lms-xml existed, this would have been a bad assumption, but as far as I can tell, we're clear now to make this change.
| # LMS events. These have to be copied over here because lms.common adds some derived entries as well, | ||
| # and the derivation fails if the keys are missing. If we ever remove the import of lms.common, we can remove these. | ||
| 'org.openedx.learning.certificate.created.v1': { | ||
| 'learning-certificate-lifecycle': | ||
| {'event_key_field': 'certificate.course.course_key', 'enabled': False}, | ||
| }, | ||
| 'org.openedx.learning.certificate.revoked.v1': { | ||
| 'learning-certificate-lifecycle': | ||
| {'event_key_field': 'certificate.course.course_key', 'enabled': False}, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed these now that we have removed the dependency on lms.envs.common. Introduced in #33458.
|
|
||
|
|
||
| import os | ||
| import tempfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implicitly available from openedx/envs/test.py, but explicitly declaring now.
| CONTEXT_PROCESSORS.remove('django.contrib.messages.context_processors.messages') | ||
| CONTEXT_PROCESSORS[5:5] = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one where to match the original order, we have to be a little creative. I was on the fence with this one.
| # CMS events. These have to be copied over here because cms.common adds some derived entries as well, | ||
| # and the derivation fails if the keys are missing. If we ever fully decouple the lms and cms settings, | ||
| # we can remove these. | ||
| 'org.openedx.content_authoring.xblock.published.v1': { | ||
| 'course-authoring-xblock-lifecycle': | ||
| {'event_key_field': 'xblock_info.usage_key', 'enabled': False}, | ||
| }, | ||
| 'org.openedx.content_authoring.xblock.deleted.v1': { | ||
| 'course-authoring-xblock-lifecycle': | ||
| {'event_key_field': 'xblock_info.usage_key', 'enabled': False}, | ||
| }, | ||
| 'org.openedx.content_authoring.xblock.duplicated.v1': { | ||
| 'course-authoring-xblock-lifecycle': | ||
| {'event_key_field': 'xblock_info.usage_key', 'enabled': False}, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed now that common modules are decoupled. (Introduced in #33458).
| DEBUG = False | ||
|
|
||
| USE_TZ = True | ||
| TIME_ZONE = 'UTC' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be valuable to gather all the Django specific settings into this section, so I brought all the Django settings that weren't in this section previously and added them here, like this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the settings, I can undo this if it is problematic.
TIME_ZONECSRF_COOKIE_AGECSRF_TRUSTED_ORIGINSCSRF_COOKIE_SECUREALLOWED_HOSTSX_FRAME_OPTIONSDATA_UPLOAD_MAX_MEMORY_SIZEDATA_UPLOAD_MAX_NUMBER_FIELDSSTATICFILES_FINDERSUSE_I18NLANGUAGE_CODECACHESDATABASESDEFAULT_AUTO_FIELD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think that's a helpful reorganization.
| } | ||
|
|
||
| USE_I18N = True | ||
| USE_L10N = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this variable was removed from Django 5.0 and it isn't referenced in the code, so I thought we'd be safe to remove it at this time.
| ('integrated_channels.cornerstone', None), | ||
| ('integrated_channels.xapi', None), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LMS has cornerstone and xapi in this order. For the CMS, this is a swap in the order of these two. Looking at the apps (cornerstone, xapi), I didn't see anything that would make this problematic.
|
@kdmccormick @feanil Could either of you look this over when you get a chance? |
|
Took a quick first pass, I'll take a deeper look later this week. |
feanil
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see any issues in my review. I think it's worth moving from SERVICE_NAME to SERVICE_VARIANT but I don't feel strongly enough about that to block merging this as is. It's a huge improvement and we can deal with the small complexity of having both of those if we need to.
| ('integrated_channels.integrated_channel', None), | ||
| ('integrated_channels.degreed', None), | ||
| ('integrated_channels.degreed2', None), | ||
| ('integrated_channels.sap_success_factors', None), | ||
| ('integrated_channels.cornerstone', None), | ||
| ('integrated_channels.xapi', None), | ||
| ('integrated_channels.blackboard', None), | ||
| ('integrated_channels.canvas', None), | ||
| ('integrated_channels.moodle', None), | ||
|
|
||
| # Channel Integrations Apps | ||
| ('channel_integrations.integrated_channel', None), | ||
| ('channel_integrations.degreed2', None), | ||
| ('channel_integrations.sap_success_factors', None), | ||
| ('channel_integrations.cornerstone', None), | ||
| ('channel_integrations.xapi', None), | ||
| ('channel_integrations.blackboard', None), | ||
| ('channel_integrations.canvas', None), | ||
| ('channel_integrations.moodle', None), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know this is not documented anywhere. I was unable to find out why we have both of these. The integrated-channels repo came later as a way to separate the concerns of the enterprise repo from the integrated reporting capabilities but I'm not sure what state it's in at the moment.
bb342c7 to
c06bbd2
Compare
|
@feanil @kdmccormick I updated Line 87 in 7b91d1d
Line 192 in 7b91d1d
edx-platform/lms/wsgi_apache_lms.py Line 15 in 7b91d1d
|
|
@wgu-taylor-payne the changes look good. I think as long as we fix all the |
b5c2099 to
c46a399
Compare
| ) | ||
|
|
||
| edx_args, django_args = parser.parse_known_args() | ||
| known_args, remaining_args = parser.parse_known_args() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pylint didn't like these variables being defined with the same name as the top level scope.
|
@feanil I decided to make the |
e3b62fb to
fb2477f
Compare
Closes #37280.
Description
Bring up more common settings from
lms/envs/common.pyandcms/envs/common.py. This is done by calculating common paths inopenedx/envs/common.py, usingDerivedto delay resolution of platform specific dependencies, or bringing up the common parts of mutable settings while adding the different parts in the platform specific common files.Here is a summary of the differences in the rendered settings between
masterand this branch:EVENT_BUS_PRODUCER_CONFIG: removed redundant values (based on comments: cms, lms).OPTIONAL_APPS: swap the order of 'integrated_channels.cornerstone' and 'integrated_channels.xapi' in CMS to match LMS. From my analysis of the the apps, this reordering shouldn't introduce any side-effects.INSTALLED_APPS: Changed based on the reorder inOPTIONAL_APPS.USE_L10N: this variable was removed from Django 5.0 and it isn't referenced in the code, so I thought we'd be safe to remove it at this time.LOGIN_ISSUE_SUPPORT_LINK: moved to Derived from the value ofSUPPORT_SITE_LINK. The default forSUPPORT_SITE_LINKis'', but is overridden via YAML incms/envs/mock.ymltohttps://support.localhost. SimilarlyID_VERIFICATION_SUPPORT_LINK,PASSWORD_RESET_SUPPORT_LINK, andACTIVATION_EMAIL_SUPPORT_LINKwere changed to be derived fromSUPPORT_SITE_LINK, so have similar implications.WEBPACK_LOADER['STATS_FILE']: Different for test settings only. Changed to be derived from theSTATIC_ROOTsetting, so now this value is updated based on theSTATIC_ROOTfor testing.QUEUE_VARIANTandCONFIG_PREFIX:SERVICE_VARIANThas been changed to always becmsorlms. This means it will never be falsy and will always be lowercase. This means we can useSERVICE_VARIANTdirectly in the different queue names, and no longer need to useCONFIG_PREFIXandQUEUE_VARIANT.Supporting information
This task is part of the effort to simplify settings as outlined in ADR 0022 - Django settings simplification.
Testing instructions
Run the
dump_settingsmanagement command on the different terminal settings modules, given differentymlconfig files and compare the diff on the rendered settings betweenmasterandtpayne/consolidate-with-derived. To simplify this, I used the script diff_settings.py and alsotable_diff.pyto simplify the diff output. I've added the output of these scripts in this gist.Deadline
None