Skip to content

Commit

Permalink
BLD: non existing id handling on status request
Browse files Browse the repository at this point in the history
  • Loading branch information
AvishaiW committed Aug 21, 2018
1 parent c0c9981 commit 09fc44c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
36 changes: 19 additions & 17 deletions catalyst/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,25 +744,27 @@ def remote_status(ctx, algo_id, data_output, log_output):
if algo_id is None:
ctx.fail("must specify an id of your running algorithm with '--id'")

click.echo('Running in backtesting mode.', sys.stdout)

perf, log = get_remote_status(
status_response = get_remote_status(
algo_id=algo_id
)

if log_output == '-':
click.echo(str(log), sys.stdout)
elif log_output != os.devnull:
with open(log_output, 'w') as file:
file.write(log)

if data_output == '-' or perf is None:
click.echo('the performance data is:\n' + str(perf), sys.stdout)
elif data_output != os.devnull:
# make the catalyst magic not write any data
perf.to_pickle(data_output)

return perf
if isinstance(status_response, tuple):
status, perf, log= status_response
if log_output == '-':
click.echo(str(log), sys.stderr)
elif log_output != os.devnull:
with open(log_output, 'w') as file:
file.write(log)

if data_output == '-' or perf is None:
click.echo('the performance data is:\n' + str(perf), sys.stdout)
elif data_output != os.devnull:
# make the catalyst magic not write any data
perf.to_pickle(data_output)
print(status)
return status, perf
else:
print(status_response)
return status_response


# @main.command(name='serve-live')
Expand Down
11 changes: 9 additions & 2 deletions catalyst/utils/remote_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

POST = 'POST'
GET = 'GET'
NONEXISTENT = 'nonexistent'

EXCEPTION_LOG = "please contact Catalyst support to fix this issue at\n" \
"https://github.com/enigmampc/catalyst/issues/"
Expand Down Expand Up @@ -63,6 +64,12 @@ def decompress_data(encoded_data):


def handle_status(received_content):
status = received_content['status']
if status == NONEXISTENT:
log.error(received_content['message'])
return status

log.info("The status of the algorithm is: '{}'".
format(received_content['status']))
return load_response(received_content)
format(status))
perf, log_file = load_response(received_content)
return status, perf, log_file

0 comments on commit 09fc44c

Please sign in to comment.