The process finished, but was the whole forecast updated?

Check a forecast against expected cells, times and fields. A real teaching process exits with code 0 while an independent audit finds a missing position.

An empty pane illustrates a gap in the expected forecast dataset.
An empty pane illustrates a gap in the expected forecast dataset.

The importer exited with code 0, the log contains no exception, and the number of written rows looks convincing. Yet one location may be missing its final forecast time, another may lack wind, and some values may belong to a different run. Process termination describes the execution of a program. Forecast completeness requires a separate check of what that program actually prepared.

We will build a small independent audit: two fictional cells, three time positions and two required fields. The expected set will be defined before we read the result. We will then deliberately remove a row, add a duplicate and substitute provenance. The exercise uses Python and its standard library; it neither downloads weather data nor tests a deployed service.

Define the product's promise first

The question “is everything present?” has no answer without a defined expectation. The next few hours may be enough for one page, while another needs a longer horizon. A field available from the source is not necessarily required by this product. Equally, a required parameter cannot disappear from the check simply because it did not arrive this time.

Our contract has two cells, cell-a and cell-b. Each requires instantaneous air temperature at two metres and wind speed at ten metres at hours 0, 3 and 6. These hours are relative to a shared arbitrary origin in one fictional run. This is not a dated forecast or the temporal grid of any particular provider.

Expectation dimension Value in the exercise
Spatial scope Two distinct cells
Time positions 0, 3, 6
Required fields Temperature and wind speed
Required positions 2 × 3 × 2 = 12
Optional field Cloud fraction at the same cells and hours
Optional positions 2 × 3 × 1 = 6

The trusted call to audit supplies the expectation; the incoming document cannot declare itself complete. In a real product, the configuration for the required scope and representation owns that choice of contract. Unvalidated input must not be able to shrink the expectation to match its own contents.

The matrix exists independently of the received rows

A position's key consists of its cell, valid time and field. Three finite sets form a Cartesian product. The example uses itertools.product; the Python documentation explains its relationship to nested loops and that it retains the input collections in memory.

We therefore check the sizes before constructing the matrix. The teaching implementation permits at most 4096 expected positions and 8192 input rows. Those numbers bound this particular exercise. They are neither recommendations for a large weather catalogue nor measured server capacity.

Empty cell lists, time lists or field definitions are rejected as contract errors. A contract with no required field is also prohibited. Otherwise, an empty response could pass a formal comparison of two empty sets and receive a green mark. A product that genuinely requires an empty scope must describe it as a separate permitted state.

Repeated cells, time positions and field names are prohibited too. The product function itself does not decide whether a duplicate in the input configuration was a mistake. Times must be ordered integer values; the boolean False is not accepted in place of hour 0.

An identical key does not imply compatible data

Before counting a position, we check its provenance scope. Every row must have the source, model, grid revision, run revision and normalization version expected by the contract. A row from an older run cannot fill a hole in the new one, even if the cell, hour and number happen to match.

The field definition separately fixes the unit and temporal support. Only instantaneous quantities are allowed here. Replacing degree_Celsius with kelvin causes rejection; the auditor performs no conversion. Interval precipitation or accumulated quantities cannot pass as instantaneous fields either. Supporting them would require extending the contract and specifying both time boundaries.

This check establishes that the supplied metadata matches the expectation. It does not prove the true origin of the bytes or the correctness of an earlier normalization. If an adapter incorrectly labels an old value with a new revision, string comparisons alone will not detect it. Trust in the adapter and the connection to a pinned source document require other evidence.

The contract identifier is included in the report so that the result can be explained. The exercise maintains no historical contract registry. External configuration management must keep the meaning of a name stable; the contract_id string does not provide that guarantee by itself.

Zero, a missing value and a duplicate have different consequences

Zero wind speed and a negative temperature are ordinary numeric values. None, booleans, NaN and infinities do not count. The implementation uses math.isfinite to check finiteness. The technical absolute-value limit of one million also belongs solely to the exercise; it is not a physical limit for a weather variable.

A finite number does not prove plausibility. For example, this model does not check climatic temperature limits or an allowed cloud-fraction range. Such rules may be needed when admitting a real forecast, but adding them to the conclusions of an already completed experiment would be incorrect.

A duplicate does not increase coverage. Under our strict policy, repeating an expected position makes it ambiguous: the position is removed from the valid set even when both numbers are identical. The auditor chooses neither the first nor the last row. This is a rule for one completed candidate; it does not prevent another system layer from handling a repeated delivery idempotently before building that candidate.

This reveals a failure that a simple count hides. Remove the final row and add a copy of the first. The input again contains twelve rows. But one position is absent, while another is duplicated and no longer counts. Ten valid required positions remain.

Completeness and admission answer different questions

The central decision is expressed through set difference:

missing = required - valid
coverage_complete = not missing
admissible = coverage_complete and not issues

coverage_complete means that every required position has one unambiguous accepted value. admissible additionally requires the absence of recorded problems in the input candidate. For example, all twelve required rows may be present, but an extra row for another cell makes the entire document unacceptable under our policy.

Optionality permits absence, not incorrect data. If all six cloud-fraction positions are missing, the report lists them but admits the complete required set. If cloud fraction is present with None or an incorrect unit, the candidate has an error. Another product might allow that field to be discarded, but this must be an explicit rule with its own reporting and tests.

Unknown fields, time positions and additional row keys are also prohibited here. The conservative format makes contract drift visible. This is not a universal API compatibility rule: an open schema would make a different choice about unknown fields.

What the four controlled scenarios showed

All input rows and the complete expected report are recorded as separate literal data. The audit function does not generate the expectations. We can therefore compare its response against independently specified counts and exact keys.

Scenario Input rows Valid required positions Decision
All required values, no cloud fraction 12 12 Admit
Wind at cell-b, hour 6, removed 11 11 Reject: one gap
That missing row replaced by a copy of the first 12 10 Reject: a duplicate and two unfulfilled positions
Cloud fraction with None added to the complete set 13 12 Coverage is complete, but the candidate is rejected

In the second case, the report identifies the exact position cell-b|6|wind_speed_10m. This is more useful than a general “92 percent received” message: we know precisely what needs to be restored or explained. However, the key itself does not instruct us to retry a request. A retry also requires knowing whether the source is available and its identity remains unchanged.

A successful process can really emit an incomplete set

The exercise includes a separate producer.py. With --drop-last, it deliberately prints eleven of the twelve synthetic rows and terminates normally. This is a controlled counterexample, not a description of a defect in a production importer.

Python's documentation for sys.exit describes zero as successful termination from the shell's perspective. The program's code determines which domain result, if any, it checked before terminating.

In the actual local experiment, the child process returned 0, its JSON parsed successfully, and our auditor found one missing required position. The failure was therefore not concealed behind a broken parser or an artificially nonzero status. It was the independent expectation that exposed the insufficient result.

The local check used the Python standard library.

All 35 test methods completed successfully on Python 3.12.14. They cover a missing cell, field and hour, duplicates, every provenance component, units, None, infinite and boolean values, and empty or oversized contracts. Separate checks establish that the input objects remain unchanged and repeated audits return the same result. This is a count of 35 methods, not of every subcase within them.

A complete candidate still needs to be displayed correctly

The auditor returns a report about a bounded set in memory. It does not switch the active version, execute transactions, check a cache or open a visitor's page. The set could also change after validation if external code has not pinned its identity and contents. The resulting flag cannot be transferred to an arbitrary later version.

Freshness and forecast accuracy remain separate properties. A complete older run may be unacceptable because of its age; a complete, technically sound set may produce an inaccurate forecast. A real service must check its time policies, the immutability of the validated candidate, its activation and the reading of the expected revision through the actual product path.

This exercise provides a more precise intermediate result: a known expectation, a set of accepted positions and an explanation for every absence or rejection. With that result, process termination becomes one signal about system operation, while forecast completeness acquires its own testable meaning.

  1. Platform Engineering When a prototype becomes a product: an evidence matrix for one end-to-end scenario
  2. Weather Switching a whole forecast: snapshots, checkpoints and crash recovery
  3. Weather One weather contract for Go and PHP: checking data across the language boundary
  4. Weather A newer forecast is shorter: updating the next hours while retaining the long horizon

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article