def RegisterObservations(self, request, context): # pylint: disable=unused-argument # TODO: stop ignoring context # observations = request.Observations features_df = pd.read_json(observations.Features.FeaturesJsonString, orient='index') objectives_df = pd.read_json(observations.ObjectiveValues.ObjectiveValuesJsonString, orient='index') with self.exclusive_optimizer(optimizer_id=request.OptimizerHandle.Id) as optimizer: optimizer.register(feature_values_pandas_frame=features_df, target_values_pandas_frame=objectives_df) return Empty()
def get_existing_optimizers(self): """Returns proxies to all existing optimizers. :return: """ request = Empty() optimizer_list = self._optimizer_service_stub.ListExistingOptimizers(request) optimizer_proxies = [ self._optimizer_factory.connect_to_existing_remote_optimizer(optimizer_info) for optimizer_info in optimizer_list.Optimizers ] return optimizer_proxies
def RegisterObservation(self, request, context): # pylint: disable=unused-argument # TODO: add an API to register observations in bulk. # TODO: stop ignoring context # feature_values = json.loads(request.Observation.Features.FeaturesJsonString) feature_values_dataframe = pd.DataFrame(feature_values, index=[0]) objective_values = json.loads(request.Observation.ObjectiveValues.ObjectiveValuesJsonString) objective_values_dataframe = pd.DataFrame(objective_values, index=[0]) with self.exclusive_optimizer(optimizer_id=request.OptimizerHandle.Id) as optimizer: optimizer.register(feature_values_pandas_frame=feature_values_dataframe, target_values_pandas_frame=objective_values_dataframe) return Empty()
def Echo(self, request: Empty, context): # pylint: disable=unused-argument return Empty()
def test_echo(self): optimizer_service_stub = OptimizerServiceStub(channel=self.optimizer_service_channel) response = optimizer_service_stub.Echo(Empty()) self.assertTrue(isinstance(response, Empty))