提交 ccde3771 编写于 作者: T TomorrowIsAnOtherDay

fix workspace bug

上级 b56914ac
......@@ -272,6 +272,7 @@ class Job(object):
os.makedirs(os.path.join(*file.rsplit('/')[:-1]))
except OSError as e:
pass
file = os.path.join(envdir, file)
with open(file, 'wb') as f:
f.write(content)
logger.info('[job] reply')
......@@ -350,6 +351,7 @@ class Job(object):
# receive source code from the actor and append them to the environment variables.
envdir = self.wait_for_files(reply_socket, job_address)
sys.path.append(envdir)
os.chdir(envdir)
obj = self.wait_for_connection(reply_socket)
assert obj is not None
......
......@@ -44,7 +44,7 @@ def simplify_code(code, end_of_file):
def load_remote_class(file_name, class_name, end_of_file):
"""
"""
load a class given its file_name and class_name.
Args:
......@@ -55,13 +55,14 @@ def load_remote_class(file_name, class_name, end_of_file):
Return:
cls: the class to load
"""
with open(file_name) as t_file:
with open(file_name + '.py') as t_file:
code = t_file.readlines()
code = simplify_code(code)
tmp_file_name = 'xparl_' + file_name
code = simplify_code(code, end_of_file)
module_name = 'xparl_' + file_name
tmp_file_name = 'xparl_' + file_name + '.py'
with open(tmp_file_name, 'w') as t_file:
for line in code:
t_file.write(line)
mod = __import__(tmp_file_name)
cls = getattr(mod, class_name)._original
mod = __import__(module_name)
cls = getattr(mod, class_name)
return cls
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册