runtraj.stages.Stage.run#

Stage.run(config, sim, path)[source]#

Make the stage’s file for one simulation, and write it at path.

The worker calls it for each simulation whose file is missing, after the particles and the files of the stages in reads exist. Read the particles from sim.particles (a pandas DataFrame, which simulations that share it hold in common: do not change it in place), and another stage’s file from sim.path("<its name>") with that stage’s own reader. Write one file at path and nothing else, whatever there is to say: a result with nothing in it is still a file. On a filesystem path is a temporary name beside the file’s own, ending in suffix, which the worker moves into place when this returns; a file left by a run that raises is removed. So a run cut off part-way leaves no file that counts as complete. A Parquet file may carry runtraj.identity.file_stamp() in its metadata, as runtraj’s own files do.

Parameters:
  • config (Any) – The variant’s settings of this stage, as resolve() returned them.

  • sim (runtraj.simulation.Simulation) – The simulation: its release, its variant, its particles, and the project directory (sim.directory), where a relative file name in the settings starts.

  • path (Path | UPath) – Where to write the file: a pathlib.Path, or a upath.UPath when the output directory is on an object store. Write through path.open("wb") (or "w"), which both have, and the stage works with either.

Raises:

Exception – Any error fails the simulation at this stage: the worker records it (runtraj.Simulation.failure) and goes on. Raise a SimulationError with a reason for a failure you expect.

Return type:

None