Skip to content

Commit 6b27ab6

Browse files
authored
Keep nightly 20231010 for ExecuTorch alpha 0.1 for now (#4900)
pytorch/executorch#1663. The indexing script was migrated recently from builder to test-infra in #4879. But there was a mistake in which my [recent change](pytorch/builder@6f3cb2b) to keep nightly 20231010 for ExecuTorch wasn't copied over. So, this PR copies the missing logic pytorch/builder#1642. It also fixes some linter issues flagged by test-infra lintrunner.
1 parent 9178476 commit 6b27ab6

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

s3_management/manage.py

100644100755
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import functools
88
import time
99

10+
from contextlib import suppress
1011
from os import path, makedirs
1112
from datetime import datetime
1213
from collections import defaultdict
@@ -112,6 +113,12 @@
112113
# How many packages should we keep of a specific package?
113114
KEEP_THRESHOLD = 60
114115

116+
# TODO (huydhn): Clean this up once ExecuTorch has a new stable release that
117+
# match PyTorch stable release cadence. This nightly version is currently
118+
# referred to publicly in ExecuTorch alpha 0.1 release. So we want to keep
119+
# nightly binaries around for now
120+
KEEP_NIGHTLY_PACKAGES_FOR_EXECUTORCH = {datetime(2023, 10, 10, 0, 0)}
121+
115122
S3IndexType = TypeVar('S3IndexType', bound='S3Index')
116123

117124

@@ -139,11 +146,9 @@ def __lt__(self, other):
139146
def extract_package_build_time(full_package_name: str) -> datetime:
140147
result = search(PACKAGE_DATE_REGEX, full_package_name)
141148
if result is not None:
142-
try:
143-
return datetime.strptime(result.group(2), "%Y%m%d")
144-
except ValueError:
149+
with suppress(ValueError):
145150
# Ignore any value errors since they probably shouldn't be hidden anyways
146-
pass
151+
return datetime.strptime(result.group(2), "%Y%m%d")
147152
return datetime.now()
148153

149154

@@ -160,7 +165,6 @@ def safe_parse_version(ver_str: str) -> Version:
160165
return Version("0.0.0")
161166

162167

163-
164168
class S3Index:
165169
def __init__(self: S3IndexType, objects: List[S3Object], prefix: str) -> None:
166170
self.objects = objects
@@ -201,7 +205,10 @@ def nightly_packages_to_show(self: S3IndexType) -> List[S3Object]:
201205
if package_name not in PACKAGE_ALLOW_LIST:
202206
to_hide.add(obj)
203207
continue
204-
if packages[package_name] >= KEEP_THRESHOLD or between_bad_dates(package_build_time):
208+
if package_build_time not in KEEP_NIGHTLY_PACKAGES_FOR_EXECUTORCH and (
209+
packages[package_name] >= KEEP_THRESHOLD
210+
or between_bad_dates(package_build_time)
211+
):
205212
to_hide.add(obj)
206213
else:
207214
packages[package_name] += 1
@@ -447,7 +454,7 @@ def sanitize_key(key: str) -> str:
447454
checksum=None,
448455
size=None) for key in obj_names], prefix)
449456
if prefix == "whl/nightly":
450-
rc.objects = rc.nightly_packages_to_show()
457+
rc.objects = rc.nightly_packages_to_show()
451458
if with_metadata:
452459
rc.fetch_metadata()
453460
return rc

0 commit comments

Comments
 (0)