(torch/elastic) add fqdn hostname to error printout (#66182) (#66662)
authorkiukchung <43595115+kiukchung@users.noreply.github.com>
Fri, 15 Oct 2021 01:35:23 +0000 (18:35 -0700)
committerGitHub <noreply@github.com>
Fri, 15 Oct 2021 01:35:23 +0000 (18:35 -0700)
commit36449ea93134574c2a22b87baad3de0bf8d64d42
tree76700597a11113c7cc8acbd03142e811800d34d9
parentb544cbddfaa2c085d1b16e5313b3af09d2c1663d
(torch/elastic) add fqdn hostname to error printout (#66182) (#66662)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/66182

closes https://github.com/pytorch/pytorch/issues/63174

Does a few things:

1. adds hostname to the error report
2. moves the "root cause" section to the end (presumably since the logs are being "tailed" we want the root cause to appear at the end)
3. moves redundant error info logging to debug
4. makes the border max 60 char in length and justifies left for the header

NOTE: YOU HAVE TO annotate your main function with torch.distributed.elastic.multiprocessing.errors.record, otherwise no traceback is printed (this is because python exception propagation does NOT work out of the both for IPC - hence the extra record annotation).

Test Plan:
Sample

```
============================================================
run_script_path FAILED
------------------------------------------------------------
Failures:
  <NO_OTHER_FAILURES>
------------------------------------------------------------
Root Cause (first observed failure):
[0]:
  time      : 2021-10-05_17:37:22
  host      : devvm4955.prn0.facebook.com
  rank      : 0 (local_rank: 0)
  exitcode  : 1 (pid: 3296201)
  error_file: /home/kiuk/tmp/elastic/none_3_lsytqe/attempt_0/0/error.json
  traceback :
  Traceback (most recent call last):
    File "/tmp/jetter.xr3_x6qq/torch/distributed/elastic/multiprocessing/errors/__init__.py", line 372, in wrapper
      return f(*args, **kwargs)
    File "main.py", line 28, in main
      raise RuntimeError(args.throws)
  RuntimeError: foobar

============================================================
```

Reviewed By: cbalioglu, aivanou

Differential Revision: D31416492

fbshipit-source-id: 0aeaf6e634e23ce0ea7f6a03b12c8a9ac57246e9
test/distributed/elastic/multiprocessing/api_test.py
test/distributed/elastic/multiprocessing/errors/api_test.py
torch/distributed/elastic/agent/server/local_elastic_agent.py
torch/distributed/elastic/multiprocessing/errors/__init__.py
torch/distributed/elastic/multiprocessing/errors/error_handler.py
torch/distributed/run.py