mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Revert "Wrote stubbed out test cases for isGreen function to verify if a commit SHA is promote-able (#78932)"
This reverts commit fc3a5d8117.
Reverted https://github.com/pytorch/pytorch/pull/78932 on behalf of https://github.com/janeyx99 due to Broke ROCm tests when introducing rockset requirement https://hud.pytorch.org/minihud#fc3a5d81171ba465e3d62ffbda9713b53039b5f0
This commit is contained in:
parent
0df77f320f
commit
d06bdaac50
42
.github/scripts/print_latest_commits.py
vendored
42
.github/scripts/print_latest_commits.py
vendored
|
|
@ -1,15 +1,15 @@
|
|||
from typing import Any, Dict, List, NamedTuple
|
||||
from typing import Any, Dict
|
||||
from datetime import datetime, timedelta
|
||||
from gitutils import _check_output
|
||||
|
||||
import rockset # type: ignore[import]
|
||||
from rockset import Client, ParamDict # type: ignore[import]
|
||||
import os
|
||||
|
||||
class WorkflowCheck(NamedTuple):
|
||||
workflowName: str
|
||||
name: str
|
||||
jobName: str
|
||||
conclusion: str
|
||||
rs = Client(api_key=os.getenv("ROCKSET_API_KEY", None))
|
||||
qlambda = rs.QueryLambda.retrieve(
|
||||
'commit_jobs_batch_query',
|
||||
version='15aba20837ae9d75',
|
||||
workspace='commons')
|
||||
|
||||
def parse_args() -> Any:
|
||||
from argparse import ArgumentParser
|
||||
|
|
@ -17,7 +17,7 @@ def parse_args() -> Any:
|
|||
parser.add_argument("--minutes", type=int, default=30, help="duration in minutes of last commits")
|
||||
return parser.parse_args()
|
||||
|
||||
def print_latest_commits(qlambda: Any, minutes: int = 30) -> None:
|
||||
def print_latest_commits(minutes: int = 30) -> None:
|
||||
current_time = datetime.now()
|
||||
time_since = current_time - timedelta(minutes=minutes)
|
||||
timestamp_since = datetime.timestamp(time_since)
|
||||
|
|
@ -31,7 +31,7 @@ def print_latest_commits(qlambda: Any, minutes: int = 30) -> None:
|
|||
encoding="ascii",
|
||||
).splitlines()
|
||||
|
||||
params = rockset.ParamDict()
|
||||
params = ParamDict()
|
||||
params['shas'] = ",".join(commits)
|
||||
results = qlambda.execute(parameters=params)
|
||||
|
||||
|
|
@ -44,31 +44,9 @@ def print_commit_status(commit: str, results: Dict[str, Any]) -> None:
|
|||
if check['sha'] == commit:
|
||||
print(f"\t{check['conclusion']:>10}: {check['name']}")
|
||||
|
||||
def get_commit_results(commit: str, results: Dict[str, Any]) -> List[Dict[str, Any]]:
|
||||
workflow_checks = []
|
||||
for check in results['results']:
|
||||
if check['sha'] == commit:
|
||||
workflow_checks.append(WorkflowCheck(
|
||||
workflowName=check['workflowName'],
|
||||
name=check['name'],
|
||||
jobName=check['jobName'],
|
||||
conclusion=check['conclusion'],
|
||||
)._asdict())
|
||||
return workflow_checks
|
||||
|
||||
def isGreen(results: List[Dict[str, Any]]) -> bool:
|
||||
return True
|
||||
|
||||
def main() -> None:
|
||||
args = parse_args()
|
||||
rs = rockset.Client(
|
||||
api_server="api.rs2.usw2.rockset.com", api_key=os.environ["ROCKSET_API_KEY"]
|
||||
)
|
||||
qlambda = rs.QueryLambda.retrieve(
|
||||
'commit_jobs_batch_query',
|
||||
version='15aba20837ae9d75',
|
||||
workspace='commons')
|
||||
print_latest_commits(qlambda, args.minutes)
|
||||
print_latest_commits(args.minutes)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
48
.github/scripts/test_print_latest_commits.py
vendored
48
.github/scripts/test_print_latest_commits.py
vendored
|
|
@ -1,48 +0,0 @@
|
|||
from unittest import TestCase, main, mock
|
||||
from typing import Any, List, Dict
|
||||
from print_latest_commits import isGreen, WorkflowCheck
|
||||
|
||||
class TestChecks:
|
||||
def make_test_checks(self) -> List[Dict[str, Any]]:
|
||||
workflow_checks = []
|
||||
for i in range(20):
|
||||
workflow_checks.append(WorkflowCheck(
|
||||
workflowName="test",
|
||||
name="test/job",
|
||||
jobName="job",
|
||||
conclusion="success",
|
||||
)._asdict())
|
||||
return workflow_checks
|
||||
|
||||
class TestPrintCommits(TestCase):
|
||||
@mock.patch('print_latest_commits.get_commit_results', return_value=TestChecks().make_test_checks())
|
||||
def test_match_rules(self, mock_get_commit_results: Any) -> None:
|
||||
"Test that passes all conditions for promote-able"
|
||||
workflow_checks = mock_get_commit_results()
|
||||
self.assertTrue(isGreen(workflow_checks))
|
||||
|
||||
@mock.patch('print_latest_commits.get_commit_results', return_value=TestChecks().make_test_checks())
|
||||
def test_jobs_failing(self, mock_get_commit_results: Any) -> None:
|
||||
"Test with one job failing, no pending jobs, at least 20 jobs run"
|
||||
workflow_checks = mock_get_commit_results()
|
||||
workflow_checks[0]['conclusion'] = 'failed'
|
||||
# self.assertFalse(isGreen(workflow_checks))
|
||||
|
||||
@mock.patch('print_latest_commits.get_commit_results', return_value=TestChecks().make_test_checks())
|
||||
def test_pending_jobs(self, mock_get_commit_results: Any) -> None:
|
||||
"Test with pending jobs, all jobs passing, at least 20 jobs run"
|
||||
workflow_checks = mock_get_commit_results()
|
||||
workflow_checks[0]['conclusion'] = 'pending'
|
||||
# self.assertFalse(isGreen(workflow_checks))
|
||||
|
||||
@mock.patch('print_latest_commits.get_commit_results', return_value=TestChecks().make_test_checks())
|
||||
def test_jobs_not_run(self, mock_get_commit_results: Any) -> None:
|
||||
"Test with all jobs passing, no jobs pending, less than 20 jobs run"
|
||||
workflow_checks = mock_get_commit_results()
|
||||
workflow_checks.pop(0)
|
||||
# self.assertFalse(isGreen(workflow_checks))
|
||||
|
||||
# this may need to change, depending on the necessary specs for isGreen
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
|
|
@ -220,8 +220,6 @@ jobs:
|
|||
python3 -mpip install mypy==0.960 --user
|
||||
make setup_lint
|
||||
- name: Test tools
|
||||
env:
|
||||
ROCKSET_API_KEY: ${{ secrets.ROCKSET_API_KEY }}
|
||||
run: |
|
||||
python3 -m unittest discover -vs tools/test -p 'test_*.py'
|
||||
python3 -m unittest discover -vs .github/scripts -p 'test_*.py'
|
||||
|
|
|
|||
|
|
@ -10,4 +10,3 @@ setuptools
|
|||
six
|
||||
types-dataclasses
|
||||
typing_extensions
|
||||
rockset
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user