mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
[GHF] More verbose failures messages (#71941)
Summary: Modify _check_output to capture `CalledProcessError` and add stdout/stderr to the failure message Also record github actions run id in the failure message (calculated based on `${{ github.run_id}}`) Pull Request resolved: https://github.com/pytorch/pytorch/pull/71941 Reviewed By: seemethere Differential Revision: D33829633 Pulled By: malfet fbshipit-source-id: 060b2856ca6c71574075effa72b982f9e1d64e6e (cherry picked from commit a9ad7df9b540f9ab14524a644cab5e06225debe4)
This commit is contained in:
committed by
PyTorch MergeBot
parent
c85965600c
commit
3b9f2e2cca
14
.github/scripts/gitutils.py
vendored
14
.github/scripts/gitutils.py
vendored
@ -30,8 +30,18 @@ def fuzzy_list_to_dict(items: List[Tuple[str, str]]) -> Dict[str, List[str]]:
|
||||
|
||||
|
||||
def _check_output(items: List[str], encoding: str = "utf-8") -> str:
|
||||
from subprocess import check_output
|
||||
return check_output(items).decode(encoding)
|
||||
from subprocess import check_output, CalledProcessError
|
||||
try:
|
||||
return check_output(items).decode(encoding)
|
||||
except CalledProcessError as e:
|
||||
msg = f"Command `{' '.join(e.cmd)}` returned non-zero exit code {e.returncode}"
|
||||
stdout = e.stdout.decode(encoding) if e.stdout is not None else ""
|
||||
stderr = e.stderr.decode(encoding) if e.stderr is not None else ""
|
||||
if len(stderr) == 0:
|
||||
msg += f"\n{stdout}"
|
||||
else:
|
||||
msg += f"\nstdout:\n{stdout}\nstderr:\n{stderr}"
|
||||
raise RuntimeError(msg) from e
|
||||
|
||||
|
||||
class GitCommit:
|
||||
|
Reference in New Issue
Block a user