def test_optimize(self):
        """
        Test the launch of a simple OptimizeTask
        """
        # Init
        output = {
            'uuid': 'optimize-task-uuid',
            'type': 'optimize',
            'status': 'PENDING'
        }
        self.presience_client.call = MagicMock(return_value=(200, output, {}))
        dataset = Dataset(json={'dataset_id': 'my-dataset-id'},
                          prescience=self.presience_client)

        # Test
        optimize_task = dataset.optimize(budget=10,
                                         scoring_metric=ScoringMetric.ACCURACY)
        self.assertEqual('optimize-task-uuid', optimize_task.uuid())
        self.assertEqual('optimize', optimize_task.type())
        self.assertEqual(Status.PENDING, optimize_task.status())

        self.presience_client.call.assert_called_with(
            method='POST',
            path='/ml/optimize/my-dataset-id',
            content_type='application/json',
            data={
                'scoring_metric': 'accuracy',
                'budget': 10
            },
            multipart=None,
            query_parameters=None,
            admin_call=False)
 def test_get_evaluation_results(self):
     """
     Test the access of evaluation results from a dataset
     """
     # Init
     output = {
         'metadata': {
             'page_number': 2,
             'total_pages': 2,
             'elements_on_page': 1,
             'elements_total': 1,
             'elements_type': 'EvaluationResult'
         },
         'content': [{
             'uuid': 'azerty'
         }]
     }
     self.presience_client.call = MagicMock(return_value=(200, output, {}))
     dataset = Dataset(json={'dataset_id': 'my-dataset-id'},
                       prescience=self.presience_client)
     dataset.evaluation_results(page=2)
     self.presience_client.call.assert_called_with(
         method='GET',
         path='/evaluation-result',
         query_parameters={
             'dataset_id': 'my-dataset-id',
             'page': 2
         })
    def test_delete_single_dataset(self):
        """
        Test the deletion of a dataset
        """
        self.presience_client.call = MagicMock(return_value=(200, {}, {}))
        dataset = Dataset(json={'dataset_id': 'my-dataset-id'},
                          prescience=self.presience_client)

        # Test 1
        dataset.delete()
        self.presience_client.call.assert_called_with(
            method='DELETE',
            path='/dataset/my-dataset-id',
            expect_json_response=False)
Exemplo n.º 4
0
 def dataset(self) -> 'Dataset':
     """
     Getter of the linked dataset for this task
     :return: the dataset object
     """
     from com.ovh.mls.prescience.core.bean.dataset import Dataset
     return Dataset(json=self.initial_payload.get('dataset'), prescience=self.prescience)
Exemplo n.º 5
0
 def dataset(self, dataset_id: str):
     """
     Get a single dataset from its ID
     :param dataset_id: The dataset ID
     :return: The dataset object
     """
     _, source, _ = self.__get(path=f'/dataset/{dataset_id}')
     from com.ovh.mls.prescience.core.bean.dataset import Dataset
     return Dataset(json=source, prescience=self)
 def test_create_dataset_mask(self):
     """
     Test the creation of a dataset mask
     """
     # Init
     self.presience_client.call = MagicMock(return_value=(200, {}, {}))
     dataset = Dataset(json={'dataset_id': 'my-dataset-id'},
                       prescience=self.presience_client)
     dataset.create_mask(mask_id='dataset-mask',
                         selected_column=['col1', 'col2', 'label'])
     self.presience_client.call.assert_called_with(
         method='POST',
         path='/dataset/mask/my-dataset-id',
         query_parameters={'mask_id': 'dataset-mask'},
         content_type='application/json',
         data=['col1', 'col2', 'label'],
         multipart=None,
         admin_call=False)
Exemplo n.º 7
0
 def dataset(self):
     """
     Getter of the linked dataset object
     :return: the dataset object
     """
     dataset_json = self.json_dict.get('dataset', None)
     dataset = None
     if dataset_json is not None:
         dataset = Dataset(json=dataset_json, prescience=self.prescience)
     return dataset
Exemplo n.º 8
0
    def create_mask(self, dataset_id: str, mask_id: str,
                    selected_column: list) -> 'Dataset':
        """
        Create a Mask Dataset from a Dataset
        :param dataset_id: The initial Dataset ID
        :param mask_id: The new ID that we want to create for the Mask Dataset
        :param selected_column: The subset of the initial Dataset that we want to keep for the Mask Dataset
        :return: The new Mask Dataset
        """
        query_parameters = {'mask_id': mask_id}
        _, result, _ = self.__post(path=f'/dataset/mask/{dataset_id}',
                                   data=selected_column,
                                   query_parameters=query_parameters)

        from com.ovh.mls.prescience.core.bean.dataset import Dataset
        return Dataset(json=result, prescience=self)