Skip to content

Commit d067d3a

Browse files
committed
Getting ready for release 0.5.0
1 parent 17d7102 commit d067d3a

7 files changed

+58
-80
lines changed

ANNOUNCE.rst

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
Announcing python-blosc2 0.4.1
1+
Announcing python-blosc2 0.5.0
22
==============================
33

4-
This is a major release introducing new `pack_array2()` and
5-
`unpack_array2()` functions for packing NumPy arrays.
6-
Also, there are new `Scunk.to_cframe()` and `blosc2.from_cframe()`
7-
methods for serializing/deserialzing `SChunk` instances.
8-
9-
Finally, we have added new `Schunk.get_slice()`, `SChunk.__getitem__()`
10-
and `SChunk.__setitem__()` methods for getting/setting slices from/to
11-
`SChunk` instances.
4+
This is a major release introducing new `pack_tensor`, `unpack_tensor`,
5+
`save_tensor` and `load_tensor` functions for serializing/deserializing
6+
PyTorch and TensorFlow tensor objects. They also understand NumPy arrays,
7+
so these are the new recommended ones for serialization.
128

139
For more info, you can have a look at the release notes in:
1410

RELEASE_NOTES.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Release notes
22

3+
## Changes from 0.4.1 to 0.5.0
4+
5+
* New `pack_tensor`, `unpack_tensor`, `save_tensor` and `load_tensor` functions for serializing/deserializing PyTorch and TensorFlow tensor objects. They also understand NumPy arrays, so these are the new recommended ones for serialization.
6+
7+
* ``pack_array2`` do not modify the value of a possible `cparams` parameter anymore.
8+
9+
* The `pack_array2` / `save_array` have changed the serialization format to follow the new standard introduced in `pack_tensor`. In the future `pack_array2` / `save_array` will probably be deprecated, so please change to `pack_tensor` / `save_tensor` as soon as you can.
10+
11+
* The new 'standard' for serialization relies on using the '__pack_tensor__' attribute as a `vlmeta` (variable length) metalayer.
12+
13+
314
## Changes from 0.4.0 to 0.4.1
415

516
* Add `msgpack` as a runtime requirement

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.1
1+
0.5.0

bench/pack_compress.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import blosc2
1717

1818

19-
NREP = 1
19+
NREP = 3
2020
N = int(2e8)
2121
Nexp = np.log10(N)
2222

bench/pack_tensor.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020

2121
NREP = 1
22-
# N = int(4e8 - 2**27) # larger than 2 GB
22+
# N = int(5e8 + 2**27) # larger than 2 GB
23+
# Using tensors > 2 GB makes tensorflow serialization to raise this error:
24+
# [libprotobuf FATAL google/protobuf/io/coded_stream.cc:831] CHECK failed: overrun <= kSlopBytes:
2325
N = int(1e8)
2426

2527
store = True
@@ -78,8 +80,6 @@
7880
c = None
7981
ctic = time.time()
8082
for i in range(NREP):
81-
# _in = np.asarray(memoryview(tt))
82-
# c = blosc2.pack_array2(_in, cparams=cparams)
8383
c = blosc2.pack_tensor(in_, cparams=cparams)
8484
ctoc = time.time()
8585
tc = (ctoc - ctic) / NREP
@@ -96,8 +96,6 @@
9696
c = None
9797
ctic = time.time()
9898
for i in range(NREP):
99-
#_in = np.asarray(th)
100-
#c = blosc2.pack_array2(_in, cparams=cparams)
10199
c = blosc2.pack_tensor(in_, cparams=cparams)
102100
ctoc = time.time()
103101
tc = (ctoc - ctic) / NREP

examples/slicing_and_beyond.ipynb

+3-5
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"cell_type": "markdown",
103103
"metadata": {},
104104
"source": [
105-
"That's much better!\n",
105+
"That looks better!\n",
106106
"\n",
107107
"## Setting data in a SChunk\n",
108108
"\n",
@@ -194,6 +194,7 @@
194194
"be mindful that you will have to keep a reference to it until you do not\n",
195195
"want the SChunk anymore.\n",
196196
"\n",
197+
"\n",
197198
"## Serializing NumPy arrays\n",
198199
"\n",
199200
"If what you want is to create a serialized, compressed version of a NumPy array, you can use the newer (and faster) functions to store it either in-memory or on-disk. The specification of such a contiguous compressed representation, aka **cframe** can be seen at: https://github.com/Blosc/c-blosc2/blob/main/README_CFRAME_FORMAT.rst.\n",
@@ -232,10 +233,7 @@
232233
"source": [
233234
"blosc2.save_array(np_array, urlpath=\"ondisk_array.b2frame\", mode=\"w\")\n",
234235
"np_array2 = blosc2.load_array(\"ondisk_array.b2frame\")\n",
235-
"np.array_equal(np_array, np_array2)\n",
236-
"\n",
237-
"# Remove it from disk\n",
238-
"blosc2.remove_urlpath(\"ondisk_array.b2frame\")"
236+
"np.array_equal(np_array, np_array2)"
239237
]
240238
},
241239
{

examples/tutorial-basics.ipynb

+34-59
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"storage = {\n",
4848
" \"contiguous\": True,\n",
4949
" \"urlpath\": \"myfile.b2frame\",\n",
50+
" \"mode\": \"w\", # create a file anew\n",
5051
" \"cparams\": cparams,\n",
5152
" \"dparams\": dparams,\n",
5253
"}"
@@ -56,37 +57,19 @@
5657
"cell_type": "markdown",
5758
"metadata": {},
5859
"source": [
59-
"And let's remove a possible existing serialized super-chunk (frame):"
60+
"Now, we can already create a SChunk instance:"
6061
]
6162
},
6263
{
6364
"cell_type": "code",
6465
"execution_count": 3,
6566
"metadata": {},
66-
"outputs": [],
67-
"source": [
68-
"blosc2.remove_urlpath(\"myfile.b2frame\")"
69-
]
70-
},
71-
{
72-
"cell_type": "markdown",
73-
"metadata": {},
74-
"source": [
75-
"Now, we can already create a SChunk!"
76-
]
77-
},
78-
{
79-
"cell_type": "code",
80-
"execution_count": 4,
81-
"metadata": {},
8267
"outputs": [
8368
{
8469
"data": {
85-
"text/plain": [
86-
"<blosc2.SChunk.SChunk at 0x7f71c83a67c0>"
87-
]
70+
"text/plain": "<blosc2.SChunk.SChunk at 0x110def6c0>"
8871
},
89-
"execution_count": 4,
72+
"execution_count": 3,
9073
"metadata": {},
9174
"output_type": "execute_result"
9275
}
@@ -100,7 +83,7 @@
10083
"cell_type": "markdown",
10184
"metadata": {},
10285
"source": [
103-
"Great! So you have created your first super-chunk with your desired compression codec and typesize, and it is going to be persistent on disk."
86+
"Great! So you have created your first super-chunk with your desired compression codec and typesize, that is going to be persistent on-disk."
10487
]
10588
},
10689
{
@@ -114,7 +97,7 @@
11497
},
11598
{
11699
"cell_type": "code",
117-
"execution_count": 5,
100+
"execution_count": 4,
118101
"metadata": {},
119102
"outputs": [],
120103
"source": [
@@ -123,15 +106,15 @@
123106
},
124107
{
125108
"cell_type": "code",
126-
"execution_count": 6,
109+
"execution_count": 5,
127110
"metadata": {},
128111
"outputs": [
129112
{
130113
"name": "stdout",
131114
"output_type": "stream",
132115
"text": [
133-
"CPU times: user 355 ms, sys: 0 ns, total: 355 ms\n",
134-
"Wall time: 69.6 ms\n"
116+
"CPU times: user 312 ms, sys: 790 ms, total: 1.1 s\n",
117+
"Wall time: 333 ms\n"
135118
]
136119
}
137120
],
@@ -144,14 +127,14 @@
144127
},
145128
{
146129
"cell_type": "code",
147-
"execution_count": 7,
130+
"execution_count": 6,
148131
"metadata": {},
149132
"outputs": [
150133
{
151134
"name": "stdout",
152135
"output_type": "stream",
153136
"text": [
154-
"-rw-rw-r-- 1 faltet2 faltet2 11M jun 28 19:03 myfile.b2frame\r\n"
137+
"-rw-r--r-- 1 francesc staff 10M Oct 3 18:29 myfile.b2frame\r\n"
155138
]
156139
}
157140
],
@@ -170,7 +153,7 @@
170153
},
171154
{
172155
"cell_type": "code",
173-
"execution_count": 8,
156+
"execution_count": 7,
174157
"metadata": {},
175158
"outputs": [],
176159
"source": [
@@ -179,15 +162,15 @@
179162
},
180163
{
181164
"cell_type": "code",
182-
"execution_count": 9,
165+
"execution_count": 8,
183166
"metadata": {},
184167
"outputs": [
185168
{
186169
"name": "stdout",
187170
"output_type": "stream",
188171
"text": [
189-
"CPU times: user 65.9 ms, sys: 82 ms, total: 148 ms\n",
190-
"Wall time: 39.5 ms\n"
172+
"CPU times: user 200 ms, sys: 65.8 ms, total: 266 ms\n",
173+
"Wall time: 77 ms\n"
191174
]
192175
}
193176
],
@@ -199,7 +182,7 @@
199182
},
200183
{
201184
"cell_type": "code",
202-
"execution_count": 10,
185+
"execution_count": 9,
203186
"metadata": {},
204187
"outputs": [],
205188
"source": [
@@ -218,7 +201,7 @@
218201
},
219202
{
220203
"cell_type": "code",
221-
"execution_count": 11,
204+
"execution_count": 10,
222205
"metadata": {},
223206
"outputs": [],
224207
"source": [
@@ -228,24 +211,22 @@
228211
},
229212
{
230213
"cell_type": "code",
231-
"execution_count": 12,
214+
"execution_count": 11,
232215
"metadata": {},
233216
"outputs": [
234217
{
235218
"name": "stdout",
236219
"output_type": "stream",
237220
"text": [
238-
"CPU times: user 258 µs, sys: 348 µs, total: 606 µs\n",
239-
"Wall time: 351 µs\n"
221+
"CPU times: user 288 µs, sys: 839 µs, total: 1.13 ms\n",
222+
"Wall time: 1.41 ms\n"
240223
]
241224
},
242225
{
243226
"data": {
244-
"text/plain": [
245-
"100"
246-
]
227+
"text/plain": "100"
247228
},
248-
"execution_count": 12,
229+
"execution_count": 11,
249230
"metadata": {},
250231
"output_type": "execute_result"
251232
}
@@ -264,24 +245,22 @@
264245
},
265246
{
266247
"cell_type": "code",
267-
"execution_count": 13,
248+
"execution_count": 12,
268249
"metadata": {},
269250
"outputs": [
270251
{
271252
"name": "stdout",
272253
"output_type": "stream",
273254
"text": [
274-
"CPU times: user 116 µs, sys: 158 µs, total: 274 µs\n",
275-
"Wall time: 173 µs\n"
255+
"CPU times: user 280 µs, sys: 570 µs, total: 850 µs\n",
256+
"Wall time: 687 µs\n"
276257
]
277258
},
278259
{
279260
"data": {
280-
"text/plain": [
281-
"101"
282-
]
261+
"text/plain": "101"
283262
},
284-
"execution_count": 13,
263+
"execution_count": 12,
285264
"metadata": {},
286265
"output_type": "execute_result"
287266
}
@@ -311,16 +290,14 @@
311290
},
312291
{
313292
"cell_type": "code",
314-
"execution_count": 14,
293+
"execution_count": 13,
315294
"metadata": {},
316295
"outputs": [
317296
{
318297
"data": {
319-
"text/plain": [
320-
"{'info1': 'This is an example', 'info2': 'of user meta handling'}"
321-
]
298+
"text/plain": "{b'info1': 'This is an example', b'info2': 'of user meta handling'}"
322299
},
323-
"execution_count": 14,
300+
"execution_count": 13,
324301
"metadata": {},
325302
"output_type": "execute_result"
326303
}
@@ -340,16 +317,14 @@
340317
},
341318
{
342319
"cell_type": "code",
343-
"execution_count": 15,
320+
"execution_count": 14,
344321
"metadata": {},
345322
"outputs": [
346323
{
347324
"data": {
348-
"text/plain": [
349-
"{'info2': 'of user meta handling'}"
350-
]
325+
"text/plain": "{b'info2': 'of user meta handling'}"
351326
},
352-
"execution_count": 15,
327+
"execution_count": 14,
353328
"metadata": {},
354329
"output_type": "execute_result"
355330
}
@@ -363,7 +338,7 @@
363338
"cell_type": "markdown",
364339
"metadata": {},
365340
"source": [
366-
"That's all for now. There are more examples in the examples directory for you to explore. Enjoy!"
341+
"That's all for now. There are more examples in the `examples/` directory for you to explore. Enjoy!"
367342
]
368343
}
369344
],

0 commit comments

Comments
 (0)