BOM-2245 : Unpin python-dateutil#30255
Conversation
f792247 to
2b961fb
Compare
7c95ff6 to
23db538
Compare
|
Hi @regisb , can you please have a look at this PR. It's related to python-dateutil version update. |
f82855f to
29e9413
Compare
| return datetime( | ||
| year=xblock_field.year, month=xblock_field.month, day=xblock_field.day, | ||
| hour=xblock_field.hour, minute=xblock_field.minute, second=xblock_field.second, | ||
| tzinfo=tzlocal() |
There was a problem hiding this comment.
I don't see anywhere else we use tzlocal in edx-platform, and the Django docs indicate that UTC is generally used to store in MySQL when USE_TZ = True.
There was a problem hiding this comment.
If we check the course_outline on sandbox where USE_TZ = True, we will find that tzlocal is being used multiple times
Code snippet to check the course outline:
from django.contrib.auth.models import User
from django.test import RequestFactory
from openedx.features.course_experience.utils import get_course_outline_block_tree
user = User.objects.get(username='admin')
request = RequestFactory().get(u'/')
request.user = user
course_key_string = 'course-v1:edX+DemoX+Demo_Course'
course_outline = get_course_outline_block_tree(request, course_key_string, request.user)
print(course_outline)There was a problem hiding this comment.
Ah, I forgot that this is coming from a cache instead of the database. Yes, in that sense it makes sense to just replicate the time zone they had before being cached.
| import pytest | ||
| import pytz | ||
| from boto.exception import BotoServerError | ||
| from dateutil.zoneinfo import gettz |
There was a problem hiding this comment.
Why not the original dateutil.tz? According to the python-dateutil docs, the method you have here is deprecated.
There was a problem hiding this comment.
Updated.
Two tests were failing when I first created this PR that's why I tried to use this method.
But now tests are passing even after removing this method. So now using the original dateutil.tz
as you suggested.
| import dateutil | ||
| import pytz | ||
| import edx_api_doc_tools as apidocs | ||
| from dateutil.zoneinfo import gettz |
requirements/constraints.txt
Outdated
| networkx<2.6 | ||
| # numpy>=1.17 is required for matplotlib>=3.5.1 | ||
| # and numpy>=1.17.0 caused failures in importing numpy in code-jail environment. | ||
| matplotlib==3.4.0 |
There was a problem hiding this comment.
This looks like it would upgrade matplotlib from 3.3.4 to 3.4.0, but I don't see a corresponding change in py38.txt. And I'd rather not risk upgrading that in codejail at the same time as we attempt the python-dateutil upgrade, so can we shift this back to matplotlib<3.4.0?
There was a problem hiding this comment.
Done. Will be upgraded in separate PR if required.
a5ef5b3 to
f302d2a
Compare
jmbowman
left a comment
There was a problem hiding this comment.
Thanks for helping unravel this! I still think we'll want to stop using pickle on datetimes altogether in the future to avoid further upgrade hassles, but hopefully this will get us through this upgrade at least.
Are there still any cache purges that we'll need to coordinate with SRE during deployment, or do you think this should cover it?
| return datetime( | ||
| year=xblock_field.year, month=xblock_field.month, day=xblock_field.day, | ||
| hour=xblock_field.hour, minute=xblock_field.minute, second=xblock_field.second, | ||
| tzinfo=tzlocal() |
There was a problem hiding this comment.
Ah, I forgot that this is coming from a cache instead of the database. Yes, in that sense it makes sense to just replicate the time zone they had before being cached.
I think that we will not need any cache purges. But if somethings goes wrong, we can rely on that as a backup plan. |
cd772d7 to
95d756e
Compare
95d756e to
3492bed
Compare
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
|
EdX Release Notice: This PR has been rolled back from the production environment. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
1 similar comment
|
EdX Release Notice: This PR has been deployed to the production environment. |

Last time we tried to bump the version of

python-dateutil(PR#27196) we got this errorLine 585 in method
get_course_assignmentswas causing the error at that timehttps://github.com/openedx/edx-platform/blob/072b6b8875e2a6323b6666998a3bf5c5e6444039/lms/djangoapps/courseware/courses.py#L585
The reason of the error was that
startdatetime object which we were getting fromBlockStructureBlockDatawasn't updated as per the latest version ofpython-dateutilhttps://github.com/openedx/edx-platform/blob/072b6b8875e2a6323b6666998a3bf5c5e6444039/lms/djangoapps/courseware/courses.py#L584
https://github.com/openedx/edx-platform/blob/072b6b8875e2a6323b6666998a3bf5c5e6444039/openedx/core/djangoapps/content/block_structure/block_structure.py#L396
The


tzlocalobject assigned totzinfovariable ofstartdate was like thisBut according to the latest version of
python-dateutilit should have been like thisSo now as we know that the problem is with the outdated datetime objects. We should update them and this is what we are doing in this PR. We have added a patch where we are creating updated datetime objects using the outdated ones and using them for calculations and comparisons.
How did I test?
I used follwoing 3 branches to test this solution.
current branch)python-dateutilpython-dateutilnopatch, we're using outdated datetime objectspython-dateutilpatchI also created a code snippet to replicate the
behaviorofget_course_assingmentsmethod, so that I can trigger that behavior fromlms-shellSo I executed the
abovecode snippet on the mentioned branches and I got the following outputs:For
masterpython-dateutilWhen I switched from
mastertobom-2245-attempt-3(current branch)python-dateutilWhen I switched from
bom-2245-attempt-3totest-bom-2245-attempt-3