Skip to content

flex_rf.web.run

Type: function Base(s): None

Submit one or many simulations and return results in the same container shape.

This is a convenience wrapper around the autograd runners that accepts a single simulation or an arbitrarily nested container of simulations (list, tuple, or dict values). Internally, all simulations are collected, deduplicated by object hash, executed either synchronously (single) or asynchronously (batch), and the returned data objects are reassembled to mirror the input structure.

Path behavior

  • Single simulation: results are downloaded to f"{path}.hdf5" when path is provided without a suffix.
  • Multiple simulations: path is treated as a directory, and each task will write its own results file inside that directory.

Lazy loading

  • If lazy is not specified: single runs default to False (eager load); batch runs default to True (proxy objects that load on first access).
  • Simulations are indexed by hash(sim). If the same object appears multiple times in the input, it is executed once and its data is reused at all positions. The last occurrence wins if duplicates with the same hash are encountered.
  • For each simulation, a mode-solver compatibility patch is applied so that the returned data exposes expected convenience attributes.
  • progress_callback_* are only used in the single-run code path.
  • Passing run options directly is deprecated. Set defaults via td.config.run and td.config.vgpu instead. Non-None values passed here override the config for this call.

Single run (eager by default)

sim_data = run(sim, task_name="wg_bend", path="out/bend")
# writes: "out/bend.hdf5"

Batch run with nested structure (lazy by default)

sims = {
"coarse": [sim_a, sim_b],
"fine": sim_c,
}
data = run(sims, path="out/batch_dir", max_workers=4)
# 'data' mirrors 'sims' structure:
# data["coarse"][0] -> data for sim_a, etc.
simulation [RunInput]
task_name [str | None] = None
folder_name [str] = 'default'
path [PathLike | None] = None
callback_url [str | None] = None
verbose [bool] = True
progress_callback_upload [typing.Callable[[float], None] | None] = None
progress_callback_download [typing.Callable[[float], None] | None] = None
solver_version [str | None] = None
worker_group [str | None] = None
simulation_type [str | None] = None
parent_tasks [list[str] | None] = None
local_gradient [bool | None] = None
max_num_adjoint_per_fwd [int | None] = None
reduce_simulation [typing.Literal['auto', True, False]] = 'auto'
pay_type [PayType | str | None] = None
priority [int | None] = None
max_workers [int | None] = None
lazy [bool | None] = None
vgpu_allocation [int | None] = None
ignore_memory_limit [bool | None] = None