Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ nav:
- Distributed Computing: tutorials/advanced/distributed.ipynb
- Custom Codecs: tutorials/advanced/custom-codecs.ipynb
- Instances: tutorials/advanced/instances.ipynb
- Three-Part make(): tutorials/advanced/three-part-make.ipynb
- How-To:
- how-to/index.md
- Setup:
Expand Down
16 changes: 10 additions & 6 deletions src/how-to/run-computations.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,19 @@ class LongComputation(dj.Computed):
data = (RawData & key).fetch1('data')
return (data,)

def make_compute(self, key, fetched):
"""Perform computation (outside transaction)"""
(data,) = fetched
def make_compute(self, key, data):
"""Perform computation (outside transaction).

`data` is make_fetch's returned tuple, unpacked positionally.
"""
result = expensive_computation(data)
return (result,)

def make_insert(self, key, fetched, computed):
"""Insert results (inside brief transaction)"""
(result,) = computed
def make_insert(self, key, result):
"""Insert results (inside a brief transaction).

`result` is make_compute's returned tuple, unpacked positionally.
"""
self.insert1({**key, 'result': result})
```

Expand Down
Loading
Loading