-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat: removing get_storage_class from COURSE_METADATA_EXPORT_STORAGE #36761
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
base: master
Are you sure you want to change the base?
feat: removing get_storage_class from COURSE_METADATA_EXPORT_STORAGE #36761
Conversation
Thanks for the pull request, @dwong2708! 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. 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
b8da29c
to
e9daa7c
Compare
e9daa7c
to
bb9ce7e
Compare
@@ -17,4 +17,4 @@ def __init__(self): | |||
bucket = settings.COURSE_METADATA_EXPORT_BUCKET | |||
super().__init__(bucket_name=bucket, custom_domain=None, querystring_auth=True) | |||
|
|||
course_metadata_export_storage = get_storage_class(settings.COURSE_METADATA_EXPORT_STORAGE)() | |||
course_metadata_export_storage = resolve_storage_backend("COURSE_METADATA_EXPORT_STORAGE") |
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.
nit: Consider renaming 'COURSE_METADATA_EXPORT_STORAGE' to lowercase (e.g., 'course_metadata_export_storage') for consistency with other keys in STORAGES, which are conventionally lowercase.
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.
Got it, thanks for your feedback. I'm concerned about this because the current settings key, "COURSE_METADATA_EXPORT_STORAGE", is in uppercase. For that reason, I have a question: how will the transition to migrate these changes work? Will it be merged before the settings are migrated to STORAGES, or can we assume that the STORAGES settings will already exist?
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.
Yes, your concern is valid, so let’s keep the key as-is for now. There isn’t a finalized discussion yet on how the migration to the new STORAGES setting will be handled. At this stage, our focus is on updating deprecated methods for Django 4.2 and ensuring the code remains compatible with future versions like Django 5.x.
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.
Just to clarify, I was referring to the future STORAGES key, e.g.,
STORAGES = {"course_metadata_export_storage": "something"}
—not the existing settings.COURSE_METADATA_EXPORT_STORAGE
. I mixed up the two earlier :) but for now no change require since we have no STORAGES plan yet.
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.
Got it, thank you. Here are some ideas on how we could handle the migration:
Case 1:
Stage 1 (no breaking change): Migrate get_storage_class (this PR is an example) and merge it.
Stage 2 (breaking change): Migrate storage settings to the new convention, e.g., STORAGES = {}. and decide if we use lower or upper case in the key.
Stage 3: Ready to migrate to Django 5.
Case 2:
Stage 1 (no breaking change): Migrate get_storage_class (this PR is an example) and merge it.
Stage 2: Ready to migrate to Django 5 because the STORAGES settings is not required
Stage 3 (breaking change): Gradually migrate storage settings to the new convention, e.g., STORAGES = {}, in preparation for upgrading to Django 6.
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.
Stage 1 would be merging all these PRs as the initial step.
Stage 2 involves reaching out to the owning teams to get their input on the proposed migration plan. because it will effect the community also.
Looping in @feanil for visibility.
common/djangoapps/util/storage.py
Outdated
# In Django 5.x, it uses STORAGES['default'] | ||
return default_storage | ||
|
||
if django.VERSION >= (5, 0) and storage_key in storages_config: |
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.
Since the STORAGES setting is available starting in Django 4.2, we can simplify the logic by removing the django.VERSION >= (5, 0) check. Instead, we can directly check if storage_key exists in storages_config, allowing this logic to work consistently in both Django 4.2 and 5.x as long as STORAGES is defined.
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. I have the same question regarding the removal of the django.VERSION >= (5, 0) check. How will the transition for these changes work? If I remove this check while we're still on Django 4 and the STORAGES settings have already been migrated, I believe it won't work because django.core.files.storage.storages
doesn't exist for Django 4
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.
@dwong2708 I'm a bit confused about this. My assumption is that django.core.files.storage.storages
should work with Django 4.2. Could you please take a look at this code reference?
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.
@awais786 You’re right! I looked into Django 4.0 and realized that Django 4.2 supports django.core.files.storage.storages
. I’ve updated my logic—could you please take another look?
@dwong2708 Thanks for this PR. Awesome work. |
a54e56d
to
2c40211
Compare
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 am approving it from my side. But we need final review from @feanil.
2c40211
to
ed97319
Compare
Description
Fixes: #36736
The file cms/djangoapps/export_course_metadata/storage.py was updated to use storages, as get_storage_class will be removed in Django 5.1.
These changes include:
Testing instructions
Run
pytest cms cms/djangoapps/export_course_metadata/test_signals.py
Functionality verified locally
Exporting course:

Importing course:
