Skip to content

Commit

Permalink
tc
Browse files Browse the repository at this point in the history
  • Loading branch information
clee2000 committed Jan 10, 2025
1 parent f4a275b commit 57d7f60
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 46 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ jobs:
- name: Run lintrunner on all files - Linux
run: |
set +e
<<<<<<< HEAD
if ! lintrunner -v --force-color --all-files --tee-json=lint.json --take ACTIONLINT,MYPY,RUSTFMT,COPYRIGHT,LINTRUNNER_VERSION,UFMT,NEWLINE; then
=======
if ! lintrunner -v --force-color --all-files --tee-json=lint.json --take ACTIONLINT,MYPY,RUSTFMT,COPYRIGHT,LINTRUNNER_VERSION,UFMT,TABS; then
>>>>>>> e276e9efb (tc)
echo ""
echo -e "\e[1m\e[36mYou can reproduce these results locally by using \`lintrunner -m main\`.\e[0m"
exit 1
Expand Down
3 changes: 3 additions & 0 deletions .lintrunner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ exclude_patterns = [
'.lintrunner.toml',
'**/fixtures/**',
'**/snapshots/**',
'.github/actions/setup-ssh/index.js',
'terraform-aws-github-runner/**',
'aws/ami/windows/**',
]
command = [
'python3',
Expand Down
44 changes: 22 additions & 22 deletions tools/linter/adapters/grep_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Generic linter that greps for a pattern and optionally suggests replacements.
"""

from __future__ import annotations

import argparse
import json
import logging
Expand All @@ -10,7 +12,7 @@
import sys
import time
from enum import Enum
from typing import Any, List, NamedTuple, Optional
from typing import Any, NamedTuple


IS_WINDOWS: bool = os.name == "nt"
Expand All @@ -28,24 +30,24 @@ class LintSeverity(str, Enum):


class LintMessage(NamedTuple):
path: Optional[str]
line: Optional[int]
char: Optional[int]
path: str | None
line: int | None
char: int | None
code: str
severity: LintSeverity
name: str
original: Optional[str]
replacement: Optional[str]
description: Optional[str]
original: str | None
replacement: str | None
description: str | None


def as_posix(name: str) -> str:
return name.replace("\\", "/") if IS_WINDOWS else name


def run_command(
args: List[str],
) -> "subprocess.CompletedProcess[bytes]":
args: list[str],
) -> subprocess.CompletedProcess[bytes]:
logging.debug("$ %s", " ".join(args))
start_time = time.monotonic()
try:
Expand All @@ -59,18 +61,13 @@ def run_command(


def lint_file(
matching_line: str,
filename: str,
allowlist_pattern: str,
replace_pattern: str,
linter_name: str,
error_name: str,
error_description: str,
) -> Optional[LintMessage]:
# matching_line looks like:
# tools/linter/clangtidy_linter.py:13:import foo.bar.baz
split = matching_line.split(":")
filename = split[0]

) -> LintMessage | None:
if allowlist_pattern:
try:
proc = run_command(["grep", "-nEHI", allowlist_pattern, filename])
Expand Down Expand Up @@ -108,7 +105,7 @@ def lint_file(
original = None
replacement = None
if replace_pattern:
with open(filename, "r") as f:
with open(filename) as f:
original = f.read()

try:
Expand Down Expand Up @@ -142,8 +139,8 @@ def lint_file(
)

return LintMessage(
path=split[0],
line=int(split[1]) if len(split) > 1 else None,
path=filename,
line=None,
char=None,
code=linter_name,
severity=LintSeverity.ERROR,
Expand Down Expand Up @@ -252,12 +249,15 @@ def main() -> None:
),
)
print(json.dumps(err_msg._asdict()), flush=True)
exit(0)
sys.exit(0)

lines = proc.stdout.decode().splitlines()
for line in lines:
# matching_line looks like:
# tools/linter/clangtidy_linter.py:13:import foo.bar.baz
files = {line.split(":")[0] for line in lines}
for file in files:
lint_message = lint_file(
line,
file,
args.allowlist_pattern,
args.replace_pattern,
args.linter_name,
Expand Down
4 changes: 2 additions & 2 deletions torchci/clickhouse_queries/test_time_per_class/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class_duration_per_job AS (
test_run.invoking_file,
test_run.classname,
base_name,
test_config,
job.run_id
test_config,
job.run_id
)
SELECT
REPLACE(file, '.', '/') AS file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class_duration_per_job AS (
test_run.invoking_file,
test_run.classname,
base_name,
test_config,
job.run_id
test_config,
job.run_id
)
SELECT
REPLACE(file, '.', '/') AS file,
Expand Down
4 changes: 2 additions & 2 deletions torchci/clickhouse_queries/test_time_per_file/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ file_duration_per_job AS (
GROUP BY
test_run.invoking_file,
base_name,
test_config,
job.run_id
test_config,
job.run_id
)
SELECT
REPLACE(file, '.', '/') AS file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ file_duration_per_job AS (
GROUP BY
test_run.invoking_file,
base_name,
test_config,
job.run_id
test_config,
job.run_id
)
SELECT
REPLACE(file, '.', '/') AS file,
Expand Down
32 changes: 16 additions & 16 deletions torchci/clickhouse_queries/workflow_duration_percentile/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
-- workflow names grouped by sha and then take percentile, but this matches the
-- Rockset query most closely
with tts as (
SELECT
DATE_DIFF(
'second',
workflow.created_at,
workflow.updated_at
) as duration_sec,
name,
FROM
default.workflow_run workflow final
WHERE
conclusion = 'success'
AND lower(workflow.name) in {workflowNames: Array(String)}
AND workflow.created_at >= {startTime: DateTime64(3)}
AND workflow.created_at < {stopTime: DateTime64(3)}
AND workflow.run_attempt = 1
SELECT
DATE_DIFF(
'second',
workflow.created_at,
workflow.updated_at
) as duration_sec,
name,
FROM
default.workflow_run workflow final
WHERE
conclusion = 'success'
AND lower(workflow.name) in {workflowNames: Array(String)}
AND workflow.created_at >= {startTime: DateTime64(3)}
AND workflow.created_at < {stopTime: DateTime64(3)}
AND workflow.run_attempt = 1
), tts_by_name as (
SELECT
quantileExact({percentile: Float32})(tts.duration_sec) as duration_sec
quantileExact({percentile: Float32})(tts.duration_sec) as duration_sec
FROM tts
group by name
)
Expand Down

0 comments on commit 57d7f60

Please sign in to comment.