diff --git a/src/explanation/computation-model.md b/src/explanation/computation-model.md index 4cd8942a..4cbe8f25 100644 --- a/src/explanation/computation-model.md +++ b/src/explanation/computation-model.md @@ -207,8 +207,11 @@ class SignalAverage(dj.Computed): avg_signal : float64 """ - def make_fetch(self, key): - """Step 1: Fetch input data (outside transaction)""" + def make_fetch(self, key, **kwargs): + """Step 1: Fetch input data (outside transaction). + + kwargs are passed from populate(make_kwargs={...}). + """ raw_signal = (RawSignal & key).fetch1("signal") return (raw_signal,) diff --git a/src/how-to/run-computations.md b/src/how-to/run-computations.md index e535544e..5f00f9b5 100644 --- a/src/how-to/run-computations.md +++ b/src/how-to/run-computations.md @@ -199,8 +199,11 @@ class LongComputation(dj.Computed): result : float64 """ - def make_fetch(self, key): - """Fetch input data (outside transaction)""" + def make_fetch(self, key, **kwargs): + """Fetch input data (outside transaction). + + kwargs are passed from populate(make_kwargs={...}). + """ data = (RawData & key).fetch1('data') return (data,) diff --git a/src/reference/specs/autopopulate.md b/src/reference/specs/autopopulate.md index b4c907f6..7b616728 100644 --- a/src/reference/specs/autopopulate.md +++ b/src/reference/specs/autopopulate.md @@ -334,8 +334,11 @@ class HeavyComputation(dj.Computed): result : """ - def make_fetch(self, key): - """Fetch all required data (runs in transaction).""" + def make_fetch(self, key, **kwargs): + """Fetch all required data (runs in transaction). + + kwargs are passed from populate(make_kwargs={...}). + """ return (Recording & key).fetch1('raw_data') def make_compute(self, key, data): @@ -393,6 +396,15 @@ class ConfigurableAnalysis(dj.Computed): ConfigurableAnalysis.populate(make_kwargs={'threshold': 0.8}) ``` +**Tripartite pattern:** When using the method-based tripartite pattern, `make_kwargs` are passed to `make_fetch()`: + +```python +def make_fetch(self, key, verbose=False, **kwargs): + if verbose: + print(f"Fetching {key}") + return (Source & key).fetch1('data') +``` + **Anti-pattern warning:** Passing arguments that affect the computed result breaks reproducibility—all inputs should come from `fetch` calls inside `make()`. If a parameter affects results, it should be stored in a lookup table and referenced via foreign key. **Acceptable use:** Directives that don't affect results, such as: @@ -973,8 +985,8 @@ def make(self, key): yield # Re-acquire transaction self.insert1({**key, 'result': result}) -# Tripartite (methods) -def make_fetch(self, key): return data +# Tripartite (methods) - kwargs passed to make_fetch +def make_fetch(self, key, **kwargs): return data def make_compute(self, key, data): return result def make_insert(self, key, result): self.insert1(...) ```