Skip to content

best approach for parallel sessions #15

@epifanio

Description

@epifanio

Hi, I was wondering what would be the best approach to run a list of independent commands in parallel that use input file from the same location.

My approach is to create a mapset for each command, so that for each process i repeat something like:

import uuid
mapset = str(uuid.uuid4())

with Session(gisdb="grassdata", 
             location="location_name"):
    gcore.run_command("g.mapset", flags="c", mapset=mapset)
    
with Session(gisdb="grassdata", 
             location="location_name", mapset=mapset):
    gcore.run_command('r.process.data', 
                  param='value-for-process-i_n,
                  output=prefix_param-value-for-process-i_n)
    gcore.run_command('r.export.output', 
                  input=prefix_param-value-for-process-i_n,
                  output=prefix_param-value-for-process-i_n)

I run this for each process by changing just the value for the input parameters and then I remove such mapset after the session exit with a brute rm -rf /path/to/location_name/mapset_uuid_name

Is there an option to use grass-session with a temporary mapset that gets created when the session starts and removed when it exit?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions