Repository navigation
fix(stores): <filepath@> insert checks stores.filepath_default; folder downloads work on older fsspec - #1731
Open
dimitri-yatsenko wants to merge 2 commits into
Open
dimitri-yatsenko wants to merge 2 commits into
dimitri-yatsenko wants to merge 2 commits into
Conversation
…wnloads on old fsspec - <filepath@> with no store named resolves stores.filepath_default once, and runs the path and existence checks against that store, the one the row records. It used to build the backend from stores.default. - ObjectRef.download() of a folder fetches files one by one on fsspec before 2023.9, where get(list, list) expands the sources as globs. A key ending in '/' becomes a folder. An empty folder that find() does not list (fsspec before 2024.3.1) is created instead of raising. - The <attach> reuse check opens the file with O_NONBLOCK and treats a failed open as a different file, so a pipe swapped in after the lstat check cannot block the fetch. - Tests: symbolic-link and relative store locations, an S3 folder download, and a fixture that restores the datajoint modules after the tests that import it afresh, so tests/unit and tests/integration can run in one session. Fixes #1713.
dimitri-yatsenko
requested review from
MilagrosMarin,
lum-agilyti and
ttngu207
November 21, 2026 01:32
Windows file names cannot contain them; the folder download tests keep the '[' case there.
MilagrosMarin
approved these changes
Nov 28, 2026
MilagrosMarin
left a comment
Contributor
There was a problem hiding this comment.
Thanks @dimitri-yatsenko, this is a careful set of follow-ups.
What I checked locally, with current master merged in:
- Full suite on MySQL and PostgreSQL: 2071 passed, 17 skipped.
- With master's source restored, 8 of the new unit tests fail on current fsspec, as described. The 4
<filepath@>integration tests fail on both backends. - With fsspec 2023.1.0 actually installed (not just the version reported), the new unit tests all pass. With master's source, 9 fail, including
test_download_folder_keys_with_glob_characters, so that test does guard the real old-fsspec case.
Two small wording notes from probing fsspec 2023.1.0 through 2024.3.1 on the local and memory filesystems:
- On 2023.1.0 and 2023.6.0,
fs.get(list, list)with keys such asa[12].txtorb*.txtraisedAssertionError(the two lists ended up different lengths). I could not get it to pair a key with another key's local name. The practical symptom seems to be "folder download fails" rather than silent mispairing. The fix is right either way, so this only affects the PR description. - The empty-folder comment says fsspec before 2024.3.1 leaves the folder out of
find(withdirs=True). For local and memory I saw the change at 2023.9.0 (2024.2.0 already lists it). 2024.3.1 may be the right number for s3fs, which I did not test. If not, the comment could say 2023.9.0 or drop the version.
Resolving the store once and recording that same name makes <filepath@> much easier to reason about when the two defaults differ.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-ups to the file-store and attachment changes in 2.3.6 (GHSA-94rh-cpp4-v56c). The path checks from that release are unchanged. Every change here refuses, or falls back to the safer path, when in doubt.
<filepath@>insert checks the right store. With no store named,<filepath@>recordsstores.filepath_default. The path check and the existence check used the backend ofstores.default. When the two named different stores, an insert checked one store and recorded the other. Now the store name is resolved once, and every check uses that store.fs.get(list, list)still expands the sources as glob patterns. A key containing[,*or?could be paired with another key's local name. DataJoint now fetches the files one by one on those versions. A key ending in/(a directory marker) becomes a folder, not a file.find(withdirs=True)does not list the folder itself, so the download raisedFileNotFoundError. It now creates the empty folder. A folder that does not exist still raises.<attach>reuse check cannot block._has_contentsopens the file withO_NONBLOCK. If the open fails, the file counts as different, and the fetch moves on to the next free name.Fixes #1713.
Changes
src/datajoint/builtin_codecs/filepath.py: resolve the store withuse_filepath_default=Trueonce, and use it for the spec, the backend, the error message and the recorded row.src/datajoint/objectref.py: fetch files one by one unless fsspec is 2023.9.0 or later (an unrecognized version counts as old); treat keys ending in/as folders; create an empty folder thatfinddoes not list.src/datajoint/builtin_codecs/attach.py: open withO_NONBLOCK; a failed open returns False.tests/unit/conftest.py: afresh_datajoint_importfixture. Some unit tests removedatajointfromsys.modulesto import it afresh. They now put the original modules back afterwards. Before, later tests mixed two copies of the package, so a setting changed through onedj.configdid not reach code reading the other. That is whytests/unitandtests/integration/test_path_confinement.pyfailed when run in one session.Tests
tests/unit/test_path_confinement.py):<filepath@>withstores.defaultandstores.filepath_defaultset to different stores: the file is found in, confined to, and recorded with the filepath store.locationis a symbolic link. A relativelocation, resolved against the working directory at call time.[,*and?(only[on Windows, where file names cannot contain the others), on the installed fsspec and with an older fsspec version reported. Also a directory-marker key, an empty folder thatfinddoes not list, and a missing folder.lstatcheck: the check returns False without blocking.tests/integration/test_store_follow_ups.py):<filepath@>insert and fetch with the two defaults set to different stores, on MySQL and PostgreSQL.<filepath@>tests, the old-fsspec download test for each of its three reported versions, the directory-marker and empty-folder tests, and the named-pipe test.test_download_folder_keys_with_glob_characterspasses onmasterwith a current fsspec, because fsspec 2023.9 and later no longer expands the sources as patterns; the old-fsspec tests cover the case that failed. The symbolic-link, relative-location and missing-folder tests pass before and after. The<filepath@>integration tests fail before the change on both backends.tests/unittogether withtests/integration/test_path_confinement.pyandtests/integration/test_schema.pynow passes in one session; it failed before.