Skip to content

fix(brainio): accept bucket/folder names in upload_to_s3 like the s3 loaders - #241

Merged
KartikP merged 3 commits into
brain-score:mainfrom
albertlieyingadrian:fix/upload-bucket-folder
Nov 28, 2026
Merged

KartikP merged 3 commits into
brain-score:mainfrom
albertlieyingadrian:fix/upload-bucket-folder

Conversation

@albertlieyingadrian

@albertlieyingadrian albertlieyingadrian commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes brain-score/vision#2159.

Problem. load_stimulus_set_from_s3 and load_assembly_from_s3 accept 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:

botocore.exceptions.ParamValidationError: Invalid bucket name "brainscore-storage/brainio-brainscore": Bucket name must match the regex ...

Fix. upload_to_s3 splits off the folder the way the loaders do and puts it in front of the key. It drops empty path segments, as BotoFetcher does when it rebuilds the key with os.path.join, so bucket/folder/ and bucket//folder land where the loaders look. package_stimulus_set and package_data_assembly still return the unsplit string in "bucket", so the values they return load back unchanged. Plain bucket names behave as before. The brainio.requested check now compares only the bucket part, so a folder under that bucket still runs check_experiment_stimulus_set.

Tests. I added 15 tests to brainio/tests/test_packaging.py, using moto:

  • upload_to_s3 to a plain bucket and to folder forms (a/b, a/b/, //a//b, bucket/);
  • stimulus set round trips (package_stimulus_set then load_stimulus_set_from_s3 into a fresh local data path) for the same forms;
  • assembly round trips (package_data_assembly then load_assembly_from_s3) for bucket and bucket/some/folder;
  • the brainio.requested check, with and without a folder.

All 15 pass on this branch. With main's packaging.py, 10 of them fail with the ParamValidationError above. The rest of the file gives the same result as on main; locally the only failures are the 3 tests that need AWS credentials.

moto is now moto>=5 in the test extra, because the tests use mock_aws.

The assembly test uses integer ids because string coordinates fail in write_netcdf under pandas 3. That's unrelated to this change and filed as #242.

@KartikP could you take a look when you have a moment?

@albertlieyingadrian

Copy link
Copy Markdown
Contributor Author

Jenkins run 228 shows 276 passed, 3 skipped, including the new tests. The build is marked failed afterwards, the same way as #240 and the main merge build #224 (pip resolver ERROR: lines during setup).

@albertlieyingadrian

Copy link
Copy Markdown
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.

@KartikP KartikP self-assigned this Nov 28, 2026
@KartikP

KartikP commented Nov 28, 2026

Copy link
Copy Markdown
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 ERROR: lines that the log parser treats as a failure (the tests themselves pass). We are fixing that on the CI side and will re-run the build once it lands.

@KartikP KartikP closed this Nov 28, 2026
@KartikP KartikP reopened this Nov 28, 2026

@KartikP KartikP left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-breaking. LGTM

@KartikP
KartikP merged commit 34841f9 into brain-score:main Nov 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cannot pass / in bucket name

2 participants