From 0bc97e92b83c66104df6f48e357b8543def1e72c Mon Sep 17 00:00:00 2001 From: zhiboniu <31800336+zhiboniu@users.noreply.github.com> Date: Tue, 27 Apr 2021 09:48:13 +0800 Subject: [PATCH] update 2.0 public api in utils (#32008) --- python/paddle/utils/__init__.py | 36 ++++++++++--------- python/paddle/utils/cpp_extension/__init__.py | 26 +++++++------- python/paddle/utils/download.py | 2 -- python/paddle/utils/install_check.py | 2 -- python/paddle/utils/op_version.py | 2 -- python/paddle/utils/profiler.py | 19 ++++++++-- 6 files changed, 50 insertions(+), 37 deletions(-) diff --git a/python/paddle/utils/__init__.py b/python/paddle/utils/__init__.py index d32fa4c88c4..40c9d415e11 100644 --- a/python/paddle/utils/__init__.py +++ b/python/paddle/utils/__init__.py @@ -12,21 +12,25 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .profiler import ProfilerOptions -from .profiler import Profiler -from .profiler import get_profiler -from .deprecated import deprecated -from .lazy_import import try_import -from .op_version import OpLastCheckpointChecker -from .install_check import run_check -from ..fluid.framework import unique_name -from ..fluid.framework import require_version +from .profiler import ProfilerOptions # noqa: F401 +from .profiler import Profiler # noqa: F401 +from .profiler import get_profiler # noqa: F401 +from .deprecated import deprecated # noqa: F401 +from .lazy_import import try_import # noqa: F401 +from .op_version import OpLastCheckpointChecker # noqa: F401 +from .install_check import run_check # noqa: F401 +from ..fluid.framework import unique_name # noqa: F401 +from ..fluid.framework import require_version # noqa: F401 -from . import download +from . import download # noqa: F401 +from . import image_util # noqa: F401 +from . import cpp_extension # noqa: F401 -from . import cpp_extension - -__all__ = ['dump_config', 'deprecated', 'download', 'run_check'] - -#TODO: define new api under this directory -__all__ += ['unique_name', 'require_version'] +__all__ = [ #noqa + 'deprecated', + 'download', + 'run_check', + 'unique_name', + 'require_version', + 'try_import' +] diff --git a/python/paddle/utils/cpp_extension/__init__.py b/python/paddle/utils/cpp_extension/__init__.py index 130ab79b303..cef2716b7f3 100644 --- a/python/paddle/utils/cpp_extension/__init__.py +++ b/python/paddle/utils/cpp_extension/__init__.py @@ -12,18 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .cpp_extension import CUDAExtension -from .cpp_extension import CppExtension -from .cpp_extension import BuildExtension -from .cpp_extension import load, setup +from .cpp_extension import CUDAExtension # noqa: F401 +from .cpp_extension import CppExtension # noqa: F401 +from .cpp_extension import BuildExtension # noqa: F401 +from .cpp_extension import load # noqa: F401 +from .cpp_extension import setup # noqa: F401 -from .extension_utils import parse_op_info -from .extension_utils import get_build_directory -from .extension_utils import load_op_meta_info_and_register_op +from .extension_utils import parse_op_info # noqa: F401 +from .extension_utils import get_build_directory # noqa: F401 +from .extension_utils import load_op_meta_info_and_register_op # noqa: F401 -from . import cpp_extension -from . import extension_utils - -__all__ = [ - 'CppExtension', 'CUDAExtension', 'load', 'setup', 'get_build_directory' +__all__ = [ #noqa + 'CppExtension', + 'CUDAExtension', + 'load', + 'setup', + 'get_build_directory' ] diff --git a/python/paddle/utils/download.py b/python/paddle/utils/download.py index dda8abeff21..bd70013e112 100644 --- a/python/paddle/utils/download.py +++ b/python/paddle/utils/download.py @@ -55,8 +55,6 @@ except: import logging logger = logging.getLogger(__name__) -__all__ = ['get_weights_path_from_url'] - WEIGHTS_HOME = osp.expanduser("~/.cache/paddle/hapi/weights") DOWNLOAD_RETRY_LIMIT = 3 diff --git a/python/paddle/utils/install_check.py b/python/paddle/utils/install_check.py index b39009985e7..5d70cf61007 100644 --- a/python/paddle/utils/install_check.py +++ b/python/paddle/utils/install_check.py @@ -20,8 +20,6 @@ import numpy as np import paddle -__all__ = ['run_check'] - def _simple_network(): """ diff --git a/python/paddle/utils/op_version.py b/python/paddle/utils/op_version.py index 68acc9de081..a1fa230d64f 100644 --- a/python/paddle/utils/op_version.py +++ b/python/paddle/utils/op_version.py @@ -14,8 +14,6 @@ from ..fluid import core -__all__ = ['OpLastCheckpointChecker'] - def Singleton(cls): _instance = {} diff --git a/python/paddle/utils/profiler.py b/python/paddle/utils/profiler.py index 89c0d2cac68..cc33342ec5a 100644 --- a/python/paddle/utils/profiler.py +++ b/python/paddle/utils/profiler.py @@ -18,9 +18,22 @@ import sys import warnings from ..fluid import core -from ..fluid.profiler import * - -__all__ = ['ProfilerOptions', 'Profiler', 'get_profiler'] +from ..fluid.profiler import cuda_profiler # noqa: F401 +from ..fluid.profiler import start_profiler +from ..fluid.profiler import profiler # noqa: F401 +from ..fluid.profiler import stop_profiler +from ..fluid.profiler import reset_profiler + +__all__ = [ #noqa + 'Profiler', + 'get_profiler', + 'ProfilerOptions', + 'cuda_profiler', + 'start_profiler', + 'profiler', + 'stop_profiler', + 'reset_profiler' +] class ProfilerOptions(object): -- GitLab