Skip to content

Commit ba8b85b

Browse files
Merge pull request #859 from ixcat/issue-761
0.13 enable_python_native_blobs -> True (#761)
2 parents 187f188 + 6006209 commit ba8b85b

File tree

8 files changed

+14
-18
lines changed

8 files changed

+14
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Support DataJoint datatype and connection plugins (#715, #729) PR 730, #735
55
* Allow updating specified secondary attributes using `update1` PR #763
66
* add dj.key_hash reference to dj.hash.key_hash, treat as 'public api'
7+
* default enable_python_native_blobs to True
78

89
### 0.12.8 -- Jan 12, 2021
910
* table.children, .parents, .descendents, and ancestors can return queryable objects. PR #833

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ Some Python datatypes such as dicts were coerced into numpy recarrays and then f
3232
However, since some Python types were coerced into MATLAB types, old blobs and new blobs may now be fetched as different types of objects even if they were inserted the same way.
3333
For example, new `dict` objects will be returned as `dict` while the same types of objects inserted with `datajoint 0.11` will be recarrays.
3434

35-
Since this is a big change, we chose to disable full blob support by default as a temporary precaution, which will be removed in version 0.13.
35+
Since this is a big change, we chose to temporarily disable this feature by default in DataJoint for Python 0.12.x, allowing users to adjust their code if necessary.
36+
From 13.x, the flag will default to True (on), and will ultimately be removed when corresponding decode support for the new format is added to datajoint-matlab (see: datajoint-matlab #222, datajoint-python #765).
3637

37-
You may enable it by setting the `enable_python_native_blobs` flag in `dj.config`.
38+
The flag is configured by setting the `enable_python_native_blobs` flag in `dj.config`.
3839

3940
```python
4041
import datajoint as dj
@@ -68,7 +69,7 @@ as structured arrays, whereas new record inserted in DataJoint 0.12 with
6869
appropriate native python type (dict, etc).
6970
Furthermore, DataJoint for MATLAB does not yet support unpacking native Python datatypes.
7071

71-
With `dj.config["enable_python_native_blobs"]` set to `False` (default),
72+
With `dj.config["enable_python_native_blobs"]` set to `False`,
7273
any attempt to insert any datatype other than a numpy array will result in an exception.
7374
This is meant to get users to read this message in order to allow proper testing
7475
and migration of pre-0.12 pipelines to 0.12 in a safe manner.

datajoint/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
'display.width': 14,
4646
'display.show_tuple_count': True,
4747
'database.use_tls': None,
48-
'enable_python_native_blobs': False, # python-native/dj0 encoding support
48+
'enable_python_native_blobs': True, # python-native/dj0 encoding support
4949
})
5050

5151
logger = logging.getLogger(__name__)

tests/schema_external.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import numpy as np
1010

1111
schema = dj.Schema(PREFIX + '_extern', connection=dj.conn(**CONN_INFO))
12-
dj.config['enable_python_native_blobs'] = True
1312

1413

1514
stores_config = {
@@ -134,4 +133,4 @@ class FilepathS3(dj.Manual):
134133
img : filepath@repo_s3 # managed files
135134
"""
136135

137-
dj.errors._switch_filepath_types(False)
136+
dj.errors._switch_filepath_types(False)

tests/test_blob_migrate.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from . import S3_CONN_INFO, S3_MIGRATE_BUCKET
88
from . import CONN_INFO
99
from datajoint.migrate import _migrate_dj011_blob
10-
dj.config['enable_python_native_blobs'] = True
1110

1211

1312
class TestBlobMigrate:

tests/test_fetch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import warnings
88
from . import schema
99
import datajoint as dj
10-
dj.config['enable_python_native_blobs'] = True
1110

1211

1312
class TestFetch:

tests/test_fetch_same.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import datajoint as dj
55

66
schema = dj.Schema(PREFIX + '_fetch_same', connection=dj.conn(**CONN_INFO))
7-
dj.config['enable_python_native_blobs'] = True
87

98

109
@schema
@@ -19,14 +18,13 @@ class ProjData(dj.Manual):
1918
"""
2019

2120

22-
with dj.config(enable_python_native_blobs=True):
23-
ProjData().insert([
24-
{'id': 0, 'resp': 20.33, 'sim': 45.324, 'big': 3, 'blah': 'yes'},
25-
{'id': 1, 'resp': 94.3, 'sim': 34.23,
26-
'big': {'key1': np.random.randn(20, 10)}, 'blah': 'si'},
27-
{'id': 2, 'resp': 1.90, 'sim': 10.23,
28-
'big': np.random.randn(4, 2), 'blah': 'sim'}
29-
])
21+
ProjData().insert([
22+
{'id': 0, 'resp': 20.33, 'sim': 45.324, 'big': 3, 'blah': 'yes'},
23+
{'id': 1, 'resp': 94.3, 'sim': 34.23,
24+
'big': {'key1': np.random.randn(20, 10)}, 'blah': 'si'},
25+
{'id': 2, 'resp': 1.90, 'sim': 10.23,
26+
'big': np.random.randn(4, 2), 'blah': 'sim'}
27+
])
3028

3129

3230
class TestFetchSame:

tests/test_jobs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import random
55
import string
66
import datajoint as dj
7-
dj.config['enable_python_native_blobs'] = True
87

98
subjects = schema.Subject()
109

0 commit comments

Comments
 (0)