Exemple #1
0
def test_apiclient_search_solutions(search_solutions_request_mock,
                                    logger_mock):
    instance = TA3APIClient(port=9999)
    dataset = 'test_dataset'
    expected_value = 'response'

    # instance mocks
    instance._get_dataset_doc_path = MagicMock(return_value='dataset-doc-path')
    instance._build_problem = MagicMock(return_value='build-problem')
    instance.stub.SearchSolutions = MagicMock(return_value=expected_value)

    value = instance.search_solutions(dataset)
    assert value == expected_value

    search_solutions_request_mock.assert_called_once_with(
        user_agent='ta3_api_test.py',
        version='2019.6.11',
        time_bound_search=1.,
        priority=0.,
        allowed_value_types=[
            ValueType.Value('RAW'),
            ValueType.Value('DATASET_URI'),
            ValueType.Value('CSV_URI'),
        ],
        inputs=[Value(dataset_uri='dataset-doc-path')],
        problem='build-problem')

    assert logger_mock.call_count == 2
Exemple #2
0
    def fit_solution(self, solution_id, dataset):

        request = core_pb2.FitSolutionRequest(
            solution_id=solution_id,
            inputs=[Value(dataset_uri=self._get_dataset_doc_path(dataset))],
            expose_outputs=[
                'outputs.0'
                # 'steps.0.produce'
            ],
            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.FitSolution(request)

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

        return response
Exemple #3
0
def test_apiclient_fit_solution(fit_solution_request_mock, logger_mock):
    instance = TA3APIClient(port=9999)
    solution_id = 'solution-id'
    dataset = 'test-dataset'
    expected_response = 'response'

    # mocks
    fit_solution_request_mock.return_value = 'request'
    instance._get_dataset_doc_path = MagicMock(return_value='dataset-doc-path')
    instance.stub.FitSolution = MagicMock(return_value=expected_response)

    return_value = instance.fit_solution(solution_id, dataset)

    assert return_value == expected_response
    assert logger_mock.call_count == 2

    fit_solution_request_mock.assert_called_once_with(
        solution_id=solution_id,
        inputs=[Value(dataset_uri='dataset-doc-path')],
        expose_outputs=['outputs.0'],
        expose_value_types=[ValueType.Value('CSV_URI')])

    instance.stub.FitSolution.called_once_with('request')
Exemple #4
0
    def search_solutions(self, dataset, time_bound_search=1.):

        created_at = Timestamp()
        created_at.FromDatetime(datetime.utcnow())

        request = core_pb2.SearchSolutionsRequest(
            user_agent='ta3_api_test.py',
            version='2019.7.9',
            time_bound_search=time_bound_search,
            priority=0.,
            allowed_value_types=[
                ValueType.Value('RAW'),
                ValueType.Value('DATASET_URI'),
                ValueType.Value('CSV_URI'),
            ],
            inputs=[Value(dataset_uri=self._get_dataset_doc_path(dataset))],
            problem=self._build_problem(dataset)
            # template=pipeline_pb2.PipelineDescription(
            #     id='dummy',
            #     source=pipeline_pb2.PipelineSource(
            #         name='dummy',
            #         contact='dummy',
            #         pipelines=['dummy'],
            #     ),
            #     created=created_at,
            #     context=pipeline_pb2.PipelineContext.Value('PIPELINE_CONTEXT_UNKNOWN'),
            #     name='dummy',
            #     description='dummy',
            #     users=[
            #         pipeline_pb2.PipelineDescriptionUser(
            #             id='dummy',
            #             reason='dummy',
            #             rationale='dummy'
            #         )
            #     ],
            #     inputs=[
            #         pipeline_pb2.PipelineDescriptionInput(
            #             name='dummy'
            #         )
            #     ],
            #     outputs=[
            #         pipeline_pb2.PipelineDescriptionOutput(
            #             name='dummy',
            #             data='dummy'
            #         )
            #     ],
            #     steps=[
            #         pipeline_pb2.PipelineDescriptionStep(
            #             primitive=pipeline_pb2.PrimitivePipelineDescriptionStep(
            #                 primitive=Primitive(
            #                     id='dummy',
            #                     version='dummy',
            #                     python_path='dummy',
            #                     name='dummy',
            #                     digest='dummy'
            #                 ),
            #                 arguments={
            #                     'dummy': pipeline_pb2.PrimitiveStepArgument(
            #                         data=pipeline_pb2.DataArgument(
            #                             data='dummy'
            #                         )
            #                     )
            #                 },
            #                 outputs=[
            #                     pipeline_pb2.StepOutput(
            #                         id='dummy'
            #                     )
            #                 ],
            #                 hyperparams={
            #                     'dummy': pipeline_pb2.PrimitiveStepHyperparameter(
            #                         data=pipeline_pb2.DataArgument(
            #                             data='dummy'
            #                         )
            #                     )
            #                 },
            #                 users=[
            #                     pipeline_pb2.PipelineDescriptionUser(
            #                         id='dummy',
            #                         reason='dummy',
            #                         rationale='dummy'
            #                     )
            #                 ],
            #             )
            #         )
            #     ]
            # ),
        )

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

        response = self.stub.SearchSolutions(request)

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

        return response