Skip to content

Commit 68fdea5

Browse files
fix(provenance): capture defaults to off (#1568)
`provenance.capture` shipped defaulting to True, so upgrading to 2.3.4 would have changed the DDL of every Entry table declared afterwards. That is a deployment's decision, not a library default. It also makes the pair consistent: `jobs.add_job_metadata` already defaults to False for the same reason, and both add a hidden column at declaration. The platform turns capture on per project through the usual channels -- DJ_PROVENANCE_CAPTURE, the config file, or the secrets directory. Nothing else changes: a table declared with capture on still records on insert, and deploy.add_prov_column still retrofits one declared without it.
1 parent 74f72ad commit 68fdea5

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

‎src/datajoint/deploy.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ def add_prov_column(target: "TargetType", dry_run: bool = True) -> dict:
190190
"""
191191
Add the hidden ``_prov`` attribute to Entry (``dj.Manual``) tables that lack it.
192192
193-
Capture defaults on, so tables declared from 2.3.4 onward already carry the
194-
slot. Two populations do not: tables declared before 2.3.4, and tables
195-
declared while ``config.provenance.capture`` was off. Inserts into those
196-
record nothing, silently, and this brings them in line.
193+
Capture defaults off, so a table carries the slot only if it was declared
194+
while ``config.provenance.capture`` was on. Every other table -- declared
195+
before 2.3.4, or before the deployment enabled capture -- records nothing on
196+
insert, silently, and this brings it in line.
197197
198198
It belongs here rather than in :mod:`datajoint.migrate` because it is not a
199199
one-shot correction of legacy state. It is idempotent — a table that already

‎src/datajoint/settings.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,11 @@ class ProvenanceSettings(BaseSettings):
323323
)
324324

325325
capture: bool = Field(
326-
default=True,
326+
default=False,
327327
description="Add the hidden `_prov` attribute to Entry (dj.Manual) tables at declaration "
328-
"and fill it on insert. Tables declared while this is False never receive the column; "
328+
"and fill it on insert. Off by default, matching jobs.add_job_metadata: enabling it changes "
329+
"the DDL of every Entry table declared afterwards, which is a deployment's decision rather "
330+
"than a library default. Tables declared while this is False never receive the column; "
329331
"use datajoint.deploy.add_prov_column to add it to an existing table.",
330332
)
331333
source: dict[str, Any] = Field(

‎tests/unit/test_provenance.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,14 @@ def test_payload_survives_unserializable_key_values(config):
120120
assert rendered["context"]["key"]["who"] == "12345678-1234-5678-1234-567812345678"
121121

122122

123-
def test_settings_defaults_to_capturing():
124-
"""A slot nobody can rely on is a slot nobody codes against."""
125-
assert Config().provenance.capture is True
123+
def test_settings_default_to_not_capturing():
124+
"""Off by default, like `jobs.add_job_metadata`.
125+
126+
Capture changes the DDL of every Entry table declared afterwards. A library
127+
default that does that would make an upgrade to 2.3.4 alter what a schema
128+
declares, so the deployment turns it on.
129+
"""
130+
assert Config().provenance.capture is False
126131
assert Config().provenance.source == {}
127132

128133

0 commit comments

Comments
 (0)