Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
3802c07c
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3802c07c
编写于
1月 07, 2020
作者:
走神的阿圆
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add hub_name
上级
84c33d73
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
29 deletion
+37
-29
paddlehub/commands/config.py
paddlehub/commands/config.py
+0
-2
paddlehub/commands/serving.py
paddlehub/commands/serving.py
+3
-2
paddlehub/common/hub_server.py
paddlehub/common/hub_server.py
+1
-1
paddlehub/common/server_config.py
paddlehub/common/server_config.py
+5
-2
paddlehub/common/srv_utils.py
paddlehub/common/srv_utils.py
+28
-0
paddlehub/common/utils.py
paddlehub/common/utils.py
+0
-22
未找到文件。
paddlehub/commands/config.py
浏览文件 @
3802c07c
...
...
@@ -25,7 +25,6 @@ import re
from
paddlehub.commands.base_command
import
BaseCommand
,
ENTRY
from
paddlehub.common.dir
import
CONF_HOME
from
paddlehub.common.server_config
import
default_server_config
from
paddlehub.common.hub_server
import
CacheUpdater
from
paddlehub.common.hub_server
import
HubServer
HubServer
()
...
...
@@ -102,7 +101,6 @@ class ConfigCommand(BaseCommand):
print
(
str
)
def
execute
(
self
,
argv
):
CacheUpdater
(
"hub_config"
).
start
()
args
=
self
.
parser
.
parse_args
()
if
args
.
option
is
None
:
ConfigCommand
.
show_config
()
...
...
paddlehub/commands/serving.py
浏览文件 @
3802c07c
...
...
@@ -239,8 +239,7 @@ class ServingCommand(BaseCommand):
StandaloneApplication
(
app
.
create_app
(
init_flag
=
False
,
configs
=
configs
),
options
).
run
()
@
staticmethod
def
start_single_app_with_file
(
configs
):
def
start_single_app_with_file
(
self
,
configs
):
use_gpu
=
configs
.
get
(
"use_gpu"
,
False
)
port
=
configs
.
get
(
"port"
,
8866
)
if
ServingCommand
.
is_port_occupied
(
"127.0.0.1"
,
port
)
is
True
:
...
...
@@ -251,6 +250,7 @@ class ServingCommand(BaseCommand):
module_info
=
ServingCommand
.
preinstall_modules
(
module
)
for
index
in
range
(
len
(
module_info
)):
configs
[
index
].
update
(
module_info
[
index
])
self
.
dump_pid_file
()
app
.
run
(
use_gpu
,
configs
=
configs
,
port
=
port
)
@
staticmethod
...
...
@@ -304,6 +304,7 @@ class ServingCommand(BaseCommand):
"queue_size"
:
20
})
for
item
in
module_info
]
self
.
dump_pid_file
()
app
.
run
(
use_gpu
,
configs
=
module_info
,
port
=
port
)
else
:
print
(
"Lack of necessary parameters!"
)
...
...
paddlehub/common/hub_server.py
浏览文件 @
3802c07c
...
...
@@ -33,7 +33,7 @@ from paddlehub.common.server_config import default_server_config
from
paddlehub.io.parser
import
yaml_parser
from
paddlehub.common.lock
import
lock
from
paddlehub.common.dir
import
CONF_HOME
,
CACHE_HOME
from
paddlehub.common.utils
import
ConfigInfo
from
paddlehub.common.
srv_
utils
import
ConfigInfo
RESOURCE_LIST_FILE
=
"resource_list_file.yml"
CACHE_TIME
=
60
*
10
...
...
paddlehub/common/server_config.py
浏览文件 @
3802c07c
...
...
@@ -11,14 +11,17 @@
# 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
paddlehub.common.utils
import
ConfigInfo
import
time
import
uuid
from
paddlehub.common.utils
import
md5
HUB_SERVERS
=
[
"http://paddlepaddle.org.cn/paddlehub"
]
hub_name
=
md5
(
str
(
uuid
.
uuid1
())[
-
12
:])
+
"-"
+
str
(
int
(
time
.
time
()))
default_server_config
=
{
"server_url"
:
HUB_SERVERS
,
"resource_storage_server_url"
:
"https://bj.bcebos.com/paddlehub-data/"
,
"debug"
:
False
,
"log_level"
:
"DEBUG"
,
"hub_name"
:
ConfigInfo
().
get_hub_name
()
"hub_name"
:
hub_name
}
paddlehub/common/srv_utils.py
浏览文件 @
3802c07c
...
...
@@ -15,8 +15,15 @@
import
requests
import
paddle
import
json
import
time
import
uuid
import
os
from
paddlehub
import
version
from
paddlehub.common.dir
import
CONF_HOME
from
paddlehub.common.decorator_utils
import
singleton
from
paddlehub.common.utils
import
md5
from
paddlehub.common.server_config
import
default_server_config
def
uri_path
(
server_url
,
api
):
...
...
@@ -37,3 +44,24 @@ def hub_request(api, params, extra=None, timeout=8):
params
[
"extra"
]
=
json
.
dumps
(
extra
)
r
=
requests
.
get
(
api
,
params
,
timeout
=
timeout
)
return
r
.
json
()
@
singleton
class
ConfigInfo
(
object
):
def
__init__
(
self
):
self
.
filepath
=
os
.
path
.
join
(
CONF_HOME
,
"config.json"
)
self
.
hub_name
=
None
self
.
configs
=
None
if
os
.
path
.
exists
(
self
.
filepath
):
with
open
(
self
.
filepath
,
"r"
)
as
fp
:
self
.
configs
=
json
.
load
(
fp
)
self
.
hub_name
=
self
.
configs
.
get
(
"hub_name"
,
None
)
def
get_hub_name
(
self
):
if
self
.
hub_name
is
None
:
self
.
hub_name
=
md5
(
str
(
uuid
.
uuid1
())[
-
12
:])
+
"-"
+
str
(
int
(
time
.
time
()))
with
open
(
self
.
filepath
,
"w"
)
as
fp
:
fp
.
write
(
json
.
dumps
(
default_server_config
))
return
self
.
hub_name
paddlehub/common/utils.py
浏览文件 @
3802c07c
...
...
@@ -22,16 +22,12 @@ import os
import
multiprocessing
import
hashlib
import
platform
import
uuid
import
json
import
paddle.fluid
as
fluid
import
six
from
paddlehub.module
import
module_desc_pb2
from
paddlehub.common.logger
import
logger
from
paddlehub.common.dir
import
CONF_HOME
from
paddlehub.common.decorator_utils
import
singleton
def
version_compare
(
version1
,
version2
):
...
...
@@ -59,24 +55,6 @@ def get_platform():
return
platform
.
platform
()
@
singleton
class
ConfigInfo
(
object
):
def
__init__
(
self
):
self
.
filepath
=
os
.
path
.
join
(
CONF_HOME
,
"config.json"
)
self
.
hub_name
=
None
self
.
configs
=
None
if
os
.
path
.
exists
(
self
.
filepath
):
with
open
(
self
.
filepath
,
"r"
)
as
fp
:
self
.
configs
=
json
.
load
(
fp
)
self
.
use_id
=
self
.
configs
.
get
(
"hub_name"
,
None
)
def
get_hub_name
(
self
):
if
self
.
hub_name
is
None
:
hub_name
=
uuid
.
UUID
(
int
=
uuid
.
getnode
()).
hex
[
-
12
:]
self
.
hub_name
=
md5
(
hub_name
)
return
self
.
hub_name
def
is_windows
():
return
get_platform
().
lower
().
startswith
(
"windows"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录