本文整理汇总了Python中mrjob.emr.EMRJobRunner.get_contents_as_string方法的典型用法代码示例。如果您正苦于以下问题:Python EMRJobRunner.get_contents_as_string方法的具体用法?Python EMRJobRunner.get_contents_as_string怎么用?Python EMRJobRunner.get_contents_as_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mrjob.emr.EMRJobRunner
的用法示例。
在下文中一共展示了EMRJobRunner.get_contents_as_string方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from mrjob.emr import EMRJobRunner [as 别名]
# 或者: from mrjob.emr.EMRJobRunner import get_contents_as_string [as 别名]
def main():
#first run the initializer to get starting centroids
filePath = '/home/mike-bowles/pyWorkspace/mapReducers/src/kMeans3/input.txt'
#mrJob = MRkMeansInit(args=[filePath])
#mrJob = MRkMeansInit(args=['-r', 'emr', filePath])
#with mrJob.make_runner() as runner:
# runner.run()
#pull out the centroid values to compare with values after one iteration
centPath = "s3://mike-mrjob/kMeans/centroids/intermediateResults.txt"
key = EMRJobRunner().get_s3_key(centPath)
centroidsJson = key.get_contents_as_string()
delta = 10
#Begin iteration on change in centroids
while delta > 0.01:
#parse old centroid values
oldCentroids = json.loads(centroidsJson)
#run one iteration
mrJob2 = MRkMeansIter(args=['-r', 'emr', filePath])
with mrJob2.make_runner() as runner:
runner.run()
#compare new centroids to old ones
centroidsJson = key.get_contents_as_string()
newCentroids = json.loads(centroidsJson)
kMeans = len(newCentroids)
delta = 0.0
for i in range(kMeans):
delta += dist(newCentroids[i],oldCentroids[i])
print delta