Return http error if views.give_result() is called and it's not a tuning session and updated .gitignore

This commit is contained in:
dvanaken 2020-04-03 01:22:39 -04:00 committed by Dana Van Aken
parent 72580f65a0
commit 78c2fa283a
2 changed files with 8 additions and 1 deletions

View File

@ -14,3 +14,4 @@ celerybeat-schedule*
debug_*.tar.gz debug_*.tar.gz
session_knobs.json session_knobs.json
dump_website.json dump_website.json
.info

View File

@ -1217,6 +1217,12 @@ def give_result(request, upload_code): # pylint: disable=unused-argument
LOG.warning("Invalid upload code: %s", upload_code) LOG.warning("Invalid upload code: %s", upload_code)
return HttpResponse("Invalid upload code: " + upload_code, status=400) return HttpResponse("Invalid upload code: " + upload_code, status=400)
if session.tuning_session == 'no_tuning_session':
err_msg = "Session type '{}' does not generate configurations (upload only)".format(
session.get_tuning_session_display())
LOG.warning(err_msg)
return HttpResponse(err_msg, status=404)
latest_result = Result.objects.filter(session=session).latest('creation_time') latest_result = Result.objects.filter(session=session).latest('creation_time')
task_tuple = JSONUtil.loads(latest_result.task_ids) task_tuple = JSONUtil.loads(latest_result.task_ids)
task_res = celery.result.result_from_tuple(task_tuple) task_res = celery.result.result_from_tuple(task_tuple)
@ -1295,7 +1301,7 @@ def train_ddpg_loops(request, session_id): # pylint: disable=unused-argument
def alt_get_info(request, name): # pylint: disable=unused-argument def alt_get_info(request, name): # pylint: disable=unused-argument
# Backdoor method for getting basic info # Backdoor method for getting basic info
if name in ('website', 'logs'): if name in ('website', 'logs'):
tmpdir = os.path.realpath('.info_{}'.format(int(time.time()))) tmpdir = os.path.realpath('.info/info_{}'.format(int(time.time())))
os.makedirs(tmpdir, exist_ok=False) os.makedirs(tmpdir, exist_ok=False)
try: try: