| 329 | |
| 330 | |
| 331 | def get_sha(): |
| 332 | cwd = os.path.dirname(os.path.abspath(__file__)) |
| 333 | |
| 334 | def _run(command): |
| 335 | return subprocess.check_output(command, |
| 336 | cwd=cwd).decode('ascii').strip() |
| 337 | |
| 338 | sha = 'N/A' |
| 339 | diff = 'clean' |
| 340 | branch = 'N/A' |
| 341 | try: |
| 342 | sha = _run(['git', 'rev-parse', 'HEAD']) |
| 343 | subprocess.check_output(['git', 'diff'], cwd=cwd) |
| 344 | diff = _run(['git', 'diff-index', 'HEAD']) |
| 345 | diff = 'has uncommited changes' if diff else 'clean' |
| 346 | branch = _run(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) |
| 347 | except Exception: |
| 348 | pass |
| 349 | message = f'sha: {sha}, status: {diff}, branch: {branch}' |
| 350 | return message |
| 351 | |
| 352 | |
| 353 | def collate_fn(batch): |