Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Operation revisions

This page is for contributors who change what an analysis operation computes. It explains how CyteArc stops reusing stored results that a fix makes wrong or outdated, and when a change needs that.

Why revisions exist

An artifact’s identity is its scope, assay, kind, and canonical provenance: the producing operation, its parameters, and its inputs. Planning reuses a complete artifact only when its canonical provenance matches the request exactly. Artifact IDs are random, so an input recorded in provenance is a specific stored result: recomputing an upstream artifact gives every downstream artifact a new identity.

Exact reuse also means that a fix that changes the output of an operation, for unchanged parameters and inputs, would keep returning results of the old code. The operation revision registry in cytearc/storage/operation_revisions.py is the one explicit way to stop that. The CyteArc version recorded in each artifact’s cytearc_version attribute is diagnostic only and never affects reuse.

How a revision changes reuse

An operation with revisions has an ordered tuple of OperationRevision entries; an operation that is not listed is at revision 1. Revision 1 is everything the operation computed before its first entry; entries are numbered 2, 3, and so on. An entry has:

When CyteArc plans an artifact, effective_revision returns the highest revision whose applies holds for the artifact’s kind and serialized parameters and inputs, or 1. Provenance records it as "revision": n only when it is 2 or more. An operation without revisions omits the field. Adding a revision changes only the identities of the artifacts it applies to.

Reuse stays exact. An artifact that records no revision is revision 1, so it is reused only while the effective revision for its parameters is 1. During the same scan, a complete artifact whose provenance differs from the request only in its revision is a superseded match:

A revision also reaches the results built from a superseded artifact, through their inputs rather than their own revisions. A UMAP or a Leiden clustering built on a revision 1 connectivity map records the current revision of its own operation, so ArtifactStatus.is_current, which judges only an artifact’s own revision, is True for it. Its input is never reused, though: it is computed again with a new reference, which gives the result new inputs, so the result is computed again too.

An artifact that records a revision newer than the running release knows is not reused either, and its status is not current. A user may still pass a superseded artifact explicitly as an input; CyteArc accepts it without a warning, and lineage shows it as stale.

When a change needs a revision

An operation that no release has shipped takes no revisions: until a release records it, a change to its name, parameters, inputs, stored arrays or the diagnostics it declares makes the next call compute its artifacts anew, its loader refuses an artifact of the earlier form with a message that names the call which saves it anew, and the first release ships it at revision 1.

Decide with this ladder, in order:

  1. The change only moves results by last-bit or reassociation noise, or breaks exact ties in a stated order where the earlier code left their order unspecified, and old results stay equally valid: add no revision. Each earlier result of a tie-breaking change was one of the equally valid outputs, so it stays valid and is reused. A change to an iterative fit’s stopping rule belongs here too when the earlier results already lie within the precision that rounding allows at the optimum, so that earlier and new results are the optimum as far as the computation can resolve it. Record the change under Results that change while identities stay the same.

  2. Results become materially different, or were wrong, for an identifiable subset of artifacts: add a scoped revision whose applies selects that subset from recorded provenance.

  3. Otherwise: add a whole-operation revision with applies=None.

  4. A new reuse requirement that stops existing artifacts from being reused, such as a new required array or attribute, a new diagnostic (Diagnostics added after a release), or a stricter reuse validator, also adds a revision, so that the log explains the recomputation.

Do not change recorded parameters or inputs to invalidate results. That changes the identity of every artifact the operation writes without telling anyone why its stored results stopped matching. Use the operation revision registry for these changes.

When a new default replaces a computation that callers may still ask for, keep the earlier computation reachable through an argument that the record names, and scope the revision to the records that do not name it. Records of earlier releases name nothing, so the revision supersedes them, while an artifact that asks for the earlier computation by name stays current and is reused. Revision 2 of run_pseudotime_scoring works this way: the untruncated potential became the default, and its predicate selects the pseudotimes that do not record method="truncated".

Diagnostics added after a release

Every artifact saves the diagnostics that its operation declares, and reuse requires them. A diagnostic added to an operation that a release has shipped therefore needs a revision that applies to every artifact, with applies=None, and lists the diagnostic in added_diagnostics. Every artifact computed from that revision on records it or a later revision and saves the diagnostic, so planning computes each artifact of an earlier revision anew and logs why.

An artifact that records an earlier revision and lacks the diagnostic reads it as None, not measured. ArtifactStatus.diagnostics, which ds.artifacts.inspect(ref) and require_complete_artifact read, applies this rule, so such an artifact still serves the calls that pass it explicitly and the runs that reference it. Reading still refuses an artifact that lacks any other declared diagnostic, one that holds a key its operation does not declare, and one without diagnostics, as releases before 1.4.0 saved them. It also refuses an artifact that records the adding revision or a later one and lacks the diagnostic: every such artifact was saved with it, so only damage or a bug can have lost it.

The registry refuses a scoped revision that adds diagnostics, and declare_diagnostics refuses the declaration of an operation when a revision of the operation adds a diagnostic that the declaration lacks. Revision 3 of select_hvgs added selectedDetectionRatio, so a selection that CyteArc 1.4.0 saved reads the ratio as None.

Rules for entries

Add a revision

  1. Append the entry to the operation’s tuple in cytearc/storage/operation_revisions.py, adding the operation if it has no revisions yet, with the next number and the release that will ship it.

  2. Add a test that a new artifact of the operation records the revision, as ArtifactStatus.revision, and that an artifact of the earlier revision is recomputed, not reused. For a scoped revision, also test an artifact that its predicate leaves out.

  3. For a revision that adds diagnostics, also test that an artifact of the earlier revision reads them as None and that an artifact of the new revision without them is refused.

Results that change while identities stay the same

A change that moves results only by rounding or reassociation noise, or that breaks exact ties in a stated order where the earlier code left their order unspecified, needs no operation revision when existing results remain valid: an earlier result of a tie-breaking change is one of the equally valid outputs, so it is reused. Record the affected operations, the release, and the reason reuse remains valid here. A user can request recomputation with invalidate_cache=True.