|
1 |
| -# Make Method |
2 |
| - |
3 |
| -For auto-populated *Imported* and *Computed* tables, a `make` method gives exact |
4 |
| -instructions for generating the content. By making these steps explicit, we keep a |
5 |
| -careful record of data provenance and ensure reproducibility. Data should never be |
6 |
| -entered using the `insert` method directly. |
7 |
| - |
8 |
| -For information on differentiating these data tiers, see the Table Tier section on |
9 |
| -[Automation](../design/tables/tiers#automation-imported-and-computed). |
10 |
| - |
11 |
| -The `make` method receives one argument: the *key*, which represents the upstream table |
12 |
| -entries that need populating. The `key` is a `dict` in Python. |
13 |
| - |
14 |
| -A `make` function should do three things: |
15 |
| - |
16 |
| -1. [Fetch](../query/common-commands#fetch) data from tables upstream in the |
17 |
| -pipeline using the key for restriction. |
18 |
| - |
19 |
| -2. Compute and add any missing attributes to the fields already in the key. |
20 |
| - |
21 |
| -3. [Inserts](../query/common-commands#insert) the entire entity into the |
22 |
| -triggering table. |
23 |
| - |
24 |
| -## Populate |
25 |
| - |
26 |
| -The `make` method is sometimes referred to as the `populate` function because this is |
27 |
| -the class method called to run the `make` method on all relevant keys. |
28 |
| - |
29 |
| -For information on reprocessing keys that resulted in an error, see information |
30 |
| -on the [Jobs table](./distributed). |
31 |
| - |
32 |
| -```python |
33 |
| -Segmentation.populate() |
34 |
| -``` |
| 1 | +# Transactions in Make |
| 2 | + |
| 3 | +Each call of the [make](../compute/make.md) method is enclosed in a transaction. |
| 4 | +DataJoint users do not need to explicitly manage transactions but must be aware of |
| 5 | +their use. |
| 6 | + |
| 7 | +Transactions produce two effects: |
| 8 | + |
| 9 | +First, the state of the database appears stable within the `make` call throughout the |
| 10 | +transaction: |
| 11 | +two executions of the same query will yield identical results within the same `make` |
| 12 | +call. |
| 13 | + |
| 14 | +Second, any changes to the database (inserts) produced by the `make` method will not |
| 15 | +become visible to other processes until the `make` call completes execution. |
| 16 | +If the `make` method raises an exception, all changes made so far will be discarded and |
| 17 | +will never become visible to other processes. |
| 18 | + |
| 19 | +Transactions are particularly important in maintaining |
| 20 | +[group integrity](../design/integrity.md#group-integrity) with |
| 21 | +[master-part relationships](../design/tables/master-part.md). |
| 22 | +The `make` call of a master table first inserts the master entity and then inserts all |
| 23 | +the matching part entities in the part tables. |
| 24 | +None of the entities become visible to other processes until the entire `make` call |
| 25 | +completes, at which point they all become visible. |
0 commit comments