Recorded provenance: code identity by default, and a source record on Ingest tables
I maintainer di solito rispondono entro 5 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- git, python
- Ambito
- data-engineering, databases, documentation
Direzione di ricerca
Start with src/datajoint/jobs.py, src/datajoint/autopopulate.py, and src/datajoint/provenance.py, then review src/datajoint/declare.py, deploy.py, and table.py for schema and insert behavior. Run tests/integration/test_hidden_job_metadata.py and tests/integration/test_entry_provenance.py to reproduce the described cases before changing behavior. Done means the agreed defaults, transactional metadata, code identity, and Ingest source records are covered by tests and the affected documentation matches the implemented behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A row written by make() records the identity of the code that produced it, in the transaction that inserts the row. A row that enters from outside the pipeline records where it came from: an Entry row (dj.Manual), and an Ingest row (dj.Imported) whose make() reads a file, instrument, or API the pipeline does not track. Both records are readable through the query API. Foreign keys already establish which rows a result was computed from. They do not say which commit computed it or which file an imported row was read from, and neither fact can be recovered after the insert, so a pipeline author who needs either one a year later has it only if the library recorded it by default. Today the code version is recorded only when two settings are turned on, names the working directory's commit, and is written after the population transaction commits; Ingest rows carry no origin record; and several docs pages state these records as unconditional.
Every finding below was read, not run: each comes from reading master at b2994e5e and the docs at b68b6cc6. Items 1, 2, 4, and 6 describe runtime behaviour and carry a reproduction sketch, which is the test to write first and should fail before its fix. Items 3 and 5 are configuration defaults pinned by existing tests.
What is recorded today, where, and the smallest change
The sketches share two tables:
@schema
class Src(dj.Lookup):
definition = "src_id : int16"
contents = [(1,)]
@schema
class Comp(dj.Compute):
definition = """
-> Src
---
val : int32
"""
def make(self, key):
self.insert1({**key, "val": 1})
-
1. The recorded version names the working directory's commit, abbreviated, with no mark for uncommitted changes.
_get_job_versionrunsgit rev-parse --short HEADwith nocwd(src/datajoint/jobs.py:49-55), so a worker started outside the pipeline's checkout records another repository's commit, or'', which is also the value for "not configured" (jobs.py:45-46,:55-57). The value is resolved separately for the reservation (jobs.py:492), the ingesting context (autopopulate.py:695), the metadata update (:745), and each insert that records_prov(src/datajoint/provenance.py:113), and the results can differ within one job. No test pins it:tests/integration/test_hidden_job_metadata.py:181-182accepts any string.- Change: resolve once per process from the repository of the module that defines the table class, as the full hash with a
-dirtysuffix; accept a deployment-supplied version string for installs without a checkout; log a warning whengitfails._job_versionkeeps''as its empty default: the empty default of a string attribute is the empty string, neverNULL, so a reader tests one value (Table Definition Syntax, "Defaults"; datajoint/datajoint-docs#271). - Compatibility: none for code. Recorded values change form, within
varchar(64). - Read, not run. Reproduction:
# jobs.add_job_metadata = True, jobs.version_method = "git" monkeypatch.chdir(other_repo) # a second checkout with its own HEAD Comp.populate() (version,) = Comp.connection.query(f"SELECT _job_version FROM {Comp.full_table_name}").fetchone() assert version.startswith(head_of_repo_defining_Comp) # today: the short HEAD of other_repo - Change: resolve once per process from the repository of the module that defines the table class, as the full hash with a
-
2. Job metadata is written by an
UPDATEafter the population transaction commits._populate1commits atsrc/datajoint/autopopulate.py:734, then calls_update_job_metadata(:742), which runsUPDATE ... SET _job_start_time, _job_duration, _job_versionin autocommit (:881-885). Other sessions read the row before its version is set, and a worker killed between the two statements leaves the row with null times and''permanently.test_metadata_populated_after_make(tests/integration/test_hidden_job_metadata.py:166) covers only the completed case.- Change: move the
UPDATEinto thetrybody aftermake()returns (:697-714), beforecommit_transaction(), so one placement covers the plain and the tripartite paths and a failure rolls the row back. - Compatibility: none.
_job_durationthen excludes commit time. - Read, not run. Reproduction:
# jobs.add_job_metadata = True monkeypatch.setattr(Comp, "_update_job_metadata", raise_error) # stands in for a worker killed after make() with pytest.raises(RuntimeError): Comp.populate() assert len(Comp & "_job_start_time IS NULL") == 0 # today 1: the row is committed without its record - Change: move the
-
3. No code version is recorded under default settings.
jobs.add_job_metadatadefaults toFalse(src/datajoint/settings.py:499-500) andjobs.version_methodtoNone(:491-492). A Compute or Ingest table declared with defaults has no_job_versioncolumn, and one declared with only the first setting stores''in every row. Pinned byTestConfigDisabled.test_no_metadata_when_disabled(tests/integration/test_hidden_job_metadata.py:231).- Change: after items 1 and 2, default both settings on in the next minor release, for newly declared tables.
migrate.add_job_metadata_columns(src/datajoint/migrate.py:639) stays the route for existing tables. - Compatibility: no user code breaks. An unchanged schema declared after the upgrade gains three hidden columns, the effect #1568 kept out of a patch release; a minor release with a release note is the path, and both settings can still be turned off.
- Sketch: declare
Compunder default settings;"_job_version" in Comp().heading._attributesisFalsetoday.
- Change: after items 1 and 2, default both settings on in the next minor release, for newly declared tables.
-
4. Ingest rows record neither the agent nor the external source.
_tier_attributesgrants_provto the Entry tier only (src/datajoint/declare.py:582). Withjobs.add_job_metadataon, an Ingest master gets start time, duration, and version (declare.py:564-568), with no user or host. The job table records host and user at reservation (src/datajoint/jobs.py:479-492), andcomplete()deletes that entry unlessjobs.keep_completedis on (jobs.py:515-528). Pinned bytest_only_entry_tables_get_the_column(tests/integration/test_entry_provenance.py:112, assertion at:124) and the Imported case oftest_platform_attributes_added_per_tier(tests/unit/test_declare_hidden_attribute.py:117). #1547 proposed the slot for Entry and Ingest tables. Its settled design kept Ingest out because job metadata already records agent, time, and version, and #1555 shipped the slot for Entry only. This item adds that job metadata records no agent, and records time and version only when a non-default setting is on.- Change, which needs a decision because it reverses that exclusion: grant
_provto Ingest masters when capture is on, indeclare.py:582and in the Entry-only tier check ofdeploy.add_prov_column(src/datajoint/deploy.py:283). The insert path already fills any table that has the column (src/datajoint/table.py:979-1010), so agent, time, configured source, and version commit with the row. Which file was read is known only insidemake(), so it stays a declared attribute thatmake()writes, and the docs say so (below). - Compatibility: an additive hidden column on newly declared Ingest tables with capture on. The two tests change.
- Read, not run. Reproduction:
# provenance.capture = True @schema class Frame(dj.Ingest): definition = """ -> Src --- mean : float32 """ def make(self, key): self.insert1({**key, "mean": 0.0}) Frame.populate() assert len(Frame & "_prov IS NULL") == 0 # today: unknown column `_prov` - Change, which needs a decision because it reverses that exclusion: grant
-
5. The Entry origin record is off by default, and an insert that cannot record it proceeds without one.
provenance.capturedefaults toFalse(src/datajoint/settings.py:517-518, pinned bytest_settings_default_to_not_capturing,tests/unit/test_provenance.py:123). A table declared without the column is skipped with no message (src/datajoint/table.py:989-992), and rows present beforedeploy.add_prov_columnkeep null.- Change: default capture on in the minor release that carries item 3, for newly declared tables. Until then the docs qualify every "every Manual table" sentence (below).
- Compatibility: as item 3. Newly declared Entry tables gain one hidden nullable column (#1568).
-
6. Turning capture off stops recording on tables that carry the column.
_attach_provenancereturns whenprovenance.captureis false, before it looks for the column (src/datajoint/table.py:987), so a worker whose environment lacks the setting inserts unrecorded rows beside recorded ones. The how-to says such tables keep recording. No test pins either behaviour:tests/integration/test_entry_provenance.py:175covers only the absent column.- Change: correct the how-to sentence and the spec's "At insert". Alternative: record whenever the table has
_provand keepcaptureas the declaration-time switch, which makes the schema, not each worker's environment, decide. - Compatibility: none for the docs change. The alternative resumes recording for a deployment that turned capture off after declaring tables with it.
- Read, not run. Reproduction:
# Subject (dj.Entry, subject_id : int16) declared with provenance.capture = True, then: dj.config.provenance.capture = False Subject.insert1({"subject_id": 2}) assert len(Subject & "_prov IS NULL") == 0 # today 1; the how-to says 0 - Change: correct the how-to sentence and the spec's "At insert". Alternative: record whenever the table has
-
7. The recorded attributes cannot be fetched or projected, and a mapping restriction on one returns every row. Tracked in #1562 (no reader) and #1561 (dropped predicate); #1553 is covered by #1562 and can close. The library's tests read the values with raw SQL (
tests/integration/test_hidden_job_metadata.py:173;_raw_prov,tests/integration/test_entry_provenance.py:104).- Change: none beyond those two issues. They are listed because items 1 to 5 record values that no query can return until both close.
- Compatibility: as stated in #1561, raising on a hidden name changes code that today receives every row.
Docs pages that misstate what is recorded
Paths are under src/ in datajoint-docs, and line numbers are at b68b6cc6.
- Extrinsic Provenance at Entry Tables (
reference/specs/boundary-provenance.md)- Overview (
:5): rows carry_provwhen capture is on and the table has the column. - Motivation (
:13): foreign keys guarantee that the upstream rows exist, not that they are "correct". Name this half "intrinsic provenance", the counterpart of the page's title; same in theprovenance.py:3docstring. - Which Tables Carry It (
:37-38,:45-47): job metadata records start time, duration, and an optional version, not the agent. Delete the sentence that calls an unregistered source "the modeling problem described in Table Declaration"; that page has no such passage. State that an Ingestmake()writes its source's identity to declared attributes. Thedj.Computedrow says provenance is entailed; the code version is recorded. - Content (
:56): "the code version" appears only whenjobs.version_methodis set; say what the value is. - Behavior, At insert (
:129): "while capture is on", per item 6. - Querying (
:195-207): rewrite when #1562 closes.
- Overview (
- Record Data Origin (
how-to/record-data-origin.md): Turn capture on (:15) states the reverse of item 6. Configure the source (:35) promises the code version unconditionally. New section after "What you cannot do, and what to do instead": an Ingestmake()stores the source's path and checksum as required attributes with no default, with an example. - AutoPopulate Specification, §4.3 The make() reproducibility contract (
reference/specs/autopopulate.md): the opening (:309) counts "the recordedmake()code" among a row's inputs, which holds only with job metadata on. Rule 3 (:315) gains the Ingest clause that Computation Model, "Why the contract matters" (explanation/computation-model.md:83-86) already states: an Ingestmake()also reads its external source and records that source's identity in the row. - Hidden Job Metadata in Computed Tables (
reference/specs/job-metadata.md): Hidden Job Metadata Attributes (:23), Setting Interactions (:92-96), Population-time (:143-149), and Implementation Details §2 and §4 follow items 1 to 3. - Table Declaration, §3.4 Hidden Attributes (
reference/specs/table-declaration.md:196-197,:202):_job_versionis described as "Library version that produced the row"; it is the pipeline code's version. With item 2,_job_*is written inside the population transaction. The_provrow gains Ingest if item 4 is adopted. - Configuration (
reference/configuration.md:182-183,:190): the three defaults, when items 3 and 5 ship. - Schema as a Workflow Specification (
explanation/schema-as-workflow-specification.md): Semantics (:115-117) says "Each inserted row records the git hash of themake()source that produced it". Today that needs two settings, and the value is a repository commit. TheAverageFrameexample (:55-60) declares no source attribute. - The Relational Workflow Model (
explanation/relational-workflow-model.md): the imaging example (:36-38) reads a TIFF and records no path or checksum. Lineage and reproducibility (:102-105) calls reproducibility structural and says "The model enforces what other systems merely log"; the foreign keys are enforced, but the code version a reproduction needs is recorded only with two settings on, and origin at entry only with capture on. - Scientific Data Pipelines (
explanation/data-pipelines.md:137-145): theScanInfoexample declares no source attribute. - The Fan-Out Ingestion Pattern (
explanation/fan-out-ingestion.md): "Every row written into aManualtable carries a hidden_provattribute" (:70-71) holds only with capture on; with it off the modeledsource_filecolumn is the only origin record. Thecontextentry is a record, unchecked and without cascade, not "exactly the link the missing foreign key would have carried" (:72-73). TheIngestexample (:33-44) stores no checksum of the file it parsed. - Comparison to Provenance Systems (
explanation/comparison-to-provenance-systems.md:56-64): "on every Manual table", and the same foreign-key sentence. - Data Entry tutorial (
tutorials/basics/03-data-entry.ipynb, line 610 of the notebook JSON): "and the code version" holds only whenjobs.version_methodis set.
Order: correct the record before turning it on by default
- Write the failing tests from the sketches for items 1, 2, 4, and 6.
- Correct the docs sentences that misstate today's behaviour. They depend on no code change.
- Items 2 and 1, in that order. Neither changes a schema.
- Decide item 4 (the slot on Ingest masters) and item 6 (docs or library).
- Close #1562 and #1561, so the recorded values can be queried.
- Items 3 and 5 together in the next minor release, with a release note. Turning the default on before step 3 would spread a value that can name the wrong repository.
- Lingua principale
- Python
- Stelle
- 198
- Fork
- 107
- Merge medio
- 4g 7h
- PR unite (30g)
- 12
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di datajoint/datajoint-python
-
bug triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
datajoint/datajoint-python#1775 ·
I maintainer di solito rispondono entro 5 giorni
-
MySQL: with use_tls=False, 2.3.6 needs the cryptography package to log in to MySQL 8Forse già presa @dimitri-yatsenko l’ha presa 5 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
datajoint/datajoint-python#1750 ·
I maintainer di solito rispondono entro 5 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
datajoint/datajoint-python#1747 ·
I maintainer di solito rispondono entro 5 giorni
-
Reject constant defaults on primary-key attributesForse già presa @godara-alt l’ha presa 4 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
datajoint/datajoint-python#1712 ·
I maintainer di solito rispondono entro 5 giorni
-
Decoding a <blob> value in an unknown format returns None instead of raising an errorForse già presa @godara-alt l’ha presa 9 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
datajoint/datajoint-python#1703 ·
I maintainer di solito rispondono entro 5 giorni
Tutte le issue di datajoint/datajoint-python
Issue simili
-
[Bug]: test_remote_realpath_uses_argument_vector fails on Windows with Python 3.13+ (ntpath.isabs)Forse già presa @gouyu-hou l’ha presa oggi. Apertatriage/confirmed
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
agentscope-ai/agentscope#4397 ·
I maintainer di solito rispondono entro 2 giorni
-
area/profiles area/sessions comp/desktop desktop/chat desktop/sessions P2 type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
NousResearch/hermes-agent#161712 ·
I maintainer di solito rispondono entro 1 giorno
-
[New Check]: postgresql_flexible_server_public_network_access_disabledForse già presa @pouria-l l’ha presa oggi. Apertafeature-request status/needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
prowler-cloud/prowler#13615 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
SACGF/variantgrid#2941 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
linkedin/Liger-Kernel#1730 ·
I maintainer di solito rispondono entro 3 giorni