[GRASS-dev] pyGRASS: ParallelModuleQueue

Sören Gebbert soerengebbert at googlemail.com
Wed Nov 30 05:15:07 PST 2016


2016-11-30 13:59 GMT+01:00 Martin Landa <landa.martin at gmail.com>:

> Hi,
>
> 2016-11-30 13:29 GMT+01:00 Martin Landa <landa.martin at gmail.com>:
> > Wouldn't make sense to add something like _progress=True. Then module
> > could call msgr.percent() automatically when it finish.
> >
> > queue.percent(5, count) # print each 5%
> > module = Module(..., _run=False, _progress=5)
> > for ... in ...:
> > ...
> > queue.wait()
>
> another possibility would be to define own function, eg.
>
> def process(i, n, count):
>     Module(..., _run=True, quiet=True)
>     msgr.percent(i, n, count)
>

Maybe you can implement a derivative from the Module class and implement
the required behaviour there?


>
> Similar approach could be useful when for example applying mask and
> doing some processing for each scene with multiple bands.
>
> But such function cannot be used together with ParallelModuleQueue. Or
> am I wrong? Ma
>

I am not sure if i understand you correctly. But you can use
the MultiModule[1] class to specify a stack of modules that should be run
in serial order. Several MultiModule objects can be run in parallel by the
ParallelModuleQueue. However, setting a mask in one module will affect all
other modules that are running in parallel as well, since they are running
in the same mapset. Changing the region in each stack is no problem, since
the MultiModule class provides a dedicated region environment that does not
affect other parallel running modules in the same mapset.

Ciao
Sören

[1]
https://grass.osgeo.org/grass73/manuals/libpython/_modules/pygrass/modules/interface/module.html#MultiModule

>
> --
> Martin Landa
> http://geo.fsv.cvut.cz/gwiki/Landa
> http://gismentors.cz/mentors/landa
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20161130/8488d93b/attachment.html>


More information about the grass-dev mailing list