Commit ecc2d77
authored
fix(store): don't close a shared filesystem in FsspecStore.close() (#4165)
* fix: byte-order handling for structured dtypes in the bytes codec (#220)
* fix: byte-order handling for structured dtypes in the bytes codec
The bytes codec neither byte-swapped structured-dtype fields to its
configured endian on encode (numpy reports byteorder '|' for void
dtypes, so the top-level byteorder comparison never detected a
mismatch) nor honored its endian when decoding, silently corrupting
any structured data whose field byte order differed from the stored
one (e.g. virtual references to external big-endian data).
Encode now detects byte-order mismatches by comparing full dtypes via
newbyteorder, and decode reinterprets raw bytes in the stored byte
order before converting to the data type's declared byte order, so the
stored layout (codec state) and the in-memory layout (array data type)
are independent.
Closes #4141
Assisted-by: ClaudeCode:claude-fable-5
* test: fold structured byte-order cases into existing bytes codec tests
Extend test_endian's parametrization with structured dtypes and
test_bytes_codec_sync_roundtrip with endian/dtype parametrization plus
stored-layout and decoded-dtype assertions, instead of adding parallel
test functions for the same properties.
Assisted-by: ClaudeCode:claude-fable-5
* refactor: rename stored_dtype to view_dtype in BytesCodec decode
The variable is the dtype used to view the raw chunk bytes (byte order
from the codec's endian configuration), not a property of the stored
data or of the returned buffer, which always carries the array's
declared dtype.
Assisted-by: ClaudeCode:claude-fable-5
* docs: note that the decode-side byte-order conversion copies the chunk
Assisted-by: ClaudeCode:claude-fable-5
* fix(store): FsspecStore.close() no longer closes the filesystem
FsspecStore.close() closed the underlying filesystem's session, on the
premise that a store built by from_url "owns" the filesystem it created.
That premise does not hold: fsspec caches and shares filesystem
instances across callers (its instance cache keys on storage options,
not path), and users can hand one filesystem to many stores directly.
Closing one store therefore killed the session that sibling stores were
still using, and left the dead filesystem in fsspec's cache for later
callers.
Determining whether a filesystem is actually shared requires reaching
into fsspec's private instance cache (_cache, _fs_token, cachable) and
walking wrapper chains for caching/proxy filesystems — an implementation
detail that leaks upward and that we would have to keep in sync with
fsspec forever, getting it subtly wrong in between. The wrapper case
alone (simplecache::/dir://) already slipped through a cache-membership
check.
The filesystem's lifecycle is simply not the store's to manage. This
removes the ownership model added in the unreleased gh-4003: no _owns_fs,
no _close_fs, no ownership transfer in with_read_only, and close() just
marks the store not-open. The only thing given up is suppressing an
"Unclosed client session" ResourceWarning, which was true anyway — the
session belongs to a cached filesystem that outlives the store.
Since gh-4003 never shipped (latest release is v3.2.1), its changelog
fragment is removed rather than superseded.
Assisted-by: ClaudeCode:claude-opus-4.8
* test: skip with_read_only fs test when AsyncFileSystemWrapper is absent
test_with_read_only_shares_filesystem replaced an ownership test that
carried a guard for fsspec < 2024.12.0, and the guard was dropped in the
rewrite. The test still opens a file:// URL, which needs
AsyncFileSystemWrapper, so it failed the min_deps job.
Assisted-by: ClaudeCode:claude-opus-4.8
* docs: correct changelog claim about gh-4003 release status
The fragment said gh-4003 was unreleased with no net change for
released versions. Its text is already in the staged 3.3.0 release
notes, so the revert is a real behavior change for anyone relying on
close() releasing the session.
Assisted-by: ClaudeCode:claude-opus-4.8
* docs: remove changelog entry for unreleased versions1 parent ab76998 commit ecc2d77
2 files changed
Lines changed: 47 additions & 157 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
22 | | - | |
23 | | - | |
24 | 21 | | |
25 | 22 | | |
26 | 23 | | |
| |||
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | 38 | | |
62 | 39 | | |
63 | 40 | | |
| |||
126 | 103 | | |
127 | 104 | | |
128 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
129 | 115 | | |
130 | 116 | | |
131 | 117 | | |
| |||
152 | 138 | | |
153 | 139 | | |
154 | 140 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | 141 | | |
159 | 142 | | |
160 | 143 | | |
| |||
220 | 203 | | |
221 | 204 | | |
222 | 205 | | |
223 | | - | |
224 | | - | |
225 | | - | |
| 206 | + | |
| 207 | + | |
226 | 208 | | |
227 | 209 | | |
228 | 210 | | |
229 | 211 | | |
230 | 212 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | 213 | | |
235 | 214 | | |
236 | 215 | | |
| |||
272 | 251 | | |
273 | 252 | | |
274 | 253 | | |
275 | | - | |
276 | | - | |
277 | | - | |
| 254 | + | |
278 | 255 | | |
279 | 256 | | |
280 | 257 | | |
281 | | - | |
| 258 | + | |
282 | 259 | | |
283 | 260 | | |
284 | 261 | | |
285 | 262 | | |
286 | 263 | | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | 264 | | |
309 | 265 | | |
310 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
| 279 | + | |
280 | 280 | | |
281 | | - | |
282 | | - | |
| 281 | + | |
| 282 | + | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | 287 | | |
302 | 288 | | |
303 | 289 | | |
304 | 290 | | |
305 | 291 | | |
306 | 292 | | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | 293 | | |
349 | 294 | | |
350 | 295 | | |
| |||
574 | 519 | | |
575 | 520 | | |
576 | 521 | | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
| 522 | + | |
| 523 | + | |
583 | 524 | | |
584 | | - | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
585 | 534 | | |
586 | | - | |
587 | | - | |
588 | | - | |
| 535 | + | |
589 | 536 | | |
590 | | - | |
| 537 | + | |
591 | 538 | | |
592 | | - | |
593 | | - | |
594 | 539 | | |
| 540 | + | |
| 541 | + | |
595 | 542 | | |
596 | | - | |
597 | | - | |
598 | | - | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
599 | 551 | | |
600 | | - | |
| 552 | + | |
601 | 553 | | |
602 | | - | |
603 | | - | |
| 554 | + | |
604 | 555 | | |
605 | 556 | | |
606 | 557 | | |
607 | 558 | | |
608 | 559 | | |
609 | 560 | | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
| 561 | + | |
| 562 | + | |
618 | 563 | | |
619 | 564 | | |
620 | 565 | | |
621 | 566 | | |
622 | 567 | | |
623 | 568 | | |
624 | 569 | | |
625 | | - | |
626 | 570 | | |
627 | 571 | | |
628 | 572 | | |
629 | 573 | | |
630 | 574 | | |
631 | 575 | | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
| 576 | + | |
| 577 | + | |
641 | 578 | | |
642 | | - | |
643 | 579 | | |
644 | 580 | | |
645 | 581 | | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | 582 | | |
| 583 | + | |
| 584 | + | |
651 | 585 | | |
652 | 586 | | |
653 | 587 | | |
| |||
0 commit comments