2016-10-24 21 views
3

失敗したタスクが数回再試行されるように、Luigiの再試行メカニズムを設定しようとしています。タスクが正常に再試行されている間しかし、ルイージは失敗し終了します。Luigiタスクの再試行を正しく設定するにはどうすればよいですか?

===== Luigi Execution Summary ===== 

Scheduled 3 tasks of which: 
* 2 ran successfully: 
    - 1 FailOnceThenSucceed(path=/tmp/job-id-18.subtask) 
    - 1 MasterTask(path=/tmp/job-id-18) 
* 1 failed: 
    - 1 FailOnceThenSucceed(path=/tmp/job-id-18.subtask) 

This progress looks :(because there were failed tasks 

そこで質問です:タスクが一度失敗したときにようにどのように私は、(私はピップインストールしてバージョン2.3.3がインストールされている)ルイジを設定します成功した場合、LuigiはThis progress looks :(で失敗するのではなく、This progress looks :)で正常に終了しますか?ここで

は、私が作ってみた最小限のスケジューラと労働者設定であるだけでなく、タスクが動作を実証する:

[scheduler] 
retry_count = 3 
retry-delay = 1 

[worker] 
keep_alive=true 

mytasks.py:

import luigi 


class FailOnceThenSucceed(luigi.Task): 
    path = luigi.Parameter() 

    def output(self): 
     return luigi.LocalTarget(self.path) 

    def run(self): 
     failmarker = luigi.LocalTarget(self.path + ".hasfailedonce") 
     if failmarker.exists(): 
      with self.output().open('w') as target: 
       target.write('OK') 
     else: 
      with failmarker.open('w') as marker: 
       marker.write('Failed') 
      raise RuntimeError("Failed once") 


class MasterTask(luigi.Task): 
    path = luigi.Parameter() 

    def requires(self): 
     return FailOnceThenSucceed(path=self.path + '.subtask') 

    def output(self): 
     return luigi.LocalTarget(self.path) 

    def run(self): 
     with self.output().open('w') as target: 
      target.write('OK') 

例の実行:

PYTHONPATH=. luigi --module mytasks MasterTask --workers=2 --path='/tmp/job-id-18'

答えて

0

これはLuigiの古い問題です。私はすなわちピップインストール、最新のルイジ・バージョンにアップグレードすることをお勧め https://github.com/spotify/luigi/releases/tag/2.7.2

https://github.com/spotify/luigi/issues/1932

これはバージョン2.7.2で修正されました:ULは、タスクが失敗してから再試行に成功した時にそのようにマークされませんでした再試行しましたルイジ。

関連する問題