Execution#

Most users only need project.run(), project.submit(), or stilt run (Running). The functions below do the work underneath.

  • run() is what project.run() calls. It finds the releases with missing results, runs them, and waits until they finish. task=(i, n) runs share i of n here (task_share()), which is what stilt run --task i/n does.

  • submit() is what project.submit() calls. It writes a job array script (job_script()) whose tasks each run stilt run --task, submits it with sbatch, and returns the job id at once.

  • run_particles() runs the transport model for one Simulation and writes its particles and log.

  • run_stages() runs the stages of the variants that share those particles, the footprint among them: each stage file that is missing, in the order the stages read one another, and each again when what it reads was made again. run_stage() runs one, which writes its own file.

  • run_release() runs every variant of one release, skipping what exists. Variants that share particles run the transport model once and run their stages on the particles in memory. A failure is recorded with the simulation (stilt.Simulation.failure). Workers are always handed releases.

  • run_releases() runs a list of releases, in this process or in a process pool.

On Slurm each task of the job array runs one share of the releases (task_share()) with stilt run --task. A local run happens in this process. A program that starts the tasks itself, on another scheduler, writes pending() to the releases.txt each task reads (stilt run --releases); wait() waits for a Slurm job array by its id.

Running#

runtraj.execution.run

Run every simulation of a project that has not finished, and wait for it.

runtraj.execution.submit

Submit every simulation of a project that has not finished to Slurm.

runtraj.execution.pending

Return the ids of the releases a run would run, each once, in project order.

runtraj.execution.wait

Wait until every task of a Slurm job array has ended, and return how each ended.

runtraj.execution.task_share

Return task task's share of release_ids, split n_tasks ways.

Workers#

Internal: importable from their modules, and free to change.

runtraj.execution.runner.resolve_compute_root

Return the compute root of project: the directory its workdirs are made in.

runtraj.execution.worker.run_particles

Run the transport model for a simulation and write its particles to the output directory.

runtraj.execution.worker.run_stage

Run one stage of a simulation, which writes its file to the output directory.

runtraj.execution.worker.run_stages

Run the stages of the simulations of one release that share particles, and return what failed.

runtraj.execution.worker.run_release

Run every simulation of one release, and return what did not complete.

runtraj.execution.worker.run_releases

Run a list of releases, in this process or in a process pool.

Slurm job arrays#

runtraj.execution.job_script

Return the sbatch script of a job array whose tasks each run a share of the releases.

runtraj.execution.fetch_script

Return the sbatch script of the job that gets the met files before a job array.

Transport model#

The worker runs a simulation through the transport model its settings name. HYSPLIT is the one built in that runs, and CONTRIBUTING describes how to add another, named by its import path. PYSTILT’s stilt-r model (class: stilt.migration.StiltRModel) is one of those, and runs nothing: its variants read the runs stilt.migration.import_stilt_r() imported from STILT-R, with the settings STILT-R’s files record. A model fails a run that its meteorology does not cover, as MET_COVERAGE. Particles that all leave the met’s domain before the end of the run are a complete run.

runtraj.models.TransportModel

A transport model that follows particles from a release.

runtraj.models.BatchedTransportModel

A transport model that runs many releases in one call, such as an emulator on a GPU.

runtraj.models.TransportConfig

The base of every transport model's config.

runtraj.models.ModelRun

What one model run produced.

runtraj.models.get_model

Return the transport model name names.

runtraj.models.run_model

Run the transport model called name for one release, and finish its particles.

runtraj.models.run_model_many

Run a batched transport model once for many releases, and finish each one's particles.

runtraj.models.hysplit.HysplitModel

HYSPLIT as a transport model, the object get_model("hysplit") returns.

stilt.migration.StiltRModel

The stilt-r transport model of imported runs, named by its import path (STILT_R_MODEL).

stilt.migration.StiltRConfig

The settings of imported STILT-R runs: HYSPLIT's, as STILT-R ran it, and the STILT-R version.

stilt.migration.StiltRMetConfig

The met of imported STILT-R runs, as written under mets: in config.yaml.

Stages#

A stage makes one file per release from a simulation’s results, after the transport model runs. The footprint is one (stilt.footprint.FootprintStage). A stages block of config.yaml names its stage’s class by import path, so a stage in a package of your own needs no registration, and CONTRIBUTING describes how to write one. Use check_stage() in its tests.

runtraj.stages.Stage

What is made from each simulation's results: one file per release.

runtraj.stages.get_stage

Return the stage whose class is at the import path path, made with no arguments.

runtraj.stages.ordered

Return the names of stages in the order they run: each after the stages it reads.

runtraj.stages.check_stage

Check that stage keeps the promises the worker and the output directory rely on, for one config.