Skip to content

Commit

Permalink
ba working
Browse files Browse the repository at this point in the history
  • Loading branch information
bronevet-abc authored and hrushikeshm-g committed Jan 8, 2025
1 parent 68f36fc commit 5dc42c3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
11 changes: 8 additions & 3 deletions py/sight/widgets/decision/decision.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ def _process_acme_action(selected_action, widget_state):
def _process_worklist_scheduler(sight, req):
"""Processes the action for 'worklist_scheduler' optimizer."""
widget_state = sight.widget_decision_state
logging.info('optimizer.obj=%s, action_id=%s', optimizer.obj, widget_state['action_id'])
logging.info('_process_worklist_scheduler: optimizer.obj=%s, action_id=%s', optimizer.obj, widget_state['action_id'])
if not optimizer.obj:
optimizer.obj = SingleActionOptimizerClient(
sight_pb2.DecisionConfigurationStart.OptimizerType.
Expand Down Expand Up @@ -1214,11 +1214,10 @@ def _make_decision(sight, req):
'vizier',
'genetic_algorithm',
'exhaustive_search',
'bayesian_opt',
'smcpy',
] or optimizer_type.startswith('ng_'):
chosen_action = optimizer_obj.decision_point(sight, req)
elif optimizer_type in ['worklist_scheduler', 'sensitivity_analysis']:
elif optimizer_type in ['worklist_scheduler', 'sensitivity_analysis', 'bayesian_opt']:
chosen_action = _process_worklist_scheduler(sight, req)
elif optimizer_type.startswith('llm_'):
chosen_action = _process_llm_action(sight, req, optimizer_obj)
Expand Down Expand Up @@ -1427,11 +1426,17 @@ def _handle_optimizer_finalize(sight: Any, req: Any) -> None:

for action_id, msg in all_messages.items():
logging.info('action_id=%s, msg=%s', action_id, msg)
logging.info('msg.action_params=%s', msg.action_params)
decision_message = sight_pb2.DecisionMessage()
decision_message.decision_outcome.CopyFrom(
get_decision_outcome_from_decision_message(outcome_label='outcome',
decision_message=msg))
decision_message.action_id = action_id

choice_params = sight_pb2.DecisionParam()
choice_params.CopyFrom(convert_dict_to_proto(dict=msg.action_params))
decision_message.decision_point.choice_params.CopyFrom(choice_params)

logging.info('decision_message=%s', decision_message)
req.decision_messages.append(decision_message)
logging.info('req=%s', req)
Expand Down
18 changes: 9 additions & 9 deletions sight_service/bayesian_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ def finalize_episode(
) -> service_pb2.FinalizeEpisodeResponse:
logging.info('FinalizeEpisode request=%s', request)

d = convert_proto_to_dict(proto=request.decision_point.choice_params)
# d = {}
# for a in request.decision_point.choice_params:
# d[a.key] = a.value.double_value

self._lock.acquire()
logging.info('FinalizeEpisode outcome=%s / %s',
request.decision_outcome.reward, d)
self._optimizer.register(params=d, target=request.decision_outcome.reward)
# self._completed_count += 1
for i in range(len(request.decision_messages)):
d = convert_proto_to_dict(proto=request.decision_messages[i].decision_point.choice_params)
logging.info('FinalizeEpisode outcome=%s / %s',
request.decision_messages[i].decision_outcome.reward, d)
# d = {}
# for a in request.decision_point.choice_params:
# d[a.key] = a.value.double_value
self._optimizer.register(params=d, target=request.decision_messages[i].decision_outcome.reward)
# self._completed_count += 1
self._lock.release()
return service_pb2.FinalizeEpisodeResponse(response_str='Success!')

Expand Down
2 changes: 1 addition & 1 deletion sight_service/proto/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ message GetOutcomeResponse {
message FinalizeEpisodeRequest {
string client_id = 1;
string worker_id = 2;
// sight.x.proto.DecisionPoint decision_point = 3;
sight.x.proto.DecisionPoint decision_point = 3;
// sight.x.proto.DecisionOutcome decision_outcome = 4;
sight.x.proto.DecisionConfigurationStart.OptimizerType optimizer_type = 5;
Acme_Request acme_config = 6;
Expand Down

0 comments on commit 5dc42c3

Please sign in to comment.