def exec(self, args: dict): source_id = prompt_for_source_id_if_needed(args, self.prescience_client) source = self.prescience_client.source(source_id) download_directory = args.get('download') cache = args.get('cache') output = args.get('output') preview = args.get('preview') tree = args.get('tree') if preview is not None: df = self.prescience_client.source_dataframe(source_id=source_id) TablePrinter.print_dataframe(df.head(10), wanted_keys=preview, output=output) elif args.get('schema'): source.schema().show(output) elif download_directory is not None: self.prescience_client.download_source( source_id=source_id, output_directory=download_directory) elif cache: self.prescience_client.update_cache_source(source_id) elif tree: source.tree().show() else: source.show(output)
def exec(self, args: dict): display_schema = args.get('schema') dataset_id = prompt_for_dataset_id_if_needed(args, self.prescience_client) output = args.get('output') download_train_directory = args.get('download_train') download_test_directory = args.get('download_test') preview = args.get('preview') tree = args.get('tree') cache = args.get('cache') if display_schema: self.prescience_client.dataset(dataset_id).schema().show(output) elif preview is not None: df = self.prescience_client.dataset_dataframe( dataset_id=dataset_id, test_part=False) TablePrinter.print_dataframe(df.head(100), wanted_keys=preview, output=output) elif download_train_directory is not None: self.prescience_client.download_dataset( dataset_id=dataset_id, output_directory=download_train_directory, test_part=False) elif download_test_directory is not None: self.prescience_client.download_dataset( dataset_id=dataset_id, output_directory=download_test_directory, test_part=True) elif tree: self.prescience_client.dataset(dataset_id).tree().show() elif cache: self.prescience_client.update_cache_dataset(dataset_id, True) self.prescience_client.update_cache_dataset(dataset_id, False) else: self.prescience_client.dataset(dataset_id).show(output)