Repository navigation
fix(brainio): accept bucket/folder names in upload_to_s3 like the s3 loaders - #241
Merged
KartikP merged 3 commits intoNov 28, 2026
Merged
Conversation
…drop empty folder segments like BotoFetcher
Contributor
Author
Contributor
Author
|
@KartikP @mike-ferguson @samwinebrake a quick nudge on this fix: happy to adjust anything, or close it if it's no longer wanted. |
Contributor
|
Thanks @albertlieyingadrian, this looks good. The red Jenkins check is not caused by your change: our CI setup installs poetry, which now produces pip resolver |
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.
Fixes brain-score/vision#2159.
Problem.
load_stimulus_set_from_s3andload_assembly_from_s3accept a bucket with a folder, such as"brainscore-storage/brainio-brainscore". They split on the first/and fetch<folder>/<file>. The upload side passes the same string to boto3 as the bucket name, so packaging into that location fails:Fix.
upload_to_s3splits off the folder the way the loaders do and puts it in front of the key. It drops empty path segments, asBotoFetcherdoes when it rebuilds the key withos.path.join, sobucket/folder/andbucket//folderland where the loaders look.package_stimulus_setandpackage_data_assemblystill return the unsplit string in"bucket", so the values they return load back unchanged. Plain bucket names behave as before. Thebrainio.requestedcheck now compares only the bucket part, so a folder under that bucket still runscheck_experiment_stimulus_set.Tests. I added 15 tests to
brainio/tests/test_packaging.py, using moto:upload_to_s3to a plain bucket and to folder forms (a/b,a/b/,//a//b,bucket/);package_stimulus_setthenload_stimulus_set_from_s3into a fresh local data path) for the same forms;package_data_assemblythenload_assembly_from_s3) forbucketandbucket/some/folder;brainio.requestedcheck, with and without a folder.All 15 pass on this branch. With
main'spackaging.py, 10 of them fail with theParamValidationErrorabove. The rest of the file gives the same result as onmain; locally the only failures are the 3 tests that need AWS credentials.motois nowmoto>=5in the test extra, because the tests usemock_aws.The assembly test uses integer ids because string coordinates fail in
write_netcdfunder pandas 3. That's unrelated to this change and filed as #242.@KartikP could you take a look when you have a moment?