I attempted to do the following with the expectation that after 10 seconds the first task would release the resource and allow the second task to run in parallel:
import luigi
class Y(luigi.Task):
wait = luigi.IntParameter(default=10)
n = luigi.IntParameter()
resources = ({'A': 1})
def output(self):
return luigi.LocalTarget('out{}.txt'.format(self.n))
def run(self):
sleep(self.wait)
self.decrease_running_resources({'A': 0})
sleep(self.wait)
f = self.output().open('w')
f.close()
class Z(luigi.WrapperTask):
tasks = [Y(n=x) for x in range(20)]
def requires(self):
yield self.tasks
$ luigid
$ luigi --module x Z --workers 20
I have zero experience with luigi resources. I could look into this more, but the time is not available at this moment.
Looks like @riga and @daveFNbuck have contributed to this feature. Maybe they can help!
"Decrease" naturally acts as "minus". I think you made this oversight. You probably wanted
self.decrease_running_resources({'A': 1})
Happy plumbing! :)
Anyway I could help by updating the documentation to make it more clear?
In general, PRs to improve Luigi documentation clarity are invited :) @tiamot
Most helpful comment
"Decrease" naturally acts as "minus". I think you made this oversight. You probably wanted
Happy plumbing! :)