Tutorials › Pharmacometric Workflows and Reproducible Modeling › Run Folders and Output Naming

Project Structure, Version Control and Documentation · Tutorial 51 of 399

Run Folders and Output Naming

You will learn to assign stable run identifiers, organize outputs, and handle naming collisions so separate pharmacometric analyses remain distinct and interpretable.

Intermediate 12 min read

What You'll Learn

  • Distinguish a run identifier from a configuration fingerprint.
  • Choose directory names that remain stable throughout a run.
  • Prevent collisions when jobs are launched concurrently.
  • Organize outputs under a run-specific directory with informative filenames.
  • Record concise metadata that links outputs to the configuration used.
  • Diagnose naming schemes that risk overwrites or obscure results.

Why Run-Specific Output Names Matter

A model run can generate tables, diagnostic plots, parameter estimates, logs, and intermediate files. If every execution writes to a shared location with generic names such as results.csv or diagnostics.pdf, a later run can silently replace an earlier one. When runs overlap in time, the risk is greater: each process may write to the same file, leaving incomplete, mixed, or misleading results.

A run-specific output directory gives each execution its own namespace. Its identifier appears in the directory path, while filenames inside that directory describe the contents. Together, these choices help prevent accidental overwrites and make it easier to find which outputs belong together. They do not, by themselves, prove that a run can be reproduced; they provide a clear and durable place to keep its outputs and the metadata needed to interpret them.

Definition: A run is one execution of an analysis workflow using a particular set of inputs, configuration, and code at a particular execution event. A run identifier is a unique, stable label assigned to that execution. A configuration fingerprint is a compact value derived from a defined representation of the configuration; it can help compare configurations, but it is not a substitute for a unique run identifier.

The distinction matters. Two separate executions may use identical configurations but still need separate output locations, for example when comparing results after a software change or checking run-to-run variability. Conversely, a single run produces multiple files that should share one run identifier. The identifier answers “which execution produced this?” A configuration fingerprint answers a narrower question: “does this defined configuration representation match?”

Designing a Run Directory

A practical layout separates shared project inputs and code from generated results. For example, a project might place generated artifacts under outputs/runs/, with one child directory per execution. A run directory can then contain model results, diagnostics, and a small metadata file. Exact names depend on the project, but the organizing rule is stable: each execution writes only to its own directory.

A useful run identifier should be unique within the project, legal and portable as a directory name, and stable for the life of the run. It should not contain spaces, path separators, or characters that behave inconsistently across operating systems. Avoid relying only on a human-readable description such as “final” or “best”; those labels are subjective and are often reused. A date and time can help people recognize a run, but timestamps alone may collide when jobs start close together or when timestamp precision is limited.

One workable pattern combines a UTC timestamp with a short unique suffix, such as run_20261027T143205Z_a81f. The timestamp is descriptive; the suffix distinguishes executions with the same timestamp. Another option is a generated unique identifier with no embedded date. Whichever scheme is selected, use it consistently and do not reassign an old identifier to a new execution. A directory name should remain the same when that run writes additional outputs later.

Worked Example: Naming Two Runs Started Close Together

A hypothetical team launches two analyses of the same concentration dataset on 27 October 2026. Both begin during the 14:32:05 UTC second. A timestamp-only naming rule would assign both the directory name run_20261027T143205Z.

Identify the failure. The directory name does not distinguish the executions. If both jobs write to that path, they may overwrite files or interfere with each other's output. The timestamp is informative but not unique at the chosen precision.

Make the identifiers distinct. Suppose the run launcher assigns independent suffixes a81f and c290. The resulting paths are outputs/runs/run_20261027T143205Z_a81f/ and outputs/runs/run_20261027T143205Z_c290/. Both retain the same time information, and the suffixes distinguish the executions.

Check the result. If the first run writes diagnostics/model_summary.csv and the second writes the same relative filename, their complete paths differ because their parent directories differ. Neither output replaces the other's file. The suffixes must be generated or checked in a way that makes collisions acceptably unlikely or detects them before writing.

The directory should be created before the workflow writes outputs. A robust launcher attempts to create the requested directory as a new directory and stops if it already exists, rather than silently reusing it. This check must be safe when more than one process starts at once: checking that a path is absent and then creating it in a separate, unprotected operation can allow two processes to pass the check before either creates the directory. Prefer a filesystem operation that creates the directory only if it does not already exist, and handle a “path already exists” result by generating a new identifier or stopping with a clear error.

If a workflow intentionally resumes an interrupted run, make that a separate, explicit mode. Reusing a directory should require verifying that it belongs to the intended run and that existing files will not be mistaken for newly generated results. For ordinary fresh executions, refusing to write into an existing run directory is the safer default.

Make Output Filenames Informative

Within a run directory, filenames should identify the artifact's content, not attempt to repeat every detail of the run. Names such as parameter_estimates.csv, individual_diagnostics.pdf, and execution.log are more useful than output1.csv or plot_final.pdf. Include dimensions that distinguish multiple artifacts of the same kind, such as endpoint or analysis stage, when those differences matter. Keep naming terms consistent across runs so scripts and reviewers can locate equivalent outputs reliably.

A filename can include a compact configuration label where it improves navigation, but the directory identifier should remain the primary execution boundary. Repeating long parameter settings in every filename invites inconsistent spelling, unwieldy paths, and accidental mismatches. Put the full settings in a metadata file in the run directory and use filenames for the artifact type and any essential within-run distinction.

Worked Example: Organizing Outputs for Two Model Endpoints

A hypothetical run fits two endpoints, concentration and biomarker response. The workflow produces a parameter table and a diagnostic report for each endpoint. The run identifier is run_20261027T143205Z_a81f.

Choose the directory. Store all four files below outputs/runs/run_20261027T143205Z_a81f/. That makes the run identifier part of every full path without duplicating it in each filename.

Choose unambiguous names. Use parameter_estimates_concentration.csv, diagnostics_concentration.pdf, parameter_estimates_biomarker.csv, and diagnostics_biomarker.pdf. Each name states the artifact type and the endpoint.

Check uniqueness and meaning. The four filenames are distinct, and a reader can tell which endpoint each describes. A name such as final.csv would not communicate either artifact type or endpoint. If the same run produces multiple diagnostic reports for one endpoint, add a meaningful distinction, such as diagnostics_concentration_by_time.pdf and diagnostics_concentration_by_subject.pdf.

Metadata That Makes a Run Interpretable

A run directory name cannot carry all the information needed to interpret its contents. Include a small, machine-readable metadata file, for example run_metadata.json, with fields that identify the execution and summarize the inputs and settings. At a minimum, useful fields include the run identifier, creation time with timezone, configuration file or configuration values used, input dataset identifiers, and the workflow entry point. Record values that clarify which version of the inputs was used; a generic label such as “latest data” is not sufficiently specific if that label can change.

Keep metadata factual and consistent with the execution. If a configuration value is overridden by a command-line option, the recorded effective value should reflect the value actually used, not merely the unmodified configuration file. If an execution fails before all outputs are produced, its status should make that clear rather than implying successful completion. A short log can capture execution messages, while the metadata file should make key run details easy to inspect without searching a long log.

A fingerprint can supplement this information. For example, a project might compute a hash of a canonicalized configuration representation and store it as config_fingerprint. To interpret that field, define exactly what is included and how it is normalized: differences in key order or whitespace should not change the fingerprint if they do not change the configuration, while meaningful setting changes should. A fingerprint alone is not enough to identify a run: different input data, code, or execution conditions could produce distinct analyses with an identical configuration fingerprint.

Worked Example: Recording the Effective Configuration

A hypothetical model configuration specifies an output unit of mg/L and a maximum of 1,000 iterations. For a diagnostic check, the analyst launches the run with an explicit command-line override setting the maximum to 500 iterations. The run identifier is run_20261027T151000Z_d402.

Record what was executed. The metadata should identify run_20261027T151000Z_d402, the input dataset version, the workflow entry point, and the effective maximum of 500 iterations. It can also name the original configuration file and indicate that the maximum-iteration setting was overridden.

Explain why the distinction matters. If the metadata recorded only the configuration file's value of 1,000, a reviewer might believe the run used 1,000 iterations. Recording the effective value of 500 avoids that mismatch. The output directory and metadata together point to the execution and its actual settings; the configuration fingerprint, if included, must have a defined rule about whether it represents the original file, the effective settings, or both.

Deriving a Safe Naming Rule

A naming scheme is adequate only if it meets two separate needs: different executions must not unintentionally share a write location, and a person must be able to identify the contents of the resulting files. This gives a simple design argument.

1
Separate the executions.
Assign each fresh execution a unique identifier and create its directory without allowing silent reuse. Then files from distinct executions have distinct parent paths.
2
Describe the artifacts.
Use consistent filenames that indicate artifact type and any needed within-run distinction, such as endpoint or report subtype.
3
Connect path and settings.
Store the identifier and effective configuration summary in the directory so a result can be related to the execution that generated it.

If each run directory is unique and the workflow writes only within its assigned directory, two runs writing the same relative filename still have different full paths. If directory creation is not exclusive, however, that argument fails: two processes can share a path even if the naming pattern appears distinctive. Thus the uniqueness check is part of the output-safety rule, not an optional convenience.

Diagnostics, Alternatives, and Limitations

Review the scheme by checking both the directory structure and the behavior of the launcher. Useful warning signs include outputs appearing in a shared root directory, a second run changing the modification time or contents of an earlier run's files, duplicate run identifiers, ambiguous filenames, or metadata that disagrees with the effective settings. Test concurrent starts deliberately in a non-production workspace and verify that each process either receives a distinct directory or stops cleanly.

Common alternatives solve different parts of the problem. A timestamp-only name is readable but can collide at its time precision. A random or generated identifier is generally better for uniqueness, but it is less meaningful to a person and still needs a collision check. A configuration hash can group executions with the same defined configuration representation, but using that hash as the only directory name can cause distinct executions with identical settings to target the same location. A descriptive label such as “primary-analysis” is easy to recognize but is not unique across repeated runs. A combined approach—unique execution identifier, optional configuration fingerprint in metadata, and informative artifact filenames—keeps those purposes distinct.

Run directories also have limits. A tidy folder does not establish that the input data were valid, that the model was correctly specified, or that a result is scientifically sound. Nor does a configuration summary necessarily capture every factor that affects a result. The directory convention is an operational safeguard and an aid to interpretation; it must be used consistently and supported by accurate metadata.

Common Mistakes

  • Using one shared results directory. Separate jobs can overwrite the same outputs. Assign each fresh execution its own directory.
  • Assuming a timestamp is always unique. Runs can start within the same timestamp resolution. Add a unique suffix and handle directory collisions.
  • Using only a configuration fingerprint as the run ID. Different executions can share configuration while needing separate output locations. Keep execution identity separate from configuration similarity.
  • Overwriting an existing run folder without warning. That can destroy earlier results or mix old and new files. Refuse reuse by default and make intentional resumption explicit.
  • Recording planned rather than effective settings. Overrides can make the metadata misleading. Record the values the workflow actually used.
Key takeaway: Give every fresh execution a unique, stable directory; create it with collision-safe behavior; use clear filenames for its artifacts; and record the effective settings needed to interpret them. A run ID distinguishes executions, while a configuration fingerprint describes a defined configuration representation.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions below.

  1. Two runs start within the same second, and the directory naming rule uses only a timestamp to the nearest second. What can go wrong, and what is one correction?
  2. Why might two separate executions with the same configuration still need different run identifiers?
  3. A configuration file specifies 1,000 iterations, but the run is launched with an override of 500. Which value should the metadata report as effective?
  4. A run produces concentration and biomarker diagnostics. Suggest filenames that distinguish both artifact type and endpoint.
  5. Why is “check whether the directory exists, then create it” potentially unsafe when jobs start concurrently?

Solutions. (1) Both runs may target the same path and overwrite or mix files; add a unique suffix and reject any existing directory. (2) They are distinct execution events and may need separate outputs, such as for checking run-to-run behavior or comparing executions after a change. (3) Report 500 as the effective value, and note the override if useful. (4) For example, diagnostics_concentration.pdf and diagnostics_biomarker.pdf. (5) Both jobs can check before either creates the directory, then both proceed to write to the same path; use exclusive directory creation and handle a collision by generating a new identifier or stopping.)

Clinical Biostats