From 14013a2eba776225a3325e1a3e549b6cb6e18ee8 Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Thu, 26 Nov 2020 14:07:32 +0800 Subject: [PATCH] Remove prettytable in requirements.txt (#29100) --- python/paddle/fluid/contrib/model_stat.py | 15 ++++++++++++++- python/requirements.txt | 1 - 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/contrib/model_stat.py b/python/paddle/fluid/contrib/model_stat.py index 0d974c8d96..ca4bfac5ba 100644 --- a/python/paddle/fluid/contrib/model_stat.py +++ b/python/paddle/fluid/contrib/model_stat.py @@ -34,7 +34,6 @@ Example: Total FLOPs: 11692747751(11.69G) ''' from collections import OrderedDict -from prettytable import PrettyTable def summary(main_prog): @@ -149,6 +148,8 @@ def _format_summary(collected_ops_list): summary_table: summary report format total: sum param and flops ''' + _verify_dependent_package() + summary_table = PrettyTable( ["No.", "TYPE", "INPUT", "OUTPUT", "PARAMs", "FLOPs"]) summary_table.align = 'r' @@ -176,6 +177,18 @@ def _format_summary(collected_ops_list): return summary_table, total +def _verify_dependent_package(): + """ + Verify whether `prettytable` is installed. + """ + try: + from prettytable import PrettyTable + except ImportError: + raise ImportError( + "paddle.summary() requires package `prettytable`, place install it firstly using `pip install prettytable`. " + ) + + def _print_summary(summary_table, total): ''' Print all the summary on terminal. diff --git a/python/requirements.txt b/python/requirements.txt index 12f36b3708..a879ead685 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -11,6 +11,5 @@ rarfile Pillow six decorator -prettytable astor pathlib -- GitLab