Added flag to alt_create_or_edit_session() that specifies whether to return the ddpg models

This commit is contained in:
dvanaken 2020-04-17 00:07:04 -04:00 committed by Dana Van Aken
parent 288805aae3
commit 9cc119e129
1 changed files with 11 additions and 4 deletions

View File

@ -1553,6 +1553,7 @@ def alt_create_or_edit_session(request):
session_knobs = data.pop('session_knobs', None) session_knobs = data.pop('session_knobs', None)
disable_others = data.pop('disable_others', False) disable_others = data.pop('disable_others', False)
hyperparams = data.pop('hyperparameters', None) hyperparams = data.pop('hyperparameters', None)
return_ddpg_model = data.pop('return_ddpg_model', False)
ts = now() ts = now()
if request.path == reverse('backdoor_create_session'): if request.path == reverse('backdoor_create_session'):
@ -1634,10 +1635,16 @@ def alt_create_or_edit_session(request):
res['hardware_id'] = res['hardware'] res['hardware_id'] = res['hardware']
res['hardware'] = model_to_dict(session.hardware) res['hardware'] = model_to_dict(session.hardware)
res['algorithm'] = AlgorithmType.name(res['algorithm']) res['algorithm'] = AlgorithmType.name(res['algorithm'])
if session.ddpg_actor_model is not None: if return_ddpg_model:
res['ddpg_actor_model'] = base64.encodebytes(session.ddpg_actor_model).decode('utf8') if session.ddpg_actor_model is not None:
res['ddpg_critic_model'] = base64.encodebytes(session.ddpg_critic_model).decode('utf8') res['ddpg_actor_model'] = base64.encodebytes(session.ddpg_actor_model).decode('utf8')
res['ddpg_replay_memory'] = base64.encodebytes(session.ddpg_reply_memory).decode('utf8') res['ddpg_critic_model'] = base64.encodebytes(session.ddpg_critic_model).decode('utf8')
res['ddpg_replay_memory'] = base64.encodebytes(
session.ddpg_reply_memory).decode('utf8')
else:
res['ddpg_actor_model'] = None
res['ddpg_critic_model'] = None
res['ddpg_replay_memory'] = None
sk = SessionKnob.objects.get_knobs_for_session(session) sk = SessionKnob.objects.get_knobs_for_session(session)
sess_knobs = {} sess_knobs = {}
for knob in sk: for knob in sk: