[GRASS-dev] [GRASS GIS] #3967: Add batch job example without path

GRASS GIS trac at osgeo.org
Fri Dec 6 13:29:51 PST 2019


#3967: Add batch job example without path
--------------------------+------------------------------------
  Reporter:  jidanni      |      Owner:  grass-dev@…
      Type:  enhancement  |     Status:  new
  Priority:  trivial      |  Milestone:
 Component:  Docs         |    Version:  unspecified
Resolution:               |   Keywords:  grass.py exec CLI init
       CPU:  Unspecified  |   Platform:  Unspecified
--------------------------+------------------------------------
Changes (by wenzeslaus):

 * keywords:   => grass.py exec CLI init


Comment:

 Actually, I did not include it into documentation intentionally, but did
 not disable it - a dirty trick. I don't know if it is a good idea to do
 this, but it might be useful for some. Generally speaking, why would you
 like to run a batch job with whatever was the last used mapset? Of course,
 `--exec` is meant to be used more broadly than just batch jobs, but still
 it seems to me that specifying full path is appropriate.

 If you would be using GRASS GIS only with `--exec`, this may not work as
 expected because `--exec` actually does not save the path (to a file in
 `~/.grass7`), so the next call is using path from an interactive session
 (in GUI or with `--text`).

 What you can do now is a workflow like this:

 {{{
 grass grassdata/location/mapset -c EPSG:3358 -e
 grass grassdata/location/mapset --exec r.import input=some_image.tif
 output=some_image
 grass grassdata/location/mapset --exec r.info some_image
 grass grassdata/location/mapset --exec r.mapcalc "improved_image = 5 *
 some_image"
 grass grassdata/location/mapset --exec r.out.gdal input=improved_image
 output=.../improved_image.tiff
 }}}

 I think you are suggesting you want a workflow like this:

 {{{
 grass grassdata/location/mapset -c EPSG:3358 -e
 grass --exec r.import input=some_image.tif output=some_image
 grass --exec r.info some_image
 grass --exec r.mapcalc "improved_image = 5 * some_image"
 grass --exec r.out.gdal input=improved_image
 output=.../improved_image.tiff
 }}}

 It seemed to be that `--exec` probably should not behave like that, so
 e.g. in #2579 (under Additional ideas), I suggested a subcommand
 directory-oriented interface using a hidden file in the current directory
 (but which still keeps the "connect to any grassdata/location/mapset"
 concept):

 {{{
 grass init grassdata/location/mapset EPSG:3358
 grass lock grassdata/location/mapset
 grass exec r.import input=some_image.tif output=some_image
 grass exec r.info some_image
 grass exec r.mapcalc "improved_image = 5 * some_image"
 grass exec r.out.gdal input=improved_image output=improved_image.tif
 grass unlock
 }}}

 (The above is just an idea for now, init and lock could be merged,
 grassdata/location/mapset could default to something in init and use more
 //convention over configuration// in lock, unlock could be renamed...)

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/3967#comment:1>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list