pytorch/benchmarks/distributed/rpc/parameter_server/test_scripts.py
Garrett Cramer 16d617c3e5 test experiment script (#57925)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57925

1. adds test_scripts.py that will run added scripts and verify that there are no errors
2. adds local ddp_nccl_allreduce experiment script

test with command `pytest test_scripts.py`

Test Plan: Imported from OSS

Reviewed By: agolynski

Differential Revision: D28382452

Pulled By: gcramer23

fbshipit-source-id: 21028a990ebfedf1aad6b007a723c02403e8bea8
2021-05-12 10:22:47 -07:00

23 lines
525 B
Python

import subprocess
from os.path import join
from pathlib import Path
script_dir = join(
Path(__file__).parent, "experiment_scripts"
)
encoding = 'utf-8'
def run_script(script_name):
# runs the script and asserts that there are no errors
p = subprocess.run(
["bash", f"{join(script_dir,script_name)}"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
error = p.stderr.decode(encoding)
assert not error
def test_ddp_nccl_allreduce():
run_script("ddp_nccl_allreduce.sh")