-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing bug in errors code. Fixes #104
Adds more exception handling around setting stdout/stderr streams in bash apps.
- Loading branch information
Showing
3 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
''' Testing bash apps | ||
''' | ||
import parsl | ||
import parsl.app.errors as perror | ||
from parsl import * | ||
|
||
print("Parsl version: ", parsl.__version__) | ||
|
||
# parsl.set_stream_logger() | ||
workers = ThreadPoolExecutor(max_workers=8) | ||
dfk = DataFlowKernel(executors=[workers]) | ||
|
||
|
||
@App('bash', dfk) | ||
def echo_to_streams(msg, stderr='std.err', stdout='std.out'): | ||
return 'echo "{0}"; echo "{0}" >&2'.format(msg) | ||
|
||
|
||
def test_bad_stdout(): | ||
''' Testing bad stdout file | ||
''' | ||
stdout = "/x/test_bad_stdout.stdout" | ||
stderr = "test_bad_stdout.stderr" | ||
fu = echo_to_streams("Hello world", stderr=stderr, stdout=stdout) | ||
|
||
try: | ||
fu.result() | ||
except Exception as e: | ||
assert isinstance( | ||
e, perror.BadStdStreamFile), "Expected BadStdStreamFile, got :{0}".format(type(e)) | ||
|
||
return | ||
|
||
|
||
def test_bad_stderr(): | ||
''' Testing bad stderr file | ||
''' | ||
stdout = "test_bad_stdout.stdout" | ||
stderr = "/x/test_bad_stdout.stderr" | ||
fu = echo_to_streams("Hello world", stderr=stderr, stdout=stdout) | ||
|
||
try: | ||
fu.result() | ||
except Exception as e: | ||
assert isinstance( | ||
e, perror.BadStdStreamFile), "Expected BadStdStreamFile, got :{0}".format(type(e)) | ||
|
||
return | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-c", "--count", default="10", | ||
help="Count of apps to launch") | ||
parser.add_argument("-d", "--debug", action='store_true', | ||
help="Count of apps to launch") | ||
args = parser.parse_args() | ||
|
||
if args.debug: | ||
parsl.set_stream_logger() | ||
|
||
y = test_bad_stdout() |