From d4d6beb2469b438c9ff144c2dd14daf467c1b80e Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Wed, 30 Oct 2019 11:15:33 +0800 Subject: [PATCH] Only check requirements in `configure.py` (#6) to avoid cycle import when required packages are not installed --- ppdet/core/config/schema.py | 23 ++--------------------- tools/configure.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/ppdet/core/config/schema.py b/ppdet/core/config/schema.py index efba5be1d..4465c7306 100644 --- a/ppdet/core/config/schema.py +++ b/ppdet/core/config/schema.py @@ -23,32 +23,13 @@ import re try: from docstring_parser import parse as doc_parse except Exception: - def doc_parse(*args): - if not doc_parse.__warning_sent__: - from ppdet.utils.cli import ColorTTY - color_tty = ColorTTY() - message = "docstring_parser is not installed, " \ - + "argument description is not available" - print(color_tty.yellow(message)) - doc_parse.__warning_sent__ = True - - doc_parse.__warning_sent__ = False - + pass try: from typeguard import check_type except Exception: - def check_type(*args): - if not check_type.__warning_sent__: - from ppdet.utils.cli import ColorTTY - color_tty = ColorTTY() - message = "typeguard is not installed," \ - + "type checking is not available" - print(color_tty.yellow(message)) - check_type.__warning_sent__ = True - - check_type.__warning_sent__ = False + pass __all__ = ['SchemaValue', 'SchemaDict', 'SharedConfig', 'extract_schema'] diff --git a/tools/configure.py b/tools/configure.py index 560d16151..098f48f84 100644 --- a/tools/configure.py +++ b/tools/configure.py @@ -24,6 +24,20 @@ from ppdet.utils.cli import ColorTTY, print_total_cfg color_tty = ColorTTY() +try: + from docstring_parser import parse as doc_parse +except Exception: + message = "docstring_parser is not installed, " \ + + "argument description is not available" + print(color_tty.yellow(message)) + +try: + from typeguard import check_type +except Exception: + message = "typeguard is not installed," \ + + "type checking is not available" + print(color_tty.yellow(message)) + MISC_CONFIG = { "architecture": "", "max_iters": "", -- GitLab