def do_test(self, fitted_solution_id, dataset_path): tested = None try: response = self.core.ProduceSolution( pb_core.ProduceSolutionRequest( fitted_solution_id=fitted_solution_id, inputs=[ pb_value.Value(dataset_uri='file://%s' % dataset_path, ) ], expose_outputs=['outputs.0'], expose_value_types=['CSV_URI'], users=[], )) # Results results = self.core.GetProduceSolutionResults( pb_core.GetProduceSolutionResultsRequest( request_id=response.request_id, )) for result in results: if result.progress.state == pb_core.COMPLETED: tested = result.exposed_outputs['outputs.0'].csv_uri except: logger.exception("Exception testing %r", fitted_solution_id) return tested
def produce_solution_request(fitted_solution_id, test_paths): inputs = [value_pb2.Value(dataset_uri=test_paths['TEST']['dataset'])] expose_outputs = ['outputs.0'] expose_value_types = ['CSV_URI'] users = [ core_pb2.SolutionRunUser(id='test_user', chosen=True, reason='just because') ] request = core_pb2.ProduceSolutionRequest( fitted_solution_id=fitted_solution_id, inputs=inputs, expose_outputs=expose_outputs, expose_value_types=expose_value_types, users=users) return request
def produce_solution(self, fsid, soln, ds, inputs=None, outputs=None): logger.info("Produce predictions for solution with id: %s" % soln.id) msg = core_pb2.ProduceSolutionRequest(fitted_solution_id=fsid) # Add inputs if given if inputs is None: i = msg.inputs.add() i.dataset_uri = ds.get_schema_uri() else: for inpt in inputs: i = msg.inputs.add() # For now force it into a string until type checking is implemented i.string = str(inpt) # Add list of outputs to expose if outputs is None: if 'mit' in self.name: logger.debug("Using pipeline format 'describe'") msg.expose_outputs.extend( [soln.get_default_output(format='describe')]) else: logger.debug("Using pipeline format 'name'") msg.expose_outputs.extend( [soln.get_default_output(format='name')]) allowed_vals = [ val for val in self.allowed_values if val in self.__allowed_values__ ] msg.expose_value_types.extend(allowed_vals) logger.info("****************************************") msg_js = json_format.MessageToJson(msg) logger.info("Sending produce solution with msg: %s" % msg_js) logger.info("****************************************") if self.debug: self.write_msg_to_file(msg, 'produce_solution_msg.json') reply = self.serv.ProduceSolution(msg) if self.debug: self.write_msg_to_file(reply, 'produce_solution_reply.json') self.produce_solution_requests[reply.request_id] = msg return reply.request_id
def produce_solution(self, fitted_solution_id, dataset): request = core_pb2.ProduceSolutionRequest( fitted_solution_id=fitted_solution_id, inputs=[Value(dataset_uri=self._get_dataset_doc_path(dataset))], expose_outputs=['outputs.0'], expose_value_types=[ValueType.Value('CSV_URI')], # users=[ # core_pb2.SolutionRunUser( # id='dummy', # choosen=True, # reason='dummy' # ) # ] ) LOGGER.debug("%s: %s", request.__class__.__name__, request) response = self.stub.ProduceSolution(request) LOGGER.debug("%s: %s", response.__class__.__name__, response) return response