Skip to content

Commit 433cd56

Browse files
authored
[autorevert] correctly fetch ghstack commits (#7291)
Ghstack commits are nested inside a single push event. Fortunately, the webhook has this information, we just need to unroll the list. Testing: [2025-10-03T19-16-15.103579-00-00.html](https://github.com/user-attachments/files/22686819/2025-10-03T19-16-15.103579-00-00.html) see this stack there: ``` Tue 10:43 am 5ed4672 [dynamo, 3.14] fix _detect_and_normalize_assert_statement for 3.14 (#164005) #164005 williamwen42 Tue 10:43 am 2600f8b [dynamo, 3.14] fix tracing typing.Union (#164004) #164004 williamwen42 Tue 10:42 am 9ce31e4 [3.14] make unbacked_sym[int/float]_counter integers (#163920) #163920 williamwen42 Tue 10:42 am 0657de9 [dynamo, 3.14] support LOAD_COMMON_CONSTANT (#163919) #163919 williamwen42 Tue 10:42 am 4ead8eb [dynamo, 3.14] fix BUILD_TUPLE with 0 args (#163818) #163818 williamwen42 Tue 10:42 am d4b785a [dynamo, 3.14] fix stack ref copy error (#163796) #163796 williamwen42 Tue 10:42 am 9278b18 [dynamo, 3.14] fix WITH_EXCEPT_START (#163292) #163292 williamwen42 Tue 10:42 am 008b0a9 [dynamo, 3.14] fix inactive ctx handling in resume functions (#163191) #163191 williamwen42 Tue 10:42 am 44677ad [dynamo, 3.14] support LOAD_CONST on slice, codegen LOAD_CONST slice instead of BINARY/STORE_SLICE (#163110) #163110 williamwen42 Tue 10:42 am 1c9987f [dynamo, 3.14] fix context managers (#163109) #163109 williamwen42 Tue 10:41 am 7cbc011 [dynamo, 3.14] support some bytecodes, fix CALL_FUNCTION_EX (#163009) #163009 williamwen42 Tue 10:41 am 09c7741 [dynamo, 3.14] Python dynamo changes to get basic programs working (#161839) #161839 williamwen42 Tue 10:41 am 763ab2a [dynamo, 3.14] compile actual code in C dynamo (#161555) #161555 williamwen42 Tue 10:41 am 4b8fe79 [dynamo] format cpython_defs.c (#161838) #161838 williamwen42 ```
1 parent 6475f26 commit 433cd56

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

aws/lambda/pytorch-auto-revert/pytorch_auto_revert/signal_extraction_datasource.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,26 @@ def fetch_commits_in_time_range(
3030
"""
3131
Fetch all commits pushed to main within the lookback window.
3232
Returns list of (sha, timestamp) tuples ordered newest → older.
33+
34+
Note: Uses ARRAY JOIN to extract all commits from ghstack pushes,
35+
which can contain multiple commits in a single push event.
36+
For commits with identical timestamps (from the same ghstack push),
37+
orders by array index descending to match HUD/torchci ordering.
3338
"""
3439
lookback_time = datetime.now() - timedelta(hours=lookback_hours)
3540

3641
query = """
37-
SELECT head_commit.id AS sha, max(head_commit.timestamp) AS ts
42+
SELECT
43+
commit.id AS sha,
44+
max(commit.timestamp) AS ts,
45+
arrayMax(groupArray(arrayFirstIndex(c -> c.'id' = commit.id, commits))) as array_index
3846
FROM default.push
47+
ARRAY JOIN commits as commit, commits as c
3948
WHERE head_commit.timestamp >= {lookback_time:DateTime}
4049
AND ref = 'refs/heads/main'
4150
AND dynamoKey like {repo:String}
4251
GROUP BY sha
43-
ORDER BY ts DESC
52+
ORDER BY ts DESC, array_index DESC
4453
"""
4554

4655
params = {

0 commit comments

Comments
 (0)