Globals & initialization
Global project state and the initializeModelManager entry point.
ModelManager.mm_globals_ref — Constant
mm_globals_refModule-level Ref holding the active ModelManagerGlobals instance.
Set by the concrete simulator package in its __init__, e.g.:
function __init__()
ModelManager.mm_globals_ref[] = ModelManagerGlobals(simulator = MySimulator(), ...)
endModelManager.ModelManagerGlobals — Type
ModelManagerGlobalsMutable struct holding all global state for a ModelManager project.
The active instance is accessed via mm_globals. Concrete simulator packages (e.g. PhysiCellModelManager) create an instance of this struct and register it via mm_globals_ref in their __init__.
Fields
initialized::Bool:trueafterinitializeModelManagersucceeds.data_dir::String: Absolute path to the projectdata/directory.simulator::AbstractSimulator: The active simulator backend.inputs_dict::Dict{Symbol,Any}: Parsed contents ofinputs.toml.project_locations::ProjectLocations: Derived frominputs_dict.db::SQLite.DB: Connection to the central project database.run_on_hpc::Bool:trueto submit simulations as SLURM jobs and to route file removal through the staging path ofrm_hpc_safe.initializeModelManagersets it fromisRunningOnHPCon every call; override afterwards withuseHPC.sbatch_options::Dict{String,Any}: Options forwarded tosbatch.hpc_completion::HPCCompletionOptions: How the runner detects that a submitted SLURM job has finished. SeesetHPCCompletionOptions.max_number_of_parallel_simulations::Int: Concurrency limit.diagnostics_task::Union{Nothing,Task}: The backgroundTaskrunningdatabaseDiagnostics, set byinitializeModelManager.nothingbefore initialization or if diagnostics have not been launched. UsewaitForDiagnosticsto block until it completes.provenance_id::Union{Nothing,Int}: Row inprovenancesdescribing the current creation context (session, launching script, git state). Re-resolved on entry tocreateTrialandrun, and stamped onto the objects they create.session_id::String: Random per-session identifier recorded asmm:session. Assigned lazily on first use.tag_hints::Bool: Whether to show the one-time tagging hints. SeesetTagHints!.tag_hint_shown::Bool,tag_recovery_hint_shown::Bool: Once-per-session latches for those hints.trash_staged_warning_shown::Bool: Once-per-project latch for the warningrm_hpc_safeissues when a shared filesystem forces it to stage a path indata/.trash/instead of removing it. Its:unremovedcase — where it can do neither — is deliberately not latched, since each occurrence names a different leaked path.last_trash_sweep::String:yymmddstamp of the daydata/.trash/was last swept, so a session that outlives a single day re-sweeps instead of relying on the one at startup.
ModelManager.assertInitialized — Method
assertInitialized()Assert that the model manager has been initialized, throwing an informative error if not.
ModelManager.centralDB — Method
centralDB()Return the central SQLite.DB connection for the current project.
ModelManager.currentSimulatorVersionID — Method
currentSimulatorVersionID()Return the current simulator version row ID from the database. Delegates to currentSimulatorVersionID(sim) on the active simulator.
ModelManager.dataDir — Method
dataDir()Return the path to the current project's data/ directory.
ModelManager.initializeModelManager — Method
initializeModelManager(simulator::AbstractSimulator, data_dir::AbstractString; auto_upgrade::Bool=false)Initialize ModelManager for a project rooted at data_dir using simulator as the concrete backend.
This is the generic entry point that simulator packages (e.g. PhysiCellModelManager) call from their own path-level overloads after setting any simulator-specific fields. It performs all framework-agnostic initialization steps in order:
- Register
simulatoranddata_diron the activeModelManagerGlobals. - Open the central SQLite database (filename determined by
centralDBFileName). - Resolve the package version, creating or upgrading the DB schema if needed.
- Parse
inputs.toml. - Initialize the database schema (tables, folder registration).
- Detect whether SLURM is available via
isRunningOnHPCand store the result inrun_on_hpc. Override it afterwards withuseHPC. - Call
postInitDisplayto print startup information. - Launch a background
@asynctask that retries the removal of anythingrm_hpc_safehad to stage indata/.trash/, then runsdatabaseDiagnostics.
Returns true on success, false on any initialization failure — including errors that would otherwise throw (e.g. an unwritable data_dir). All mutated globals are reset to a clean state before any false return, so isInitialized reports false and a subsequent retry starts fresh.
Simulator packages typically provide their own path-level overloads (e.g. accepting path_to_physicell and path_to_data) that validate paths, set simulator-specific state, then delegate here.
Database diagnostics run in the background and may print after this function returns. Call waitForDiagnostics if you need them to complete before proceeding.
ModelManager.inputsDict — Method
inputsDict()Return the parsed inputs.toml dictionary for the current project.
ModelManager.isInitialized — Method
isInitialized()Return true if the model manager has been successfully initialized.
ModelManager.mm_globals — Method
mm_globals()::ModelManagerGlobalsReturn the active ModelManagerGlobals instance.
Throws an assertion error if no simulator package has registered its globals yet.
ModelManager.projectLocations — Method
projectLocations()Return the ProjectLocations for the current project.
ModelManager.simulator — Method
simulator()Return the active AbstractSimulator backend.
ModelManager.simulatorVersionIDName — Method
simulatorVersionIDName()Return the SQL column name used for the simulator version FK. Delegates to simulatorVersionIDName(sim) on the active simulator.
ModelManager.waitForDiagnostics — Method
waitForDiagnostics()Block until the background databaseDiagnostics task launched during initializeModelManager completes. Returns immediately if diagnostics have already finished or were never started.
initializeModelManager runs five read-only consistency checks (DB↔filesystem sync, orphaned entries, constituent ID integrity, simulation status) in a background task so initialization returns promptly. In interactive sessions the diagnostics typically finish during the first idle moment. In scripts and HPC jobs the task runs opportunistically during I/O-heavy work (e.g. simulation runs); call waitForDiagnostics() explicitly if you need the output before a particular step.
Example
initializeModelManager(sim, data_dir)
# Optional: block until database consistency checks have printed their results.
# Useful in scripts that exit quickly or test suites that inspect diagnostic output.
# waitForDiagnostics()
# ... rest of your workflow ...