PageRank运行出错

36 views
Skip to first unread message

Jet Zheung

unread,
Oct 21, 2013, 6:40:38 AM10/21/13
to dpark...@googlegroups.com
运行examples目录中的示例,pagerank抛出Exception: exception:iteration over non-sequence,是在第0个超级步运行完毕后抛出的,何解?


田忠博

unread,
Oct 21, 2013, 8:01:41 AM10/21/13
to dpark...@googlegroups.com
不好意思,这个问题是由于前面dpark在重构Bagel相关API的时候没有更新这个example.
下面是修复这个问题的补丁,请帮忙看看是否可以修正您的问题。github上的修复会在下一次dpark更新时修正:

diff --git a/examples/pagerank.py b/examples/pagerank.py
index 6af5ade..aab7d1a 100755
--- a/examples/pagerank.py
+++ b/examples/pagerank.py
@@ -3,7 +3,7 @@ import sys, os.path
 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
 from dpark import DparkContext
-from dpark.bagel import Vertex, Edge, Message, Bagel
+from dpark.bagel import Vertex, Edge, Bagel
 
 def parse_vertex(line, numV):
     fields = line.split(' ')
@@ -18,7 +18,7 @@ def gen_compute(num, epsilon):
         else:
             newValue = self.value
         terminate = (superstep >= 10 and abs(newValue-self.value) < epsilon) or superstep > 30
-        outbox = [Message(edge.target_id, newValue / len(self.outEdges))
+        outbox = [(edge.target_id, newValue / len(self.outEdges))
                 for edge in self.outEdges] if not terminate else []
         return Vertex(self.id, newValue, self.outEdges, not terminate), outbox
     return compute
@@ -37,5 +37,5 @@ if __name__ == '__main__':
     result = Bagel.run(dpark, vertices, messages,
         gen_compute(numVertex, epsilon))
 
-    for v in result.filter(lambda x:x.value > threshold).collect():
-        print v.id, v.value
+    for id, v in result.filter(lambda (id, v): v.value>threshold).collect():
+        print id, v



2013/10/21 Jet Zheung <jet.z...@gmail.com>
运行examples目录中的示例,pagerank抛出Exception: exception:iteration over non-sequence,是在第0个超级步运行完毕后抛出的,何解?


--
You received this message because you are subscribed to the Google Groups "DPark Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dpark-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jet Zheung

unread,
Oct 21, 2013, 8:58:00 AM10/21/13
to dpark...@googlegroups.com
Thanks,这个例子已经正常运行了。

不过还有例子也有问题,比如dsgd.py,里面使用到了Broadcast类,该类中有 if not self.cache.put(self.uuid, value):....,而Cache类中put方法有一个参数是is_iterator,默认为False,但dsgd.py调用时传入是个列表,结果没有转换会报错。

PS: 我觉得吧,例子应该是在每次更新代码后保证能运行的,一般来说,对于新学习的项目,肯定先运行自带的示例,错误太多的话挫败感油然而生...^_^.。

在 2013年10月21日星期一UTC+8下午8时01分41秒,田忠博写道:
Message has been deleted

田忠博

unread,
Oct 21, 2013, 11:53:27 PM10/21/13
to dpark...@googlegroups.com
Hi Jet,
    不好意思,回复晚了。dsgd这个例子的问题的确存在,但是并不是is_iterator的问题,而是对put的返回值判断应该判断是否为None。这个问题会近期修复。另外dsgd这个例子恐怕是没办法在单机模式运行的,比需要在mesos模式下运行。因为他依赖的mutable_dict依赖executor上的基础架构。

    mutable_dict是dpark最近增加的一个共享网络存储模型,但是可能在很多地方还不完善,我们还在努力的让他变得更加好用。

    多谢你的反馈,他们都很有价值,谢谢。





2013/10/21 Jet Zheung <jet.z...@gmail.com>
Thanks,这个例子已经正常运行了。

不过还有例子也有问题,比如dsgd.py,里面使用到了Broadcast类,该类中有 if not self.cache.put(self.uuid, value):....,而Cache类中put方法有一个参数是is_iterator,默认为False,但dsgd.py调用时传入是个列表,结果没有转换会报错。

PS: 我觉得吧,例子应该是在每次更新代码后保证能运行的,一般来说,对于新学习的项目,肯定先运行自带的示例,错误太多的话挫败感油然而生...^_^.。

在 2013年10月21日星期一UTC+8下午8时01分41秒,田忠博写道:
不好意思,这个问题是由于前面dpark在重构Bagel相关API的时候没有更新这个example.
Reply all
Reply to author
Forward
0 new messages