Skip to content

Fix naive offset-naive/aware error in asset compilation [CRI-191] - #23922

Merged
nedbat merged 1 commit into
openedx:masterfrom
regisb:regisb/fix-offset-naive-static-assets
May 6, 2020
Merged

Fix naive offset-naive/aware error in asset compilation [CRI-191]#23922
nedbat merged 1 commit into
openedx:masterfrom
regisb:regisb/fix-offset-naive-static-assets

Conversation

@regisb

@regisb regisb commented May 6, 2020

Copy link
Copy Markdown
Contributor

The XBlockPackageStorage used to return offset-naive datetime objects
which were compared to offset-aware objects when we ran static asset
collection:

./manage.py lms collectstatic

Close CRI-191 (which is a Juniper issue, cc @nedbat)

The XBlockPackageStorage used to return offset-naive datetime objects
which were compared to offset-aware objects when we ran static asset
collection:

    ./manage.py lms collectstatic

Close CRI-191
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @regisb! I've created OSPR-4476 to keep track of it in JIRA. JIRA is a place for product owners to prioritize feature reviews by the engineering development teams.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • edx-code email threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will still be done via the GitHub pull request interface. As a reminder, our process documentation is here.

@openedx-webhooks openedx-webhooks added needs triage open-source-contribution PR author is not from Axim or 2U labels May 6, 2020
@edx-status-bot

Copy link
Copy Markdown

Your PR has finished running tests. There were no failures.

@nedbat nedbat changed the title Fix naive offset-naive/aware error in asset compilation Fix naive offset-naive/aware error in asset compilation [CRI-191] May 6, 2020
@nedbat

nedbat commented May 6, 2020

Copy link
Copy Markdown
Contributor

@jmbowman @ormsbee Does this look right to you?

@feanil feanil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the timestamp this is going to be connected to always going to be UTC? Should they both be using the timezone.get_current_timezone() function from django.utils.timezone instead? If not, why not?

@regisb

regisb commented May 6, 2020

Copy link
Copy Markdown
Contributor Author

@feanil It does not matter which timezone is being used to obtain an offset-aware datetime. Using a different timezone would result in a different tz attribute for the datetime, but the absolute datetime would remain identical. This can be verified with the following piece of code:

In [13]: datetime.fromtimestamp(1, timezone.utc)
Out[13]: datetime.datetime(1970, 1, 1, 0, 0, 1, tzinfo=<UTC>)

In [14]: datetime.fromtimestamp(1, timezone.get_fixed_timezone(2))
Out[14]: datetime.datetime(1970, 1, 1, 0, 2, 1, tzinfo=datetime.timezone(datetime.timedelta(0, 120), '+0002'))

However, it does matter that we have an offset-aware datetime in order to be able to perform datetime comparisons while collecting assets. The relevant piece of code is in django/contrib/staticfiles/management/commands/collectstatic.py (line 280):

file_is_unmodified = (
                        target_last_modified.replace(microsecond=0) >=
                        source_last_modified.replace(microsecond=0)
                    )

@nedbat
nedbat merged commit 5caf9b0 into openedx:master May 6, 2020
@openedx-webhooks

Copy link
Copy Markdown

@regisb 🎉 Your pull request was merged!

Please take a moment to answer a two question survey so we can improve your experience in the future.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

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

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@regisb
regisb deleted the regisb/fix-offset-naive-static-assets branch May 8, 2020 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged open-source-contribution PR author is not from Axim or 2U

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants