Finds and returns all datasets from the database which matches the requirement. In some case, the data in a dataset can be stored separately for better management. Parameters ---------- dataset_name : str The name/key of dataset. kwargs : other ev
(self, dataset_name=None, **kwargs)
| 359 | return False |
| 360 | |
| 361 | def find_datasets(self, dataset_name=None, **kwargs): |
| 362 | """Finds and returns all datasets from the database which matches the requirement. |
| 363 | In some case, the data in a dataset can be stored separately for better management. |
| 364 | |
| 365 | Parameters |
| 366 | ---------- |
| 367 | dataset_name : str |
| 368 | The name/key of dataset. |
| 369 | kwargs : other events |
| 370 | Other events, such as description, author and etc (optional). |
| 371 | |
| 372 | Returns |
| 373 | -------- |
| 374 | params : the parameters, return False if nothing found. |
| 375 | |
| 376 | """ |
| 377 | |
| 378 | self._fill_project_info(kwargs) |
| 379 | if dataset_name is None: |
| 380 | raise Exception("dataset_name is None, please give a dataset name") |
| 381 | kwargs.update({'dataset_name': dataset_name}) |
| 382 | |
| 383 | s = time.time() |
| 384 | pc = self.db.Dataset.find(kwargs) |
| 385 | |
| 386 | if pc is not None: |
| 387 | dataset_id_list = pc.distinct('dataset_id') |
| 388 | dataset_list = [] |
| 389 | for dataset_id in dataset_id_list: # you may have multiple Buckets files |
| 390 | tmp = self.dataset_fs.get(dataset_id).read() |
| 391 | dataset_list.append(self._deserialization(tmp)) |
| 392 | else: |
| 393 | print("[Database] FAIL! Cannot find any dataset: {}".format(kwargs)) |
| 394 | return False |
| 395 | |
| 396 | print("[Database] Find {} datasets SUCCESS, took: {}s".format(len(dataset_list), round(time.time() - s, 2))) |
| 397 | return dataset_list |
| 398 | |
| 399 | def delete_datasets(self, **kwargs): |
| 400 | """Delete datasets. |
nothing calls this directly
no test coverage detected