提交 c8cec553 编写于 作者: 走神的阿圆's avatar 走神的阿圆

add convert

add timeout for request to resorce_list
上级 44c8ff50
...@@ -140,6 +140,9 @@ class ConvertCommand(BaseCommand): ...@@ -140,6 +140,9 @@ class ConvertCommand(BaseCommand):
self.module = args.module_name self.module = args.module_name
self.version = args.module_version if args.module_version is not None else '1.0.0' self.version = args.module_version if args.module_version is not None else '1.0.0'
self.src = args.model_dir self.src = args.model_dir
if not os.path.isdir(self.src):
print('`{}` is not exists or not a directory path'.format(self.src))
return False
self.dest = args.output_dir if args.output_dir is not None else os.path.join( self.dest = args.output_dir if args.output_dir is not None else os.path.join(
'{}_{}'.format(self.module, str(time.time()))) '{}_{}'.format(self.module, str(time.time())))
......
...@@ -250,9 +250,15 @@ class HubServer(object): ...@@ -250,9 +250,15 @@ class HubServer(object):
if not os.path.exists(CACHE_HOME): if not os.path.exists(CACHE_HOME):
utils.mkdir(CACHE_HOME) utils.mkdir(CACHE_HOME)
try: try:
r = requests.get(self.get_server_url() + '/' + 'search')
data = json.loads(r.text)
cache_path = os.path.join(CACHE_HOME, RESOURCE_LIST_FILE) cache_path = os.path.join(CACHE_HOME, RESOURCE_LIST_FILE)
if os.path.exists(cache_path):
r = requests.get(
self.get_server_url() + '/' + 'search', timeout=0.5)
else:
r = requests.get(
self.get_server_url() + '/' + 'search', timeout=8)
data = json.loads(r.text)
with open(cache_path, 'w+') as fp: with open(cache_path, 'w+') as fp:
yaml.safe_dump({'resource_list': data['data']}, fp) yaml.safe_dump({'resource_list': data['data']}, fp)
return True return True
......
...@@ -13,5 +13,5 @@ ...@@ -13,5 +13,5 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" PaddleHub version string """ """ PaddleHub version string """
hub_version = "1.8.1" hub_version = "1.8.3"
module_proto_version = "1.0.0" module_proto_version = "1.0.0"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册