Repository navigation
feat(studio): implement S3 dataset loading (completes #5951) - #6222
Conversation
Add foundational types and configuration for S3 bucket dataset loading: - Add S3Config type to frontend training types - Add S3Config Pydantic model to backend training models - Add "s3" as a DatasetSource option - Add s3Config state and setS3Config action to training config store - Add i18n translations for S3 configuration (English and Chinese) This provides the type definitions and UI text for S3 integration. Full implementation requires boto3 dependency and data loading logic. Refs: unslothai#4539
- Pass s3_config from request into training_kwargs so it flows to training subprocess - Add s3Config to NON_PERSISTED_STATE_KEYS to prevent AWS secrets from being saved to localStorage Addresses code review feedback on PR unslothai#5951.
Filter out s3_config (which contains secret_access_key) from the config_json stored in training_runs table, preventing AWS credentials from being persisted to disk. Addresses P1 security feedback on PR unslothai#5951.
Builds the actual S3 loader on top of the hardened unslothai#5951 foundation, turning the 501-gated scaffold into a working dataset source. Backend: - Add core/training/s3_dataset.py: lists and downloads supported dataset files (parquet/json/jsonl/csv) from an S3 bucket to a temp dir, using IAM-role or access-key credentials. boto3 is imported lazily (optional dep). - Wire s3_config into UnslothTrainer.load_and_format_dataset (downloads then reuses the existing local-file path) and thread it through worker.py. - Replace the 501 "not implemented" gate with a boto3-availability guard so S3 works when boto3 is present and fails clearly when it is not. - Add boto3 to studio.txt requirements. - Add tests/test_s3_dataset.py (8 tests) covering download/filtering, collisions, missing-boto3, and S3Config camelCase/IAM validation. Frontend: - Widen DatasetSource to include "s3"; add s3_config to the training payload type and mapper; add an S3 validation branch and selectS3Source store action. - Add s3-config-form.tsx (bucket/region/prefix/keys/IAM toggle) reusing the existing studio.dataset.s3.* i18n strings. - Add a Hugging Face / Local / Amazon S3 source toggle in dataset-section; the S3 config card replaces the dataset combobox when S3 is selected. - Fix DatasetPreviewDialog to accept the widened DatasetSource type. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c60a801eea
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| datasetSource: "s3", | ||
| dataset: null, | ||
| uploadedFile: null, |
There was a problem hiding this comment.
Handle S3 in onboarding progression
When the S3 tab is selected here, the store sets datasetSource to "s3" while clearing both dataset and uploadedFile; however, canProceedForStep still treats every non-upload source as requiring state.dataset !== null. In the onboarding wizard, WizardFooter disables Continue based on s.canProceed(), so a user who enters a valid S3 bucket/credentials on the dataset step cannot advance. Please add an S3 branch to the step-3 progression check that validates s3Config instead of requiring a Hugging Face dataset name.
Useful? React with 👍 / 👎.
| self._db_total_steps_set = False | ||
| self._db_config = {k: v for k, v in config.items() if k not in {"hf_token", "wandb_token"}} | ||
| self._db_config = { | ||
| k: v for k, v in config.items() if k not in {"hf_token", "wandb_token", "s3_config"} |
There was a problem hiding this comment.
Preserve enough S3 source state for resume
For stopped S3 runs, this drops the only dataset source from the saved run config, while can_resume_run still advertises any stopped run with trainer state as resumable and the frontend resume path replays this saved config. The resumed request therefore contains no hf_dataset, local_datasets, or s3_config, so the worker reaches dataset loading and fails with No dataset provided; either disable resume for S3 runs or persist/rehydrate a non-secret S3 source marker plus credentials prompt instead of making the resume button fail.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b25c82c91e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3c46915c9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if ( | ||
| !config.isEmbeddingModel && | ||
| !isRawTextDatasetFormat(config.datasetFormat) && | ||
| !hasRequiredS3Mapping(config) | ||
| ) { |
There was a problem hiding this comment.
Allow standard S3 formats without manual mapping
When S3 is selected and datasetFormat is left as auto or set to a standard format like alpaca/sharegpt, there is no S3 preview path to populate datasetManualMapping, so this validation disables Start even for datasets with the normal columns that the backend formatter already auto-detects and loads without a custom mapping. This makes common S3 datasets unusable unless the user switches to raw text or somehow imports a saved mapping.
Useful? React with 👍 / 👎.
| <Switch | ||
| id="s3-iam" | ||
| checked={config.useIamRole ?? false} | ||
| onCheckedChange={(useIamRole) => update({ useIamRole })} |
There was a problem hiding this comment.
Clear hidden keys when IAM role is selected
If a user enters access keys and then switches on Use IAM Role, this only flips the flag and leaves accessKeyId/secretAccessKey in the store; buildTrainingStartPayload later sends the entire s3Config object, so the hidden secret still goes to the backend/worker despite the IAM-role choice. Clear the key fields here or omit them from the payload whenever useIamRole is true.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7e34325ba2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…st and point the manifest at it key listing filtered audio files out, every download flattened to its basename, and a manifest+audio prefix was called a mixed-format error. So the layout unslothai#4539 asks for -- Whisper finetuning with audio files on S3 plus a transcription manifest -- could never load: at best the manifest downloaded alone and training died when datasets.Audio tried to open paths that were never materialized. Audio keys under the prefix now download too, preserving their prefix-relative structure so the manifest's relative references stay true, and the manifest's audio values are rewritten to the materialized absolute paths -- matching prefix-relative keys, s3://bucket/key URIs, the HF undecoded {"path": ...} shape, and manifest-relative paths; anything unmatched is left exactly as written. The single-format rule now judges only the manifest files (audio beside one manifest family is the expected shape; audio with no manifest is an error naming what is missing), and tabular-only prefixes keep unslothai#6222's flat collision-renamed layout byte for byte. Since the structured layout joins S3 keys into filesystem paths and bucket contents are external input, a key carrying '..' segments refuses the download instead of writing above the dataset directory. Credentials handling is untouched from unslothai#6222 (explicit keys or the default chain/IAM role, never logged or persisted). Parquet manifests cannot be rewritten without pyarrow; their audio references must already be absolute, which the module docstring now states. Closes unslothai#4539.
…st and point the manifest at it key listing filtered audio files out, every download flattened to its basename, and a manifest+audio prefix was called a mixed-format error. So the layout unslothai#4539 asks for -- Whisper finetuning with audio files on S3 plus a transcription manifest -- could never load: at best the manifest downloaded alone and training died when datasets.Audio tried to open paths that were never materialized. Audio keys under the prefix now download too, preserving their prefix-relative structure so the manifest's relative references stay true, and the manifest's audio values are rewritten to the materialized absolute paths -- matching prefix-relative keys, s3://bucket/key URIs, the HF undecoded {"path": ...} shape, and manifest-relative paths; anything unmatched is left exactly as written. The single-format rule now judges only the manifest files (audio beside one manifest family is the expected shape; audio with no manifest is an error naming what is missing), and tabular-only prefixes keep unslothai#6222's flat collision-renamed layout byte for byte. Since the structured layout joins S3 keys into filesystem paths and bucket contents are external input, a key carrying '..' segments refuses the download instead of writing above the dataset directory. Credentials handling is untouched from unslothai#6222 (explicit keys or the default chain/IAM role, never logged or persisted). Parquet manifests cannot be rewritten without pyarrow; their audio references must already be absolute, which the module docstring now states. Closes unslothai#4539.
…st and point the manifest at it key listing filtered audio files out, every download flattened to its basename, and a manifest+audio prefix was called a mixed-format error. So the layout unslothai#4539 asks for -- Whisper finetuning with audio files on S3 plus a transcription manifest -- could never load: at best the manifest downloaded alone and training died when datasets.Audio tried to open paths that were never materialized. Audio keys under the prefix now download too, preserving their prefix-relative structure so the manifest's relative references stay true, and the manifest's audio values are rewritten to the materialized absolute paths -- matching prefix-relative keys, s3://bucket/key URIs, the HF undecoded {"path": ...} shape, and manifest-relative paths; anything unmatched is left exactly as written. The single-format rule now judges only the manifest files (audio beside one manifest family is the expected shape; audio with no manifest is an error naming what is missing), and tabular-only prefixes keep unslothai#6222's flat collision-renamed layout byte for byte. Since the structured layout joins S3 keys into filesystem paths and bucket contents are external input, a key carrying '..' segments refuses the download instead of writing above the dataset directory. Credentials handling is untouched from unslothai#6222 (explicit keys or the default chain/IAM role, never logged or persisted). Parquet manifests cannot be rewritten without pyarrow; their audio references must already be absolute, which the module docstring now states. Closes unslothai#4539.
…st and point the manifest at it key listing filtered audio files out, every download flattened to its basename, and a manifest+audio prefix was called a mixed-format error. So the layout unslothai#4539 asks for -- Whisper finetuning with audio files on S3 plus a transcription manifest -- could never load: at best the manifest downloaded alone and training died when datasets.Audio tried to open paths that were never materialized. Audio keys under the prefix now download too, preserving their prefix-relative structure so the manifest's relative references stay true, and the manifest's audio values are rewritten to the materialized absolute paths -- matching prefix-relative keys, s3://bucket/key URIs, the HF undecoded {"path": ...} shape, and manifest-relative paths; anything unmatched is left exactly as written. The single-format rule now judges only the manifest files (audio beside one manifest family is the expected shape; audio with no manifest is an error naming what is missing), and tabular-only prefixes keep unslothai#6222's flat collision-renamed layout byte for byte. Since the structured layout joins S3 keys into filesystem paths and bucket contents are external input, a key carrying '..' segments refuses the download instead of writing above the dataset directory. Credentials handling is untouched from unslothai#6222 (explicit keys or the default chain/IAM role, never logged or persisted). Parquet manifests cannot be rewritten without pyarrow; their audio references must already be absolute, which the module docstring now states. Closes unslothai#4539.
…st and point the manifest at it key listing filtered audio files out, every download flattened to its basename, and a manifest+audio prefix was called a mixed-format error. So the layout unslothai#4539 asks for -- Whisper finetuning with audio files on S3 plus a transcription manifest -- could never load: at best the manifest downloaded alone and training died when datasets.Audio tried to open paths that were never materialized. Audio keys under the prefix now download too, preserving their prefix-relative structure so the manifest's relative references stay true, and the manifest's audio values are rewritten to the materialized absolute paths -- matching prefix-relative keys, s3://bucket/key URIs, the HF undecoded {"path": ...} shape, and manifest-relative paths; anything unmatched is left exactly as written. The single-format rule now judges only the manifest files (audio beside one manifest family is the expected shape; audio with no manifest is an error naming what is missing), and tabular-only prefixes keep unslothai#6222's flat collision-renamed layout byte for byte. Since the structured layout joins S3 keys into filesystem paths and bucket contents are external input, a key carrying '..' segments refuses the download instead of writing above the dataset directory. Credentials handling is untouched from unslothai#6222 (explicit keys or the default chain/IAM role, never logged or persisted). Parquet manifests cannot be rewritten without pyarrow; their audio references must already be absolute, which the module docstring now states. Closes unslothai#4539.
…st and point the manifest at it key listing filtered audio files out, every download flattened to its basename, and a manifest+audio prefix was called a mixed-format error. So the layout unslothai#4539 asks for -- Whisper finetuning with audio files on S3 plus a transcription manifest -- could never load: at best the manifest downloaded alone and training died when datasets.Audio tried to open paths that were never materialized. Audio keys under the prefix now download too, preserving their prefix-relative structure so the manifest's relative references stay true, and the manifest's audio values are rewritten to the materialized absolute paths -- matching prefix-relative keys, s3://bucket/key URIs, the HF undecoded {"path": ...} shape, and manifest-relative paths; anything unmatched is left exactly as written. The single-format rule now judges only the manifest files (audio beside one manifest family is the expected shape; audio with no manifest is an error naming what is missing), and tabular-only prefixes keep unslothai#6222's flat collision-renamed layout byte for byte. Since the structured layout joins S3 keys into filesystem paths and bucket contents are external input, a key carrying '..' segments refuses the download instead of writing above the dataset directory. Credentials handling is untouched from unslothai#6222 (explicit keys or the default chain/IAM role, never logged or persisted). Parquet manifests cannot be rewritten without pyarrow; their audio references must already be absolute, which the module docstring now states. Closes unslothai#4539.
…st and point the manifest at it key listing filtered audio files out, every download flattened to its basename, and a manifest+audio prefix was called a mixed-format error. So the layout unslothai#4539 asks for -- Whisper finetuning with audio files on S3 plus a transcription manifest -- could never load: at best the manifest downloaded alone and training died when datasets.Audio tried to open paths that were never materialized. Audio keys under the prefix now download too, preserving their prefix-relative structure so the manifest's relative references stay true, and the manifest's audio values are rewritten to the materialized absolute paths -- matching prefix-relative keys, s3://bucket/key URIs, the HF undecoded {"path": ...} shape, and manifest-relative paths; anything unmatched is left exactly as written. The single-format rule now judges only the manifest files (audio beside one manifest family is the expected shape; audio with no manifest is an error naming what is missing), and tabular-only prefixes keep unslothai#6222's flat collision-renamed layout byte for byte. Since the structured layout joins S3 keys into filesystem paths and bucket contents are external input, a key carrying '..' segments refuses the download instead of writing above the dataset directory. Credentials handling is untouched from unslothai#6222 (explicit keys or the default chain/IAM role, never logged or persisted). Parquet manifests cannot be rewritten without pyarrow; their audio references must already be absolute, which the module docstring now states. Closes unslothai#4539.
…st and point the manifest at it key listing filtered audio files out, every download flattened to its basename, and a manifest+audio prefix was called a mixed-format error. So the layout unslothai#4539 asks for -- Whisper finetuning with audio files on S3 plus a transcription manifest -- could never load: at best the manifest downloaded alone and training died when datasets.Audio tried to open paths that were never materialized. Audio keys under the prefix now download too, preserving their prefix-relative structure so the manifest's relative references stay true, and the manifest's audio values are rewritten to the materialized absolute paths -- matching prefix-relative keys, s3://bucket/key URIs, the HF undecoded {"path": ...} shape, and manifest-relative paths; anything unmatched is left exactly as written. The single-format rule now judges only the manifest files (audio beside one manifest family is the expected shape; audio with no manifest is an error naming what is missing), and tabular-only prefixes keep unslothai#6222's flat collision-renamed layout byte for byte. Since the structured layout joins S3 keys into filesystem paths and bucket contents are external input, a key carrying '..' segments refuses the download instead of writing above the dataset directory. Credentials handling is untouched from unslothai#6222 (explicit keys or the default chain/IAM role, never logged or persisted). Parquet manifests cannot be rewritten without pyarrow; their audio references must already be absolute, which the module docstring now states. Closes unslothai#4539.
…st and point the manifest at it key listing filtered audio files out, every download flattened to its basename, and a manifest+audio prefix was called a mixed-format error. So the layout unslothai#4539 asks for -- Whisper finetuning with audio files on S3 plus a transcription manifest -- could never load: at best the manifest downloaded alone and training died when datasets.Audio tried to open paths that were never materialized. Audio keys under the prefix now download too, preserving their prefix-relative structure so the manifest's relative references stay true, and the manifest's audio values are rewritten to the materialized absolute paths -- matching prefix-relative keys, s3://bucket/key URIs, the HF undecoded {"path": ...} shape, and manifest-relative paths; anything unmatched is left exactly as written. The single-format rule now judges only the manifest files (audio beside one manifest family is the expected shape; audio with no manifest is an error naming what is missing), and tabular-only prefixes keep unslothai#6222's flat collision-renamed layout byte for byte. Since the structured layout joins S3 keys into filesystem paths and bucket contents are external input, a key carrying '..' segments refuses the download instead of writing above the dataset directory. Credentials handling is untouched from unslothai#6222 (explicit keys or the default chain/IAM role, never logged or persisted). Parquet manifests cannot be rewritten without pyarrow; their audio references must already be absolute, which the module docstring now states. Closes unslothai#4539.
Summary
Completes the S3 dataset loader scaffold from #5951 and wires S3 in as a first-class Studio dataset source alongside Hugging Face and local uploads.
Backend
core/training/s3_dataset.pyto list and download supported dataset files from S3 using IAM role or access-key credentials.boto3lazy and optional, with a clear availability guard before S3 training starts.Frontend
s3to the Studio dataset source model and training request payload.Testing
~/.unsloth/studio/unsloth_studio/bin/python -m pytest studio/backend/tests/test_s3_dataset.py -q~/.unsloth/studio/unsloth_studio/bin/python -m pytest tests/studio/test_mlx_training_worker_behaviors.py -q~/.unsloth/studio/unsloth_studio/bin/python -m py_compile studio/backend/core/training/s3_dataset.py studio/backend/core/training/trainer.py studio/backend/core/training/worker.py studio/backend/tests/test_s3_dataset.py~/.unsloth/studio/unsloth_studio/bin/python -m ruff check studio/backend/core/training/s3_dataset.py studio/backend/core/training/trainer.py studio/backend/core/training/worker.py studio/backend/tests/test_s3_dataset.pynpm run typecheckinstudio/frontendnpm run i18n:checkinstudio/frontendgit diff --checkCloses the loader gap from #5951.