Skip to content

Commit b49153d

Browse files
committed
Reverted default write_checksums behavior to True
1 parent b3e4598 commit b49153d

6 files changed

Lines changed: 11 additions & 13 deletions

File tree

asdf/_block/io.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def callback():
276276

277277

278278
def generate_write_header(
279-
data, stream=False, compression_kwargs=None, padding=False, fs_block_size=1, write_checksum=False, **header_kwargs
279+
data, stream=False, compression_kwargs=None, padding=False, fs_block_size=1, write_checksum=True, **header_kwargs
280280
):
281281
"""
282282
Generate a dict representation of a ASDF block header that can be
@@ -309,7 +309,7 @@ def generate_write_header(
309309
The filesystem block size. See the `asdf.util.calculate_padding`
310310
``block_size`` argument for more details.
311311
312-
write_checksum: bool, optional, default False
312+
write_checksum: bool, optional
313313
Compute and write the checksum of the block data.
314314
If disabled then the checksum field is set to 0.
315315
@@ -377,7 +377,7 @@ def generate_write_header(
377377

378378

379379
def write_block(
380-
fd, data, offset=None, stream=False, compression_kwargs=None, padding=False, write_checksum=False, **header_kwargs
380+
fd, data, offset=None, stream=False, compression_kwargs=None, padding=False, write_checksum=True, **header_kwargs
381381
):
382382
"""
383383
Write an ASDF block.
@@ -400,7 +400,7 @@ def write_block(
400400
padding : bool, optional, default False
401401
Optionally pad the block data. See `generate_write_header`.
402402
403-
write_checksum: bool, optional, default False
403+
write_checksum: bool, optional
404404
Compute and write the checksum of the block data.
405405
If disabled then the checksum field is set to 0.
406406

asdf/_block/manager.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,8 @@ def update(self, new_tree_size, pad_blocks, include_block_index, write_checksums
605605
If a streamed_block is provided (or the file is not
606606
seekable) no block index will be written.
607607
608-
write_checksums: bool or None, optional
608+
write_checksums: bool, optional
609609
Compute and write block checksums to the file.
610-
If `None` then checksums will be written if the existing blocks
611-
in the file contain checksums. Otherwise defaults to `False`.
612610
613611
Raises
614612
------

asdf/_block/writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def data_bytes(self):
2929
return np.ndarray(0, np.uint8)
3030

3131

32-
def write_blocks(fd, blocks, padding=False, streamed_block=None, write_index=True, write_checksums=False):
32+
def write_blocks(fd, blocks, padding=False, streamed_block=None, write_index=True, write_checksums=True):
3333
"""
3434
Write a list of WriteBlocks to a file
3535

asdf/_tests/_block/test_io.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ def test_write_block(tmp_path):
140140
+ b"\0\0\0\0\0\0\0\0" # allocated size
141141
+ b"\0\0\0\0\0\0\0\0" # used size
142142
+ b"\0\0\0\0\0\0\0\0" # data size
143-
+ b"\0" * 16 # checksum is disabled
144-
# + b"\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\t\x98\xec\xf8B~" # checksum
143+
+ b"\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\t\x98\xec\xf8B~" # checksum
145144
)
146145

147146
# first write out a file with a block

asdf/_tests/_block/test_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_update_outside_context(tmp_path):
7676
with asdf.open(fn) as af:
7777
m = af._blocks
7878
with pytest.raises(OSError, match=r"update called outside of valid write_context"):
79-
m.update(0, pad_blocks=False, include_block_index=False, write_checksums=None)
79+
m.update(0, pad_blocks=False, include_block_index=False, write_checksums=False)
8080

8181

8282
def test_input_compression(tmp_path):

asdf/_tests/_block/test_reader.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def check(blocks):
5757
@pytest.mark.parametrize("validate_checksums", [True, False])
5858
@pytest.mark.parametrize("padding", [0, 3, 4, 5])
5959
@pytest.mark.parametrize("streamed", [True, False])
60-
def test_read(tmp_path, lazy_load, memmap, with_index, validate_checksums, padding, streamed):
60+
@pytest.mark.parametrize("write_checksums", [True, False])
61+
def test_read(tmp_path, lazy_load, memmap, with_index, validate_checksums, padding, streamed, write_checksums):
6162
fn = tmp_path / "test.bin"
6263
n = 5
6364
size = 10
@@ -68,7 +69,7 @@ def test_read(tmp_path, lazy_load, memmap, with_index, validate_checksums, paddi
6869
padding=padding,
6970
with_index=with_index,
7071
streamed=streamed,
71-
write_checksums=validate_checksums,
72+
write_checksums=write_checksums,
7273
) as (fd, check):
7374
r = read_blocks(fd, memmap=memmap, lazy_load=lazy_load, validate_checksums=validate_checksums)
7475
if lazy_load and with_index and not streamed:

0 commit comments

Comments
 (0)