Skip to content

Commit 63ff3fa

Browse files
authored
Fix dynamo key queries to use trailing slashes for accurate repo matching (#7632)
### Problem Queries using dynamoKey LIKE 'pytorch/pytorch%' incorrectly match commits from pytorch/pytorch-integration-testing, causing (among else) autorevert to process "ghost commits" that don't exist in pytorch/pytorch. ### Solution Add trailing slash/delimiter to LIKE patterns: - push table: pytorch/pytorch//% (double slash matches {repo}//{uuid} format) - Other tables: pytorch/pytorch/% (single slash matches {repo}/{id} format) --- ### Testing autorevert: ``` python -m pytorch_auto_revert --dry-run autorevert-checker pull --hours 12 --hud-html ``` rest: manual query run.
1 parent 8a367f5 commit 63ff3fa

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

aws/lambda/ci-queue-pct/ci_queue_pct.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ def get_jobs_interval(
335335
default.workflow_job AS job
336336
INNER JOIN default.workflow_run AS workflow ON workflow.id = job.run_id
337337
WHERE
338-
job.dynamoKey LIKE 'pytorch/pytorch%'
338+
-- Use trailing slash to avoid matching pytorch/pytorch-integration-testing
339+
job.dynamoKey LIKE 'pytorch/pytorch/%'
339340
AND job.created_at >= {start_time:DateTime}
340341
AND job.created_at < {end_time:DateTime}
341342
AND length(job.labels) > 0

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ def fetch_commits_in_time_range(
6868

6969
params: Dict[str, Any] = {
7070
"lookback_time": lookback_time,
71-
"repo": f"{repo_full_name}%",
71+
# Use double slash to match push table's dynamoKey format: {repo}//{uuid}
72+
# This prevents matching repos with similar prefixes (e.g., pytorch/pytorch-integration-testing)
73+
"repo": f"{repo_full_name}//%",
7274
}
7375
if as_of:
7476
params["as_of"] = as_of

torchci/clickhouse_queries/merge_retry_rate/query.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ merged_prs AS (
1212
user.login AS author
1313
FROM default.pull_request
1414
WHERE
15-
dynamoKey LIKE 'pytorch/pytorch%'
15+
-- Use trailing slash to avoid matching pytorch/pytorch-integration-testing
16+
dynamoKey LIKE 'pytorch/pytorch/%'
1617
AND state = 'closed'
1718
AND arrayExists(x -> x.'name' = 'Merged', labels)
1819
AND closed_at != ''
@@ -29,7 +30,8 @@ all_merge_attempts AS (
2930
created_at
3031
FROM default.issue_comment
3132
WHERE
32-
dynamoKey LIKE 'pytorch/pytorch%'
33+
-- Use trailing slash to avoid matching pytorch/pytorch-integration-testing
34+
dynamoKey LIKE 'pytorch/pytorch/%'
3335
AND user.login = 'pytorchmergebot'
3436
AND body LIKE '%Merge started%'
3537
),

torchci/clickhouse_queries/pr_landing_time_avg/query.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ merge_started AS (
88
MIN(created_at) AS first_merge_attempt
99
FROM default.issue_comment
1010
WHERE
11-
dynamoKey LIKE 'pytorch/pytorch%'
11+
-- Use trailing slash to avoid matching pytorch/pytorch-integration-testing
12+
dynamoKey LIKE 'pytorch/pytorch/%'
1213
AND user.login = 'pytorchmergebot'
1314
AND body LIKE '%Merge started%'
1415
AND created_at >= {startTime: DateTime64(3)}
@@ -23,7 +24,8 @@ merged_prs AS (
2324
parseDateTimeBestEffort(closed_at) AS merge_time
2425
FROM default.pull_request
2526
WHERE
26-
dynamoKey LIKE 'pytorch/pytorch%'
27+
-- Use trailing slash to avoid matching pytorch/pytorch-integration-testing
28+
dynamoKey LIKE 'pytorch/pytorch/%'
2729
AND state = 'closed'
2830
AND arrayExists(x -> x.'name' = 'Merged', labels)
2931
AND closed_at != ''

0 commit comments

Comments
 (0)