From abf5bce4a5db12cf3ca093abc26dcd270e222c0b Mon Sep 17 00:00:00 2001 From: lyuwenyu Date: Wed, 12 May 2021 10:27:36 +0800 Subject: [PATCH] update --- hubconf.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hubconf.py b/hubconf.py index 2ebfd23d..6e580761 100644 --- a/hubconf.py +++ b/hubconf.py @@ -20,17 +20,20 @@ import sys class _SysPathG(object): + def __init__(self, path): + self.path = path + def __enter__(self, ): - sys.path.insert(0, - os.path.join( - os.path.dirname(os.path.abspath(__file__)), - 'ppcls', 'modeling')) + sys.path.insert(0, self.path) def __exit__(self, type, value, traceback): - sys.path.pop(0) + _p = sys.path.pop(0) + assert _p == self.path, 'make sure pop {} correctly.'.format(self.path) -with _SysPathG(): +with _SysPathG( + os.path.join( + os.path.dirname(os.path.abspath(__file__)), 'ppcls', 'modeling')): import architectures def _load_pretrained_parameters(model, name): -- GitLab