4

networkxに有向非循環グラフがあります。各ノードはタスクを表し、ノードの先行タスクはタスクの依存性です(特定のタスクは依存性が実行されるまで実行できません)。Networkxをタスクキューとして使用しますか?

celeryが提供するものと同様に(つまり、ジョブのステータスをポーリングして結果を取得できるように)、非同期タスクキューでグラフを '実行'したいと考えています。セロリは、すべての依存関係が完了するとすぐにDAG(私が知る限り)を作成し、taskに移動する能力を持つ能力を提供しません(DAGには複数のパスがあり、1つのタスクが遅い/他のタスクなどに移動することも可能です)。

これを達成する方法について簡単な例がありますか、networkxceleryを統合することすらできますか?

+2

DASKと呼ばれるものを使用すると、検索することができる。http://dask.pydata.org/en/latest/custom-graphs.html?highlight=graph – denfromufa

答えて

0

私はこの機能が役立つかもしれないと思う:

# The graph G is represened by a dictionnary following this pattern: 
    # G = { vertex: [ (successor1: weight1), (successor2: weight2),... ] } 
    def progress (G, start): 
    Q = [ start ] # contain tasks to execute 
    done = [ ] # contain executed tasks 
    while len (Q) > 0: # still there tasks to execute ? 
     task = Q.pop(0) # pick up the oldest one 
     ready = True 
     for T in G:  # make sure all predecessors are executed 
      for S, w in G[T]: 
       if S == task and and S not in done:# found not executed predecessor 
       ready = False 
       break 
      if not ready : break 
     if not ready: 
      Q.appen(task) # the task is not ready for execution 
     else: 
      execute(task) 
      done.appen(task) # execute the task 
      for S, w in G[task]:# and explore all its successors 
       Q.append(S) 
+0

いずれのタスクも実行することはありません。 –

関連する問題