def loadTask(filename):
try:
with open(filename, 'rb') as task:
try:
header = task.readline().decode()
if header.startswith('SOSTASK1.1'):
# ignore the tags
task.readline()
return pickle.load(task)
elif header.startswith('SOSTASK1.2'):
task.readline()
try:
return pickle.loads(lzma.decompress(task.read()))
except:
# at some point, the task files were compressed with zlib
import zlib
return pickle.loads(zlib.decompress(task.read()))
else:
raise ValueError('Try old format')
except:
# old format
task.seek(0)
param = pickle.load(task)
# old format does not have tags
param.tags = []
return param
except ImportError as e:
raise RuntimeError(
f'Failed to load task {os.path.basename(filename)}, which is likely caused by incompatible python modules between local and remote hosts: {e}')
评论列表
文章目录