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 show(self, output: OutputFormat = OutputFormat.TABLE): """ Show the current schema on stdout """ if isinstance(output, str): output = OutputFormat(output) if output == OutputFormat.JSON: print(json.dumps(self.json)) if output == OutputFormat.HTML: df = TablePrinter.get_table_dataframe(Field, self.fields()) return TablePrinter.print_html(df) else: print(TablePrinter.get_table(Field, self.fields())) return self
def show(self, output: OutputFormat = OutputFormat.TABLE): """ Display the current algorithm configuration on std out :param ouput: The output format """ if output == OutputFormat.JSON: print(json.dumps(self.json_dict)) else: description_dict = { k: v for k, v in self.json_dict.items() if k not in ['hyperparameters'] } TablePrinter.print_dict('ALGORITHMS', description_dict) print( TablePrinter.get_table(Hyperparameter, self.get_hyperparameters()))
def show_arguments(self) -> 'ServingPayload': """ Display the filled argument with there validations inputs on std out :return: The current serving payload """ evaluator_inputs = self.current_inputs_evaluators() table = TablePrinter.get_table(Input, evaluator_inputs) print(table.get_string(title=f'ARGUMENTS ({self.get_payload_id()})')) return self
def show(self, output: OutputFormat = OutputFormat.TABLE): """ Show the current page on stdout """ if isinstance(output, str): output = OutputFormat(output) if output == OutputFormat.JSON: print(json.dumps(self.json_dict, indent=4)) elif output == OutputFormat.HTML: df = TablePrinter.get_table_dataframe(self.page_class, self.content) return TablePrinter.print_html(df) else: table = TablePrinter.get_table(self.page_class, self.content) print(table.get_string(title=colored(self.metadata.elements_type.upper(), 'yellow', attrs=['bold']))) print(colored(f'page {self.metadata.page_number}/{self.metadata.total_pages}', 'yellow')) return self
def show_result(self) -> 'ServingPayload': """ Display the result of the serving payload on std out :return: The current serving payload """ if len(self.get_result_probabilities()) != 0: from prescience_client.bean.serving.serving_payload_batch import ServingPayloadBatch batch = ServingPayloadBatch(model_id=self.get_model_id(), flow_type=self.flow_type, batch_serving_payload=[self], model_evaluator=self.model_evaluator, prescience=self.prescience) batch.show_result() else: TablePrinter.print_dict( title=f'PREDICTIONS RESULTS FROM \'{self.get_model_id()}\'', json_dict=self.get_result_dict()) return self
def show(self, output: OutputFormat = OutputFormat.TABLE): """ Show the current page on stdout """ if output == OutputFormat.JSON: print(json.dumps(self.json_dict)) else: table = TablePrinter.get_table(AlgorithmConfiguration, self.get_algorithm_list()) print( table.get_string( title=colored('ALGORITHMS', 'yellow', attrs=['bold']))) return self
def show(self, ouput: OutputFormat = OutputFormat.TABLE): """ Display the current configuration a a table in console standard output """ if ouput == OutputFormat.JSON: print(json.dumps(self.__dict__)) else: all_line = [ConfigLine(k, v) for k, v in self.projects.items()] [ line.set_seleted() for line in all_line if line.get_project() == self.get_current_project_name() ] table = TablePrinter.get_table(ConfigLine, all_line) print(table)
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)