Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/openpi/shared/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _set_file_permission(file_path: pathlib.Path) -> None:
def _get_mtime(year: int, month: int, day: int) -> float:
"""Get the mtime of a given date at midnight UTC."""
date = datetime.datetime(year, month, day, tzinfo=datetime.UTC)
return time.mktime(date.timetuple())
return date.timestamp()


# Map of relative paths, defined as regular expressions, to expiration timestamps (mtime format).
Expand Down
21 changes: 21 additions & 0 deletions src/openpi/shared/download_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import datetime
import os
import pathlib
import time

import pytest

Expand All @@ -24,6 +27,24 @@ def test_download_local(tmp_path: pathlib.Path):
download.maybe_download("bogus")


def test_get_mtime_is_utc():
if not hasattr(time, "tzset"):
pytest.skip("time.tzset is not available")

original_tz = os.environ.get("TZ")
try:
os.environ["TZ"] = "America/Los_Angeles"
time.tzset()
expected = datetime.datetime(2025, 2, 17, tzinfo=datetime.UTC).timestamp()
assert download._get_mtime(2025, 2, 17) == expected
finally:
if original_tz is None:
os.environ.pop("TZ", None)
else:
os.environ["TZ"] = original_tz
time.tzset()


def test_download_gs_dir():
remote_path = "gs://openpi-assets/testdata/random"

Expand Down