本文整理汇总了Python中snakebite.client.Client.copyToLocal方法的典型用法代码示例。如果您正苦于以下问题:Python Client.copyToLocal方法的具体用法?Python Client.copyToLocal怎么用?Python Client.copyToLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snakebite.client.Client
的用法示例。
在下文中一共展示了Client.copyToLocal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTrainedModel
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import copyToLocal [as 别名]
def getTrainedModel(hdfsServer, modelFile):
hdfsPort = int(os.environ.get('HDFS_NAME_PORT', 8020))
modelSavePath = "/user/" + os.getenv('LOGNAME') + "/data/model/" + modelFile + '/'
# Load the saved model data
hdfs_client = Client(hdfsServer, hdfsPort)
filesInfo = hdfs_client.ls([modelSavePath])
# Copy HDFS files to local temp directory
# First clean up and recreate the temp folder
copyDir = tempfile.gettempdir() + "/" + modelFile
shutil.rmtree(copyDir, ignore_errors=True)
os.makedirs(copyDir)
res = hdfs_client.copyToLocal([f['path'] for f in filesInfo], copyDir)
for r in res:
if not r['result']:
print "Error: %s" % r
modelFilePath = copyDir + '/' + modelFile
print "Load model from %s" % modelFilePath
return joblib.load(modelFilePath)
示例2: getObjsBackend
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import copyToLocal [as 别名]
def getObjsBackend(objs, backend, config):
if(backend == 'hdfs'):
client = Client(socket.gethostname(), config['HADOOP_RPC_PORT'], use_trash=False)
for obj in objs:
try:
copy_gen = client.copyToLocal([obj[0]], obj[1])
for copy_item in copy_gen:
pass
except Exception as e:
print(e)
elif(backend == 'swift'):
options = {'os_auth_url': os.environ['OS_AUTH_URL'], 'os_username': os.environ['OS_USERNAME'], 'os_password': os.environ['OS_PASSWORD'], 'os_tenant_id': os.environ['OS_TENANT_ID'], 'os_tenant_name': os.environ['OS_TENANT_NAME']}
swiftService = SwiftService(options=options)
for obj in objs:
# Create the containers which are used in this application for Object Storage
if(obj[0] == 'sqlite.db'):
swiftService.post(container='containerFiles')
swiftService.post(container='containerFeatures')
swiftService.post(container='containerModules')
out_file = obj[1] # Get the output file location from runner
localoptions = {'out_file': out_file}
objects = []
objects.append(obj[0])
swiftDownload = swiftService.download(container='containerModules', objects=objects, options=localoptions)
for downloaded in swiftDownload:
if("error" in downloaded.keys()):
raise RuntimeError(downloaded['error'])
# print(downloaded)
elif(backend == 'nfs'): # Every file is already in respective local dirs
pass
示例3: Client
# 需要导入模块: from snakebite.client import Client [as 别名]
# 或者: from snakebite.client.Client import copyToLocal [as 别名]
from snakebite.client import Client
client = Client('localhost', 9000)
for f in client.copyToLocal(['/input/input.txt'], '/tmp'):
print f