|
@@ -11,6 +11,9 @@ import logging
|
|
logging.basicConfig(level = logging.INFO,format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
logging.basicConfig(level = logging.INFO,format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
import time
|
|
import time
|
|
|
|
|
|
|
|
+def log(msg):
|
|
|
|
+ logging.info(msg)
|
|
|
|
+
|
|
|
|
|
|
# 配置pandas依赖包
|
|
# 配置pandas依赖包
|
|
def include_package_path(res_name):
|
|
def include_package_path(res_name):
|
|
@@ -18,9 +21,10 @@ def include_package_path(res_name):
|
|
archive_files = get_cache_archive(res_name)
|
|
archive_files = get_cache_archive(res_name)
|
|
dir_names = sorted([os.path.dirname(os.path.normpath(f.name)) for f in archive_files
|
|
dir_names = sorted([os.path.dirname(os.path.normpath(f.name)) for f in archive_files
|
|
if '.dist_info' not in f.name], key=lambda v: len(v))
|
|
if '.dist_info' not in f.name], key=lambda v: len(v))
|
|
- sys.path.append(dir_names[0])
|
|
|
|
-
|
|
|
|
- return os.path.dirname(dir_names[0])
|
|
|
|
|
|
+ _path = dir_names[0].split(".zip/files")[0]+".zip/files"
|
|
|
|
+ log("add path:%s"%(_path))
|
|
|
|
+ sys.path.append(_path)
|
|
|
|
+ return _path
|
|
|
|
|
|
# 可能出现类似RuntimeError: xxx has been blocked by sandbox
|
|
# 可能出现类似RuntimeError: xxx has been blocked by sandbox
|
|
# 这是因为包含C的库,会被沙盘block,可设置set odps.isolation.session.enable = true
|
|
# 这是因为包含C的库,会被沙盘block,可设置set odps.isolation.session.enable = true
|
|
@@ -67,8 +71,11 @@ def init_env(list_files,package_name):
|
|
def multiLoadEnv():
|
|
def multiLoadEnv():
|
|
def load_project():
|
|
def load_project():
|
|
start_time = time.time()
|
|
start_time = time.time()
|
|
- init_env(["BiddingKG.zip.env.baseline"],str(uuid.uuid4()))
|
|
|
|
|
|
+ ## init_env(["BiddingKG.zip.env.baseline"],str(uuid.uuid4()))
|
|
# init_env(["BiddingKG.zip.env.backup"],str(uuid.uuid4()))
|
|
# init_env(["BiddingKG.zip.env.backup"],str(uuid.uuid4()))
|
|
|
|
+ #改为zip引入
|
|
|
|
+ log("=======")
|
|
|
|
+ include_package_path("BiddingKG.baseline.zip")
|
|
logging.info("init biddingkg.zip.env.line cost %d"%(time.time()-start_time))
|
|
logging.info("init biddingkg.zip.env.line cost %d"%(time.time()-start_time))
|
|
|
|
|
|
def load_vector():
|
|
def load_vector():
|
|
@@ -113,26 +120,29 @@ class Extract(BaseUDTF):
|
|
|
|
|
|
multiLoadEnv()
|
|
multiLoadEnv()
|
|
|
|
|
|
- # logging.info("time5"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
- # import BiddingKG.dl.interface.predictor as predictor
|
|
|
|
- # logging.info("time6"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
- # import BiddingKG.dl.interface.Entitys as Entitys
|
|
|
|
- # logging.info("time6.1"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
- # import BiddingKG.dl.interface.getAttributes as getAttributes
|
|
|
|
- # logging.info("time6.2"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
- # import BiddingKG.dl.entityLink.entityLink as entityLink
|
|
|
|
- # logging.info("time6.2"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
- # import BiddingKG.dl.interface.Preprocessing as Preprocessing
|
|
|
|
- # logging.info("time6.3"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
-
|
|
|
|
|
|
+ import BiddingKG.dl.common.nerUtils
|
|
|
|
+ log("time5"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
+ import BiddingKG.dl.interface.predictor as predictor
|
|
|
|
+ log("time6"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
+ import BiddingKG.dl.interface.Entitys as Entitys
|
|
|
|
+ log("time6.1"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
+ import BiddingKG.dl.interface.getAttributes as getAttributes
|
|
|
|
+ log("time6.2"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
+ import BiddingKG.dl.entityLink.entityLink as entityLink
|
|
|
|
+ log("time6.2"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
+ import BiddingKG.dl.interface.Preprocessing as Preprocessing
|
|
|
|
+ log("time6.3"+str(datetime.datetime.now().strftime('%y-%m-%d %H:%M:%S')))
|
|
|
|
+
|
|
|
|
+ log("=======")
|
|
|
|
+ time.sleep(5)
|
|
from BiddingKG.dl.interface.extract import predict as predict
|
|
from BiddingKG.dl.interface.extract import predict as predict
|
|
|
|
+ log("=======import done")
|
|
import json
|
|
import json
|
|
|
|
|
|
- from BiddingKG.dl.common.Utils import log
|
|
|
|
import numpy as np
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
- global predictor,Entitys,getAttributes,entityLink,json,MyEncoder,Preprocessing,log,MyEncoder,np,predict
|
|
|
|
|
|
+ global predictor,Entitys,getAttributes,entityLink,json,MyEncoder,Preprocessing,MyEncoder,np,predict
|
|
class MyEncoder(json.JSONEncoder):
|
|
class MyEncoder(json.JSONEncoder):
|
|
|
|
|
|
def default(self, obj):
|
|
def default(self, obj):
|