From 2ec6b6f10e61f08a52406bfa3f90e0b5e9dc72f0 Mon Sep 17 00:00:00 2001 From: zhiboniu <31800336+zhiboniu@users.noreply.github.com> Date: Fri, 7 May 2021 19:53:51 +0800 Subject: [PATCH] remove packages in __all__ (#32757) * remove packages in __all__ * create new public api level paddle.callbacks;paddle.hub;paddle.utils.unique_name --- python/paddle/__init__.py | 6 ++---- python/paddle/callbacks.py | 31 ++++++++++++++++++++++++++++++ python/paddle/hapi/callbacks.py | 5 +---- python/paddle/hub.py | 21 ++++++++++++++++++++ python/paddle/nn/__init__.py | 2 -- python/paddle/utils/__init__.py | 11 +++-------- python/paddle/utils/download.py | 2 +- python/paddle/utils/unique_name.py | 21 ++++++++++++++++++++ 8 files changed, 80 insertions(+), 19 deletions(-) create mode 100644 python/paddle/callbacks.py create mode 100644 python/paddle/hub.py create mode 100644 python/paddle/utils/unique_name.py diff --git a/python/paddle/__init__.py b/python/paddle/__init__.py index 054fcdfcbe6..ee4dcaa8979 100755 --- a/python/paddle/__init__.py +++ b/python/paddle/__init__.py @@ -269,10 +269,10 @@ from .fluid.layers import crop_tensor as crop # noqa: F401 # high-level api from .hapi import Model # noqa: F401 -from .hapi import callbacks # noqa: F401 +from . import callbacks # noqa: F401 from .hapi import summary # noqa: F401 from .hapi import flops # noqa: F401 -from .hapi import hub # noqa: F401 +from . import hub # noqa: F401 import paddle.text # noqa: F401 import paddle.vision # noqa: F401 @@ -335,10 +335,8 @@ __all__ = [ #noqa 'unsqueeze_', 'argmax', 'Model', - 'callbacks', 'summary', 'flops', - 'hub', 'sort', 'split', 'logical_and', diff --git a/python/paddle/callbacks.py b/python/paddle/callbacks.py new file mode 100644 index 00000000000..08fab3e0adb --- /dev/null +++ b/python/paddle/callbacks.py @@ -0,0 +1,31 @@ +# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .hapi.callbacks import Callback # noqa: F401 +from .hapi.callbacks import ProgBarLogger # noqa: F401 +from .hapi.callbacks import ModelCheckpoint # noqa: F401 +from .hapi.callbacks import VisualDL # noqa: F401 +from .hapi.callbacks import LRScheduler # noqa: F401 +from .hapi.callbacks import EarlyStopping # noqa: F401 +from .hapi.callbacks import ReduceLROnPlateau # noqa: F401 + +__all__ = [ #noqa + 'Callback', + 'ProgBarLogger', + 'ModelCheckpoint', + 'VisualDL', + 'LRScheduler', + 'EarlyStopping', + 'ReduceLROnPlateau' +] diff --git a/python/paddle/hapi/callbacks.py b/python/paddle/hapi/callbacks.py index cd4b35ea29a..61ae8b42d63 100644 --- a/python/paddle/hapi/callbacks.py +++ b/python/paddle/hapi/callbacks.py @@ -25,10 +25,7 @@ from paddle.utils import try_import from .progressbar import ProgressBar -__all__ = [ - 'Callback', 'ProgBarLogger', 'ModelCheckpoint', 'VisualDL', 'LRScheduler', - 'EarlyStopping', 'ReduceLROnPlateau' -] +__all__ = [] def config_callbacks(callbacks=None, diff --git a/python/paddle/hub.py b/python/paddle/hub.py new file mode 100644 index 00000000000..acdb28cb6f0 --- /dev/null +++ b/python/paddle/hub.py @@ -0,0 +1,21 @@ +# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .hapi.hub import list # noqa: F401 +from .hapi.hub import help # noqa: F401 +from .hapi.hub import load # noqa: F401 + +__all__ = [ #noqa + 'list', 'help', 'load' +] diff --git a/python/paddle/nn/__init__.py b/python/paddle/nn/__init__.py index 4e4669892b0..b5a6a5ca073 100644 --- a/python/paddle/nn/__init__.py +++ b/python/paddle/nn/__init__.py @@ -232,10 +232,8 @@ __all__ = [ #noqa 'MaxPool3D', 'AdaptiveMaxPool2D', 'Hardshrink', - 'clip', 'Softplus', 'KLDivLoss', - 'clip_by_norm', 'AvgPool2D', 'L1Loss', 'LeakyReLU', diff --git a/python/paddle/utils/__init__.py b/python/paddle/utils/__init__.py index 40c9d415e11..c23841ea8b8 100644 --- a/python/paddle/utils/__init__.py +++ b/python/paddle/utils/__init__.py @@ -19,18 +19,13 @@ 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 . import unique_name # noqa: F401 from ..fluid.framework import require_version # noqa: F401 from . import download # noqa: F401 from . import image_util # noqa: F401 from . import cpp_extension # noqa: F401 -__all__ = [ #noqa - 'deprecated', - 'download', - 'run_check', - 'unique_name', - 'require_version', - 'try_import' +__all__ = [ #noqa + 'deprecated', 'run_check', 'require_version', 'try_import' ] diff --git a/python/paddle/utils/download.py b/python/paddle/utils/download.py index ddd1dad9dbd..dda8abeff21 100644 --- a/python/paddle/utils/download.py +++ b/python/paddle/utils/download.py @@ -55,7 +55,7 @@ except: import logging logger = logging.getLogger(__name__) -__all__ = [] +__all__ = ['get_weights_path_from_url'] WEIGHTS_HOME = osp.expanduser("~/.cache/paddle/hapi/weights") diff --git a/python/paddle/utils/unique_name.py b/python/paddle/utils/unique_name.py new file mode 100644 index 00000000000..d0d487c933d --- /dev/null +++ b/python/paddle/utils/unique_name.py @@ -0,0 +1,21 @@ +# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ..fluid.unique_name import generate # noqa: F401 +from ..fluid.unique_name import switch # noqa: F401 +from ..fluid.unique_name import guard # noqa: F401 + +__all__ = [ #noqa + 'generate', 'switch', 'guard' +] -- GitLab