Skip to content

Commit

Permalink
[batch] provide sufficient information to debug transient errors (hai…
Browse files Browse the repository at this point in the history
…l-is#14151)

This provides useful feedback we can use to understand why
`test_file_in_current_dir` keeps failing.
  • Loading branch information
danking authored Jan 12, 2024
1 parent f49789f commit 72669f7
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions hail/python/test/hailtop/hailctl/batch/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,35 @@ def test_file_with_no_dest(runner: CliRunner):
os.chdir(dir)
write_hello(f'{dir}/hello.txt')
write_script(dir, f'{dir}/hello.txt')
res = runner.invoke(cli.app, ['submit', '--files', 'hello.txt', 'test_job.py'])
assert res.exit_code == 0
res = runner.invoke(cli.app, ['submit', '--files', 'hello.txt', 'test_job.py'], catch_exceptions=False)
assert res.exit_code == 0, repr((res.output, res.stdout, res.stderr, res.exception))


def test_file_in_current_dir(runner: CliRunner):
with tempfile.TemporaryDirectory() as dir:
os.chdir(dir)
write_hello(f'{dir}/hello.txt')
write_script(dir, f'/hello.txt')
res = runner.invoke(cli.app, ['submit', '--files', 'hello.txt:/', 'test_job.py'])
assert res.exit_code == 0
res = runner.invoke(cli.app, ['submit', '--files', 'hello.txt:/', 'test_job.py'], catch_exceptions=False)
assert res.exit_code == 0, repr((res.output, res.stdout, res.stderr, res.exception))


def test_file_mount_in_child_dir(runner: CliRunner):
with tempfile.TemporaryDirectory() as dir:
os.chdir(dir)
write_hello(f'{dir}/hello.txt')
write_script(dir, '/child/hello.txt')
res = runner.invoke(cli.app, ['submit', '--files', 'hello.txt:/child/', 'test_job.py'])
assert res.exit_code == 0
res = runner.invoke(cli.app, ['submit', '--files', 'hello.txt:/child/', 'test_job.py'], catch_exceptions=False)
assert res.exit_code == 0, repr((res.output, res.stdout, res.stderr, res.exception))


def test_file_mount_in_child_dir_to_root_dir(runner: CliRunner):
with tempfile.TemporaryDirectory() as dir:
os.chdir(dir)
write_hello(f'{dir}/child/hello.txt')
write_script(dir, '/hello.txt')
res = runner.invoke(cli.app, ['submit', '--files', 'child/hello.txt:/', 'test_job.py'])
assert res.exit_code == 0
res = runner.invoke(cli.app, ['submit', '--files', 'child/hello.txt:/', 'test_job.py'], catch_exceptions=False)
assert res.exit_code == 0, repr((res.output, res.stdout, res.stderr, res.exception))


def test_mount_multiple_files(runner: CliRunner):
Expand All @@ -75,9 +75,11 @@ def test_mount_multiple_files(runner: CliRunner):
write_hello(f'{dir}/child/hello2.txt')
write_script(dir, '/hello1.txt')
res = runner.invoke(
cli.app, ['submit', '--files', 'child/hello1.txt:/', '--files', 'child/hello2.txt:/', 'test_job.py']
cli.app,
['submit', '--files', 'child/hello1.txt:/', '--files', 'child/hello2.txt:/', 'test_job.py'],
catch_exceptions=False,
)
assert res.exit_code == 0
assert res.exit_code == 0, repr((res.output, res.stdout, res.stderr, res.exception))


def test_dir_mount_in_child_dir_to_child_dir(runner: CliRunner):
Expand All @@ -86,8 +88,8 @@ def test_dir_mount_in_child_dir_to_child_dir(runner: CliRunner):
write_hello(f'{dir}/child/hello1.txt')
write_hello(f'{dir}/child/hello2.txt')
write_script(dir, '/child/hello1.txt')
res = runner.invoke(cli.app, ['submit', '--files', 'child/:/child/', 'test_job.py'])
assert res.exit_code == 0
res = runner.invoke(cli.app, ['submit', '--files', 'child/:/child/', 'test_job.py'], catch_exceptions=False)
assert res.exit_code == 0, repr((res.output, res.stdout, res.stderr, res.exception))


def test_file_outside_curdir(runner: CliRunner):
Expand All @@ -96,8 +98,10 @@ def test_file_outside_curdir(runner: CliRunner):
os.chdir(f'{dir}/working_dir')
write_hello(f'{dir}/hello.txt')
write_script(dir, '/hello.txt')
res = runner.invoke(cli.app, ['submit', '--files', f'{dir}/hello.txt:/', '../test_job.py'])
assert res.exit_code == 0
res = runner.invoke(
cli.app, ['submit', '--files', f'{dir}/hello.txt:/', '../test_job.py'], catch_exceptions=False
)
assert res.exit_code == 0, repr((res.output, res.stdout, res.stderr, res.exception))


def test_dir_outside_curdir(runner: CliRunner):
Expand All @@ -107,5 +111,5 @@ def test_dir_outside_curdir(runner: CliRunner):
write_hello(f'{dir}/hello1.txt')
write_hello(f'{dir}/hello2.txt')
write_script(dir, '/hello1.txt')
res = runner.invoke(cli.app, ['submit', '--files', f'{dir}/:/', '../test_job.py'])
assert res.exit_code == 0, (res.exit_code, res.stdout, res.stderr)
res = runner.invoke(cli.app, ['submit', '--files', f'{dir}/:/', '../test_job.py'], catch_exceptions=False)
assert res.exit_code == 0, repr((res.exit_code, res.stdout, res.stderr, res.exception))

0 comments on commit 72669f7

Please sign in to comment.