Tutorials › Pharmacometric Workflows and Reproducible Modeling › Handling Partial Report Generation Failures

Automating Diagnostics and Reports · Tutorial 312 of 399

Handling Partial Report Generation Failures

Build report workflows that preserve usable sections without concealing failures or presenting incomplete diagnostics as complete.

Intermediate 12 min read

What You'll Learn

  • Distinguish failed, unavailable, and skipped report sections.
  • Track prerequisites so a local failure does not invalidate unrelated outputs.
  • Decide when continuation is safe, including when sections share inputs.
  • Record useful failure details while avoiding misleading or stale output.
  • Label report-level completeness and summarize section statuses accurately.
  • Apply a consistent workflow to hypothetical diagnostic-report failures.

Why Partial Failures Need Explicit Handling

A diagnostic report may contain several useful sections even when one plot, table, or calculation cannot be produced. For example, a subgroup diagnostic may have no eligible records, or a plotting function may fail while rendering a particular figure. If the workflow stops at the first local problem, it can discard valid results. If it silently carries on, readers may mistake a missing section for a diagnostic that was checked and found unremarkable. Reliable automation must do both: preserve outputs that remain valid and make incomplete work visible.

This tutorial concerns the workflow for representing and responding to failures during report generation. It does not change the diagnostic definitions or interpretations established by the earlier material on diagnostic metrics, subgroup summaries, and diagnostic plots. The key question here is whether an output can still be generated and trusted when another part of the report has a problem.

Section Statuses and Report Status

A report workflow should assign an explicit status to each planned section, rather than treating the presence or absence of a file as its only record. Use status labels whose meanings are stable across runs. The following distinctions are useful:

Definition: A section is successful when it was generated and passed its defined checks. It is unavailable when its intended content cannot be computed from the valid inputs—for example, a prespecified subgroup contains no eligible records. It is failed when an attempted computation, validation, or rendering operation encountered an error. It is skipped when the workflow did not attempt it because a required prerequisite was invalid or missing.

“Unavailable” and “failed” should not be merged. An empty, validly identified subgroup may make a subgroup diagnostic unavailable without indicating a software defect. A rendering exception is a failure even if the data needed for that figure are present. A skipped section is different again: it may be perfectly executable in isolation, but the workflow deliberately did not run it because doing so could create an invalid result.

At report level, describe whether all planned sections succeeded, whether some sections are incomplete, or whether the workflow could not produce a usable report. A practical vocabulary is complete, partial, and failed. Define the rule in advance. For instance, a report can be marked partial when at least one planned section is unavailable, failed, or skipped and other sections were successfully produced. Reserve failed for a run that cannot produce a usable report under the project’s stated criteria. Do not label a report complete merely because the generation program reached its final line.

Prerequisites Determine Whether Work Can Continue

Treat report generation as a set of tasks with explicit dependencies. A task may require input data, a validated transformation, a model output, or another section’s result. A dependency map makes it possible to distinguish a local failure from a failure that affects several downstream sections.

Definition: A task’s prerequisites are the inputs and upstream results that must be valid for its output to be meaningful. A task may be attempted only when those prerequisites are valid. If a required prerequisite is invalid, the task should be skipped or use a fallback only when that fallback is defined, justified, and recorded.

For example, suppose section A fails. Section B may still be attempted if B’s own prerequisites remain valid and B does not require A’s output, unless a valid fallback for A’s output has been explicitly defined. This is a necessary safety check, not a guarantee that B will succeed: B can still encounter its own error. Equally, the fact that A and B do not consume each other’s outputs is not enough to justify continuation. They may share a failed input or transformation, making both outputs invalid. Check shared prerequisites before continuing.

A compact validity rule makes the logic explicit. Let \(V_j\) mean that task \(j\)'s output is valid, \(E_j\) mean that its own execution and checks succeed, and \(P(j)\) be its required prerequisites. Then:

$$ V_j = E_j \ \text{and every required prerequisite in } P(j) \text{ is valid} $$

If a prerequisite is replaced by a fallback, count it as valid only if the fallback is appropriate for that task and its use is recorded. A task that runs successfully with invalid inputs does not have a valid output. This distinction is why catching an error and moving to the next line is not, by itself, robust failure handling.

A Practical Failure-Handling Sequence

1
Define planned sections and prerequisites.
Record what each section needs and which sections depend on shared inputs or upstream results.
2
Validate inputs before dependent work.
Check required fields, units, transformations, and data availability. If a shared prerequisite fails, mark every affected downstream task accordingly.
3
Run sections within clear failure boundaries.
Handle errors at the level of an individual task where possible. Record the task, error, and relevant context, then evaluate which remaining tasks still have valid prerequisites.
4
Validate and label outputs.
Check that each generated item is usable, preserve its status and explanation, and set the overall report status from the planned sections and their outcomes.

Error handling should be specific enough to preserve diagnostic information. A broad handler that catches every error and returns an empty plot can make a software failure look like a legitimate plot with no data. Instead, retain an informative error message and identify the affected task. Avoid including sensitive data in logs; record what is needed to diagnose the failure without copying unnecessary subject-level information.

Worked Example: One Unavailable Subgroup Section

A hypothetical report has four planned sections: an overall residual plot, a subgroup residual plot, a prediction-error table, and a shrinkage summary. A validated analysis dataset contains 120 records. The prespecified subgroup filter selects 0 records, while the other sections’ required inputs are available and pass their checks.

Classify the subgroup result. The subgroup section is unavailable, not failed: the filter has been applied, and there are no eligible records on which to calculate or display that subgroup diagnostic. The workflow records the reason as “no eligible records after the prespecified subgroup filter,” rather than creating an empty figure that could be mistaken for a successful diagnostic.

Check continuation. The overall residual plot, prediction-error table, and shrinkage summary do not require the subgroup plot’s output. Their own prerequisites are valid, so they may be attempted. This conclusion depends on checking the inputs, not merely on the sections having different names.

Summarize completeness. Three of the four planned sections are successful. The successful-section fraction is \(3/4 = 0.75\), or 75%. The report is partial, with one unavailable section; 75% describes the fraction of sections successfully produced, not the fraction of diagnostics that are scientifically adequate. The report should state the missing section and its reason.

Shared-Prerequisite Failures and Dependency Propagation

A failure in a shared prerequisite can affect several sections even if those sections are otherwise independent. For example, if residuals and prediction errors both require a validated unit conversion, a failure in that conversion prevents both outputs from being trusted. A shrinkage summary derived from a separate, valid model-output file might remain possible, but only after confirming that it does not rely on the failed conversion.

Worked Example: A Failed Shared Unit Check

In a hypothetical report, a required concentration variable should be in milligrams per liter. A unit check finds that 8 of 80 records have no interpretable unit label, so the conversion step cannot establish a consistent unit for the full analysis dataset. The residual plot and prediction-error table both depend on that converted dataset. A shrinkage summary depends instead on a separate model-output file that passes its own validation.

Identify the affected sections. The conversion is a shared prerequisite for the residual plot and prediction-error table. Since it is not valid, both sections are skipped; neither should be generated using an unverified mixture of units. The two sections are not safe to continue merely because neither requires the other’s output.

Assess the remaining section. The shrinkage summary may be attempted because its specified input is separate and has passed validation. This decision would change if the summary also depended on the failed conversion or on another failed shared input.

Report the result. If the shrinkage summary succeeds, 1 of 3 sections succeeds: \(1/3 \approx 0.333\), or 33.3%. The report is partial, with two skipped sections. State that their shared unit-conversion prerequisite failed; do not describe them as unavailable due to empty data or as successful diagnostics.

This dependency check is especially important after data validation or transformation failures. An upstream issue may have a wider scope than the first task that reports it. Update the status of every affected task, and do not allow later tasks to reuse stale results from a previous run as if they belonged to the current run.

Make Partial Outputs Safe to Read

A technically successful run can still be misleading if the report hides its incomplete status. Make the state visible near the report’s start and at the affected sections. For each section, record its status and a short, specific reason when it is not successful. A reader should be able to distinguish “not attempted because a required input failed” from “attempted but the rendering operation failed” and from “no eligible data were available.”

Write outputs in a way that avoids exposing half-finished artifacts as complete. One useful pattern is to generate a section to a temporary location, run its checks, and make it available to the report only after those checks pass. If generation fails, retain the failure record and do not leave a partial artifact in the position normally used for a validated section. This does not require discarding other sections that passed their own checks.

Worked Example: Recording a Section-Specific Rendering Failure

A hypothetical run plans five sections. Four pass their prerequisites. During rendering, the subgroup plot raises an error because its plotting routine cannot handle a particular valid category label. The table and plots for other sections have already passed their checks; the subgroup plot has not produced a validated artifact.

Record the event. Mark the subgroup plot failed, not unavailable: eligible data exist, but rendering did not complete. Record the section name, the error message, and the stage at which the error occurred. Do not replace the missing plot with a blank image labeled as successful.

Check the remaining work. The failure is confined to rendering that plot. The other four sections have valid prerequisites and validated outputs, so they can remain in the report. If any later section required the subgroup plot itself, it would instead be skipped unless an explicitly justified fallback were available.

Calculate the section summary. Four of five planned sections succeeded: \(4/5 = 0.8\), or 80%. Mark the report partial and identify the failed subgroup plot. The 80% is a count-based completeness measure; it does not imply that 80% of the report’s scientific conclusions are supported.

Diagnostics, Alternatives, and Limitations

Useful checks include comparing the planned section list with the recorded outcomes, confirming that every non-success status has a reason, and verifying that successful sections have usable outputs. Check that a report marked complete has no failed, unavailable, or skipped planned sections under the project’s defined rule. Also check that no downstream section was generated from a failed prerequisite and that artifacts from earlier runs were not mistaken for current outputs.

Two tempting alternatives are unreliable. Stopping the entire run at the first error is simple, but can unnecessarily discard unaffected outputs. Silently suppressing errors and continuing is also simple, but can conceal invalid or missing diagnostics. A better approach uses scoped error handling and dependency-aware continuation: preserve valid work, record the problem, and stop or skip only what the failure actually affects. If a failure concerns a shared prerequisite or the validity of the report as a whole, broader interruption may be necessary.

Partial generation has limits. A partial report must not be used as if it were complete, and a successful section does not repair an invalid shared input elsewhere. Status labels and logged errors support interpretation and follow-up; they do not establish that the underlying model or diagnostic is scientifically adequate. Define in advance which failures make a report unusable and which allow a clearly labeled partial report.

Common pitfall: “Section A failed, but section B does not use A’s output, so B is safe to run.” This reasoning overlooks shared prerequisites. Check whether B’s own inputs and upstream transformations remain valid; continue only if they do and B does not require A’s output, unless a valid fallback is defined.

Check Your Understanding

Answer each question using the status definitions and prerequisite logic above. Brief solutions follow the questions.

  1. A subgroup filter selects no records, and the filter itself passes validation. Is the resulting section failed, unavailable, or skipped?
  2. Two sections use different outputs, but both depend on a unit conversion that failed validation. Can one be run just because it does not depend on the other section?
  3. A rendering error prevents a plot from being validated, although eligible data are available. What status should the plot receive?
  4. In a report with six planned sections, five succeed and one is skipped because a required input failed. What is the successful-section fraction, and should the report be labeled complete?
  5. Name two checks that can reveal that a report’s recorded status is misleading.

Solutions. (1) Unavailable: valid filtering found no eligible records. (2) No. Both depend on the failed shared prerequisite, so neither should be generated from it. (3) Failed, because generation was attempted and encountered a rendering error. (4) \(5/6 \approx 0.833\), or 83.3%; the report is partial, not complete. (5) Examples include checking that every planned section has a recorded outcome and reason when needed, confirming that complete reports have no non-success sections, and verifying that successful outputs are usable and were not carried over from an earlier run.

Clinical Biostats