コード例 #1
0
 def get_search_solutions_results(self, sid):
     logger.info(
         "Geting Search Solution request results for search id: %s" % sid)
     msg = core_pb2.GetSearchSolutionsResultsRequest(search_id=sid)
     soln_ids = set()
     for reply in self.serv.GetSearchSolutionsResults(msg):
         logger.debug("Got message: %s" % str(reply))
         if reply.solution_id:
             logger.debug("Got a message with a solution id: %s" %
                          reply.solution_id)
             soln_ids.add(reply.solution_id)
         if reply.progress.state == core_pb2.PENDING:
             logger.debug("Search is still pending and hasn't begin")
         elif reply.progress.state == core_pb2.RUNNING:
             logger.debug(
                 "Search is currently running and has not completed: %s" %
                 reply.progress.status)
         elif reply.progress.state == core_pb2.COMPLETED:
             logger.info("Search has completed successfully: %s" %
                         reply.progress.status)
         elif reply.progress.state == core_pb2.ERRORED:
             logger.error("Search has completed in an error state: %s" %
                          reply.progress.status)
             raise Exception("Search Solution returned in error: %s" %
                             reply.progress.status)
         else:
             logger.warning("Search is in an unknown state: %s" %
                            str(reply.progress))
     if len(soln_ids) == 0:
         return None
     else:
         return list(soln_ids)
コード例 #2
0
    def do_search(self,
                  dataset_doc_path,
                  problem_doc_path,
                  ta2_id,
                  time_bound=30.0,
                  pipelines_limit=0,
                  pipeline_template=None):
        # Search
        search = self.core.SearchSolutions(
            pb_core.SearchSolutionsRequest(
                user_agent='D3M_TA2_Evaluation',
                version=version,
                time_bound_search=time_bound,
                priority=10,
                rank_solutions_limit=pipelines_limit,
                allowed_value_types=['RAW', 'DATASET_URI', 'CSV_URI'],
                template=pipeline_template,
                problem=self._build_problem(problem_doc_path),
                inputs=[Value(dataset_uri='file://%s' % dataset_doc_path)],
            ))

        # Get request
        getsearch_request = pb_core.GetSearchSolutionsResultsRequest()
        getsearch_request.search_id = search.search_id

        # Make the call (loop cause streaming)-- It makes client docker remain open untill complete
        logger.warning('Solution Stream: ')
        for getsearch_response in self.core.GetSearchSolutionsResults(
                getsearch_request):
            logger.warning(getsearch_response)
            if getsearch_response.solution_id:
                pipeline_id = getsearch_response.solution_id
                yield {'id': pipeline_id, 'search_id': str(search.search_id)}
            logger.warning('------------------------------------')
コード例 #3
0
    def get_search_solutions_results(self, search_id, max_results=None):

        request = core_pb2.GetSearchSolutionsResultsRequest(
            search_id=search_id, )

        LOGGER.debug("%s: %s", request.__class__.__name__, request)

        solutions = []
        for solution in self.stub.GetSearchSolutionsResults(request):
            LOGGER.debug("%s: %s", solution.__class__.__name__, solution)

            solutions.append(solution)

            if max_results and len(solutions) >= max_results:
                break

        return solutions
コード例 #4
0
def get_search_solution_results_request(search_id):
    request = core_pb2.GetSearchSolutionsResultsRequest(search_id=search_id)
    return request