pyrosm.recipes.run#
- pyrosm.recipes.run(recipe, out_dir=None, force=False, base_dir=None)#
Run a recipe and write its outputs and provenance record; returns their paths.
The outputs are written into
out_dir(default:base_dir, or the recipe file’s folder) under the names the recipe gives them. They are made in a staging folder and moved into place only when every stage has succeeded, so a failed stage leaves the previous outputs and record as they were; a run interrupted while moving them leaves no record. A lock file.<record name>.lockkeeps two runs of a recipe from writing at once, and a run is refused when an input file changes while it runs, or when an input or the extract differs from asha256orsnapshotpin of the recipe.A stage whose recipe section, reader keywords, output names, inputs and package versions are those of the previous run, and whose outputs are in place unchanged, is not run again: its outputs and its part of the record are kept. An extract stage with
update: truealways runs.The provenance record (JSON) holds the package versions, the resolved recipe, the SHA-256 of each input and output, where the extract came from, how the run was invoked (with the recipe file,
out_dirandbase_dir) and when.- Parameters:
recipe (str | pathlib.Path | Mapping) – The recipe file (YAML or JSON), or the recipe as a mapping in the same format, such as
json.loads(text); a mapping needsoutputs.provenance. A string is always a file name.out_dir (str | pathlib.Path, optional) – The output folder, created when missing; a relative one is relative to the current folder.
force (bool) – Run every stage, whether or not it changed, and download the extract again.
base_dir (str | pathlib.Path, optional) – The folder that the recipe’s relative paths resolve against, and the default output folder (see
validate()).
- Returns:
The paths of the outputs, written or reused, in the recipe’s order, and the provenance record last.
- Return type:
list of pathlib.Path