Skip to content

Commit cdefe87

Browse files
committed
Update attach page
1 parent 9ce679c commit cdefe87

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

docs/src/design/tables/attach.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,59 @@
1-
# File Attachment Datatype
1+
# External Data
22

3-
## Configuration & usage
3+
## File Attachment Datatype
44

5-
<!-- Since https://github.com/datajoint/datajoint-python/issues/480 -->
5+
### Configuration & Usage
66

7-
The `attach` attribute type allows users to `attach` files into DataJoint
7+
Corresponding to issue
8+
[#480](https://github.com/datajoint/datajoint-python/issues/480),
9+
the `attach` attribute type allows users to `attach` files into DataJoint
810
schemas as DataJoint-managed files. This is in contrast to traditional `blobs`
911
which are encodings of programming language data structures such as arrays.
1012

1113
The functionality is modeled after email attachments, where users `attach`
12-
a file along with a message, and message recipients have access to a
14+
a file along with a message and message recipients have access to a
1315
copy of that file upon retrieval of the message.
1416

1517
For DataJoint `attach` attributes, DataJoint will copy the input
16-
file into a DataJoint store, hashing the file contents and tracking
18+
file into a DataJoint store, hash the file contents, and track
1719
the input file name. Subsequent `fetch` operations will transfer a
18-
copy of the file to the local directory of the python process and
20+
copy of the file to the local directory of the Python process and
1921
return a pointer to it's location for subsequent client usage. This
2022
allows arbitrary files to be `uploaded` or `attached` to a DataJoint
2123
schema for later use in processing. File integrity is preserved by
22-
checksumming the data upon attachment and verifying the contents
24+
checksum comparison against the attachment data and verifying the contents
2325
during retrieval.
2426

2527
For example, given a `localattach` store:
2628

27-
```json
29+
```python
2830
dj.config['stores'] = {
29-
'localattach': {
30-
'protocol': 'file',
31-
'location': '/data/attach',
32-
}
31+
'localattach': {
32+
'protocol': 'file',
33+
'location': '/data/attach'
34+
}
3335
}
3436
```
3537

36-
A `ScanAttachment` table can be created::
38+
A `ScanAttachment` table can be created:
3739

3840
```python
3941
@schema
4042
class ScanAttachment(dj.Manual):
41-
definition = """
42-
-> Session
43-
---
44-
scan_image: attach@localattach # attached image scans
45-
"""
43+
definition = """
44+
-> Session
45+
---
46+
scan_image: attach@localattach # attached image scans
47+
"""
4648
```
4749

4850
Files can be added using an insert pointing to the source file:
4951

5052
```python
51-
ScanAttachment.insert1((0, '/input/image0.tif'))
53+
>>> ScanAttachment.insert1((0, '/input/image0.tif'))
5254
```
5355

54-
And then retrieved to the current directory using fetch:
56+
And then retrieved to the current directory using `fetch`:
5557

5658
```python
5759
>>> s0 = (ScanAttachment & {'session_id': 0}).fetch1()

0 commit comments

Comments
 (0)