def GetFitSolutionResults(self, request, context): """grpc GetFitSolutionResults call""" msgd(self.GetFitSolutionResults.__doc__) total_loops = 3 for loop_num in range(total_loops): # pause 1, 3 seconds... pause_secs = random.randint(1, 3) print('(loop %d/%d) pausing %d seconds' % \ ((loop_num + 1), total_loops, pause_secs)) time.sleep(pause_secs) step_progress = core_pb2.StepProgress(\ progress=get_progress(no_errors=True), steps=[core_pb2.StepProgress(\ progress=get_progress(no_errors=True))]) resp = core_pb2.GetFitSolutionResultsResponse(\ progress=get_progress(no_errors=True), steps=[step_progress], exposed_outputs=dict(\ key1=value_pb2.Value(csv_uri='file://uri/to-a/csv'), key2=value_pb2.Value(dataset_uri='file://uri/to-a/dataset')), fitted_solution_id=get_solution_id_str()) yield resp
def GetSearchSolutionsResults(self, request, context): """grpc GetSearchSolutionsResults call""" msgd(self.GetSearchSolutionsResults.__doc__) total_loops = 3 for loop_num in range(total_loops): # pause 1, 3 seconds... pause_secs = random.randint(1, 3) print('(loop %d/%d) pausing %d seconds' % \ ((loop_num + 1), total_loops, pause_secs)) time.sleep(pause_secs) score_list = [] for _loop in range(0, random.randint(0, 3)): score_list.append(get_solution_search_score()) resp = core_pb2.GetSearchSolutionsResultsResponse(\ progress=get_progress(), done_ticks=random.randint(1, 9), all_ticks=10, solution_id=get_solution_id_str(), internal_score=0, scores=score_list) self.print_resp(resp) yield resp
def test_SolutionExport(): req = core_pb2.SolutionExportRequest(\ fitted_solution_id=get_solution_id_str(), rank=round(random.random(), 3)) print(MessageToJson(req, including_default_value_fields=True))
def test_ScoreSolution(): """work out the req/resp""" perf_metrics = [\ problem_pb2.ProblemPerformanceMetric(metric=\ get_rand_enum_val(problem_pb2.PerformanceMetric)), problem_pb2.ProblemPerformanceMetric(metric=\ get_rand_enum_val(problem_pb2.PerformanceMetric))] req = core_pb2.ScoreSolutionRequest(\ solution_id=get_solution_id_str(), inputs=[value_pb2.Value(csv_uri='file://uri/to-a/csv'), value_pb2.Value(dataset_uri='file://uri/to-a/dataset')], performance_metrics=perf_metrics, users=[core_pb2.SolutionRunUser(\ id='uuid of user', choosen=True, reason='best solution'), core_pb2.SolutionRunUser(\ id='uuid of user', choosen=False)], configuration=get_scoring_configuration()) """ message ScoreSolutionRequest { string solution_id = 1; repeated Value inputs = 2; repeated ProblemPerformanceMetric performance_metrics = 3; // Any users associated with this call itself. Optional. repeated SolutionRunUser users = 4; ScoringConfiguration configuration = 5; } """ print(MessageToJson(req, including_default_value_fields=True))
def test_ProduceSolution(): req = core_pb2.ProduceSolutionRequest(\ fitted_solution_id=get_solution_id_str(), inputs=[value_pb2.Value(csv_uri='file://uri/to-a/csv'), value_pb2.Value(dataset_uri='file://uri/to-a/dataset')], expose_outputs=['steps.1.steps.4.produce'], expose_value_types=[get_rand_enum_val(value_pb2.ValueType), get_rand_enum_val(value_pb2.ValueType)], users=[core_pb2.SolutionRunUser(\ id='uuid of user', choosen=True, reason='best solution'), core_pb2.SolutionRunUser(\ id='uuid of user', choosen=False)]) print(MessageToJson(req, including_default_value_fields=True))
def test_GetSearchSolutionsResults(): """work out the req/resp""" req = core_pb2.GetSearchSolutionsResultsRequest(\ search_id=get_search_id_str()) print(MessageToJson(req)) score_list = [] for _loop in range(0, random.randint(1, 3)): score_list.append(get_solution_search_score()) resp = core_pb2.GetSearchSolutionsResultsResponse(\ progress=get_progress(), done_ticks=random.randint(1, 9), all_ticks=10, solution_id=get_solution_id_str(), internal_score=0, scores=score_list) print(MessageToJson(resp, including_default_value_fields=True))
def test_GetFitSolutionResults(): req = core_pb2.GetFitSolutionResultsRequest( request_id=get_request_id_str()) print(MessageToJson(req, including_default_value_fields=True)) step_progress = core_pb2.StepProgress(\ progress=get_progress(no_errors=True), steps=[core_pb2.StepProgress(\ progress=get_progress(no_errors=True))]) resp = core_pb2.GetFitSolutionResultsResponse(\ progress=get_progress(no_errors=True), steps=[step_progress], exposed_outputs=dict(\ key1=value_pb2.Value(csv_uri='file://uri/to-a/csv'), key2=value_pb2.Value(dataset_uri='file://uri/to-a/dataset')), fitted_solution_id=get_solution_id_str()) print(MessageToJson(resp, including_default_value_fields=True))