Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: load S3 audio datasets by downloading the audio beside its manifest (#10050)
Shubhankar Tripathy95421ede6888
diff --git a/studio/backend/core/training/s3_dataset.py b/studio/backend/core/training/s3_dataset.pyindex 91fd91b40f0..3d057fa90e4 100644--- a/studio/backend/core/training/s3_dataset.py+++ b/studio/backend/core/training/s3_dataset.py@@ -9,6 +9,10 @@ to a local temp directory so the existing local-file dataset path can consumethem. boto3 is an optional dependency and is imported lazily — callers shouldgate on :func:`boto3_available` before invoking the loader.+Audio keys download too, keeping their prefix-relative layout, and audio values in+JSON/JSONL/CSV manifests are rewritten to the local paths (``datasets.Audio`` opens path+strings verbatim). Parquet manifests are not rewritten: their paths must already resolve.+The S3 config dict mirrors ``models.training.S3Config.model_dump()`` (snake_casekeys): bucket, region, prefix, access_key_id, secret_access_key, use_iam_role.Credentials are read once to build the client and never logged or persisted.@@ -22,12 +26,15 @@ from core.training.account_jobs import (require_explicit_credentials,)from utils.paths import ensure_dir, tmp_root+import csv+import jsonimport loggingimport osimport shutilimport tempfilefrom importlib.util import find_specfrom typing import Callable, Optional+from utils.datasets.format_detection import _AUDIO_EXTENSIONSfrom utils.paths.path_utils import drop_shadowed_appledouble_nameslogger = logging.getLogger(__name__)@@ -41,6 +48,7 @@ _IGNORED_METADATA_FILENAMES = {"schema.json","state.json",}+_REWRITABLE_MANIFEST_EXTENSIONS = (".json", ".jsonl", ".csv")class S3DownloadCancelled(RuntimeError):@@ -94,7 +102,7 @@ def _build_s3_client(s3_config: dict):def _list_dataset_keys(client, bucket: str, prefix: Optional[str]) -> list[str]:- """List object keys under ``prefix`` that have a supported data extension."""+ """Supported dataset keys under ``prefix``: manifests and the audio files beside them."""paginator = client.get_paginator("list_objects_v2")list_kwargs = {"Bucket": bucket}if prefix:@@ -108,7 +116,7 @@ def _list_dataset_keys(client, bucket: str, prefix: Optional[str]) -> list[str]:continueif os.path.basename(key).lower() in _IGNORED_METADATA_FILENAMES:continue- if key.lower().endswith(SUPPORTED_EXTENSIONS):+ if key.lower().endswith(SUPPORTED_EXTENSIONS + _AUDIO_EXTENSIONS):keys.append(key)# A Mac sync uploads Finder metadata under the shard's own extension and# _validate_single_extension_family cannot see it, so a key is dropped only when the object it@@ -116,6 +124,10 @@ def _list_dataset_keys(client, bucket: str, prefix: Optional[str]) -> list[str]:return drop_shadowed_appledouble_names(keys)+def _is_audio_key(key: str) -> bool:+ return key.lower().endswith(_AUDIO_EXTENSIONS)++def _extension_family(key: str) -> str:ext = os.path.splitext(key)[1].lower()if ext in _JSON_EXTENSIONS:@@ -156,6 +168,128 @@ def _raise_if_cancelled(cancel_callback: Optional[Callable[[], bool]]) -> None:raise S3DownloadCancelled("S3 dataset download cancelled")+def _download_one(client, bucket, key, local_path, cancel_callback) -> None:+ download_kwargs = {}+ if cancel_callback is not None:+ download_kwargs["Callback"] = lambda _bytes: _raise_if_cancelled(cancel_callback)+ client.download_file(bucket, key, local_path, **download_kwargs)+ _raise_if_cancelled(cancel_callback)+++def _key_relative_to_prefix(key: str, prefix: Optional[str]) -> str:+ if prefix and key.startswith(prefix):+ key = key[len(prefix) :]+ return key.lstrip("/")+++def _download_structured(+ client, bucket: str, prefix: Optional[str], keys: list[str], target_dir: str, cancel_callback+) -> dict[str, str]:+ """Download ``keys`` mirroring their prefix-relative layout. Returns key -> local path."""+ local_by_key: dict[str, str] = {}+ for key in keys:+ _raise_if_cancelled(cancel_callback)+ relative = _key_relative_to_prefix(key, prefix)+ parts = [part for part in relative.split("/") if part not in ("", ".")]+ # ".." is a legal S3 key segment: refuse rather than write above target_dir.+ if ".." in parts or not parts:+ raise ValueError(+ f"S3 key {key!r} contains '..' or empty path segments and cannot "+ "be downloaded into the dataset directory."+ )+ local_path = os.path.join(target_dir, *parts)+ os.makedirs(os.path.dirname(local_path) or target_dir, exist_ok = True)+ _download_one(client, bucket, key, local_path, cancel_callback)+ local_by_key[key] = local_path+ return local_by_key+++def _rewrite_audio_references(+ manifest_local_by_key: dict[str, str],+ audio_local_by_key: dict[str, str],+ bucket: str,+ prefix: Optional[str],+) -> None:+ """Rewrite audio values naming a downloaded key (prefix-relative, ``s3://`` URI, or+ manifest-relative) to its local path; anything else is left as written."""+ lookup: dict[str, str] = {}+ for key, local_path in audio_local_by_key.items():+ lookup[_key_relative_to_prefix(key, prefix)] = local_path+ lookup[f"s3://{bucket}/{key}"] = local_path++ for manifest_key, manifest_path in manifest_local_by_key.items():+ if not manifest_path.lower().endswith(_REWRITABLE_MANIFEST_EXTENSIONS):+ continue+ manifest_dir = os.path.dirname(_key_relative_to_prefix(manifest_key, prefix))++ def resolve(value):+ if not isinstance(value, str) or not value.lower().endswith(_AUDIO_EXTENSIONS):+ return None+ direct = lookup.get(value)+ if direct is not None:+ return direct+ relative_to_manifest = os.path.normpath(os.path.join(manifest_dir, value))+ return lookup.get(relative_to_manifest.replace(os.sep, "/"))++ if manifest_path.lower().endswith(".csv"):+ _rewrite_csv_manifest(manifest_path, resolve)+ else:+ _rewrite_json_manifest(manifest_path, resolve)+++def _rewrite_row(row, resolve) -> None:+ if not isinstance(row, dict):+ return+ for column, value in row.items():+ replacement = resolve(value)+ if replacement is not None:+ row[column] = replacement+ elif isinstance(value, dict):+ # HF undecoded audio: {"path": ..., "bytes": ...}+ replacement = resolve(value.get("path"))+ if replacement is not None:+ value["path"] = replacement+++def _rewrite_json_manifest(manifest_path: str, resolve) -> None:+ with open(manifest_path, encoding = "utf-8") as f:+ text = f.read()+ try:+ data = None if manifest_path.lower().endswith(".jsonl") else json.loads(text)+ except json.JSONDecodeError:+ data = None # JSON Lines in a .json file+ if data is None:+ rows = [json.loads(line) for line in text.splitlines() if line.strip()]+ for row in rows:+ _rewrite_row(row, resolve)+ with open(manifest_path, "w", encoding = "utf-8") as f:+ for row in rows:+ f.write(json.dumps(row, ensure_ascii = False) + "\n")+ return+ if not isinstance(data, list):+ return # column-oriented JSON+ for row in data:+ _rewrite_row(row, resolve)+ with open(manifest_path, "w", encoding = "utf-8") as f:+ json.dump(data, f, ensure_ascii = False)+++def _rewrite_csv_manifest(manifest_path: str, resolve) -> None:+ with open(manifest_path, encoding = "utf-8", newline = "") as f:+ rows = list(csv.reader(f))+ changed = False+ for row in rows:+ for index, cell in enumerate(row):+ replacement = resolve(cell)+ if replacement is not None:+ row[index] = replacement+ changed = True+ if not changed:+ return+ with open(manifest_path, "w", encoding = "utf-8", newline = "") as f:+ csv.writer(f).writerows(rows)++def prepare_s3_dataset_download(s3_config: dict,dest_dir: Optional[str] = None,@@ -180,10 +314,18 @@ def prepare_s3_dataset_download(_raise_if_cancelled(cancel_callback)client = _build_s3_client(s3_config)- keys = _list_dataset_keys(client, bucket, prefix)+ listed = _list_dataset_keys(client, bucket, prefix)+ keys = [key for key in listed if not _is_audio_key(key)]+ audio_keys = [key for key in listed if _is_audio_key(key)]_raise_if_cancelled(cancel_callback)+ where = f"s3://{bucket}/{prefix}" if prefix else f"s3://{bucket}"if not keys:- where = f"s3://{bucket}/{prefix}" if prefix else f"s3://{bucket}"+ if audio_keys:+ raise ValueError(+ f"Found {len(audio_keys)} audio file(s) under {where} but no manifest. "+ "An audio dataset needs a JSON/JSONL/CSV manifest beside the audio, "+ "with a column of audio paths and a column of transcriptions."+ )raise ValueError(f"No supported dataset files ({', '.join(SUPPORTED_EXTENSIONS)}) "f"found under {where}"@@ -201,17 +343,23 @@ def prepare_s3_dataset_download(os.makedirs(target_dir, exist_ok = True)local_files: list[str] = []- used_paths: set[str] = set()- for key in keys:- _raise_if_cancelled(cancel_callback)- filename = os.path.basename(key)- local_path = _unique_local_path(target_dir, filename, used_paths)- download_kwargs = {}- if cancel_callback is not None:- download_kwargs["Callback"] = lambda _bytes: _raise_if_cancelled(cancel_callback)- client.download_file(bucket, key, local_path, **download_kwargs)- _raise_if_cancelled(cancel_callback)- local_files.append(local_path)+ if audio_keys:+ manifest_local_by_key = _download_structured(+ client, bucket, prefix, keys, target_dir, cancel_callback+ )+ audio_local_by_key = _download_structured(+ client, bucket, prefix, audio_keys, target_dir, cancel_callback+ )+ local_files = list(manifest_local_by_key.values())+ _rewrite_audio_references(manifest_local_by_key, audio_local_by_key, bucket, prefix)+ else:+ used_paths: set[str] = set()+ for key in keys:+ _raise_if_cancelled(cancel_callback)+ filename = os.path.basename(key)+ local_path = _unique_local_path(target_dir, filename, used_paths)+ _download_one(client, bucket, key, local_path, cancel_callback)+ local_files.append(local_path)except Exception:if owns_temp_dir:shutil.rmtree(target_dir, ignore_errors = True)diff --git a/studio/backend/tests/test_s3_audio_dataset.py b/studio/backend/tests/test_s3_audio_dataset.pynew file mode 100644index 00000000000..e02dae08ea7--- /dev/null+++ b/studio/backend/tests/test_s3_audio_dataset.py@@ -0,0 +1,239 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""#4539: S3 audio datasets download beside their manifest and the manifest points at them.+boto3 is faked as in test_s3_dataset.py."""++import csv+import importlib.util+import json+import os+from pathlib import Path++import pytest++_BACKEND = Path(__file__).resolve().parents[1]+++def _load(mod_name, rel_path):+ spec = importlib.util.spec_from_file_location(mod_name, _BACKEND / rel_path)+ module = importlib.util.module_from_spec(spec)+ spec.loader.exec_module(module)+ return module+++s3_dataset = _load("s3_dataset_audio_tests", "core/training/s3_dataset.py")+++class _FakePaginator:+ def __init__(self, keys):+ self._keys = keys++ def paginate(self, **kwargs):+ prefix = kwargs.get("Prefix")+ contents = [{"Key": k} for k in self._keys if prefix is None or k.startswith(prefix)]+ mid = len(contents) // 2+ yield {"Contents": contents[:mid]}+ yield {"Contents": contents[mid:]}+++class _FakeS3Client:+ """The house fake, plus per-key content so a manifest can hold real rows."""++ def __init__(+ self,+ keys,+ contents = None,+ ):+ self._keys = list(keys)+ self._contents = contents or {}+ self.downloaded = []++ def get_paginator(self, name):+ assert name == "list_objects_v2"+ return _FakePaginator(self._keys)++ def download_file(self, bucket, key, local_path, **kwargs):+ self.downloaded.append((bucket, key, local_path))+ callback = kwargs.get("Callback")+ if callback is not None:+ callback(1)+ with open(local_path, "w", encoding = "utf-8") as f:+ f.write(self._contents.get(key, f"content-of:{key}"))+++def _install(+ monkeypatch,+ keys,+ contents = None,+):+ client = _FakeS3Client(keys, contents)+ monkeypatch.setattr(s3_dataset, "boto3_available", lambda: True)+ monkeypatch.setattr(s3_dataset, "_build_s3_client", lambda cfg: client)+ return client+++def _cfg(**overrides):+ base = {+ "bucket": "my-bucket",+ "region": "us-east-1",+ "prefix": "datasets/",+ "access_key_id": "AKIA_TEST",+ "secret_access_key": "secret",+ "use_iam_role": False,+ }+ base.update(overrides)+ return base+++def _rows(jsonl_path):+ with open(jsonl_path, encoding = "utf-8") as f:+ return [json.loads(line) for line in f if line.strip()]+++def test_audio_files_download_beside_the_manifest_preserving_structure(monkeypatch, tmp_path):+ _install(+ monkeypatch,+ [+ "datasets/metadata.jsonl",+ "datasets/audio/a.wav",+ "datasets/audio/b.mp3",+ "datasets/notes.txt", # still unsupported, still skipped+ ],+ contents = {"datasets/metadata.jsonl": '{"audio": "audio/a.wav", "text": "hi"}\n'},+ )++ files = s3_dataset.download_s3_dataset(_cfg(), dest_dir = str(tmp_path))++ assert [os.path.basename(f) for f in files] == ["metadata.jsonl"]+ assert (tmp_path / "audio" / "a.wav").exists()+ assert (tmp_path / "audio" / "b.mp3").exists()+ assert not (tmp_path / "notes.txt").exists()+++def test_a_manifest_beside_audio_is_not_a_mixed_format_error(monkeypatch, tmp_path):+ _install(+ monkeypatch,+ ["datasets/metadata.csv", "datasets/a.wav", "datasets/b.mp3"],+ contents = {"datasets/metadata.csv": "audio,text\na.wav,hi\n"},+ )+ files = s3_dataset.download_s3_dataset(_cfg(), dest_dir = str(tmp_path))+ assert [os.path.basename(f) for f in files] == ["metadata.csv"]+++def test_two_manifest_formats_beside_audio_is_still_a_mixed_format_error(monkeypatch, tmp_path):+ client = _install(+ monkeypatch,+ ["datasets/metadata.csv", "datasets/extra.parquet", "datasets/a.wav"],+ )+ with pytest.raises(ValueError, match = "mixed dataset formats"):+ s3_dataset.download_s3_dataset(_cfg(), dest_dir = str(tmp_path))+ assert client.downloaded == []+++def test_audio_with_no_manifest_names_whats_missing(monkeypatch, tmp_path):+ _install(monkeypatch, ["datasets/audio/a.wav", "datasets/audio/b.mp3"])+ with pytest.raises(ValueError, match = "manifest"):+ s3_dataset.download_s3_dataset(_cfg(), dest_dir = str(tmp_path))+++def test_jsonl_audio_references_are_rewritten_to_local_paths(monkeypatch, tmp_path):+ manifest = "\n".join(+ [+ # A prefix-relative key.+ json.dumps({"audio": "audio/a.wav", "text": "one"}),+ # A full S3 URI to a downloaded key.+ json.dumps({"audio": "s3://my-bucket/datasets/audio/b.mp3", "text": "two"}),+ # The HF undecoded-audio dict shape.+ json.dumps({"audio": {"path": "audio/a.wav"}, "text": "three"}),+ # Unmatched references are somebody else's contract: left alone.+ json.dumps({"audio": "https://example.com/c.wav", "text": "four"}),+ ]+ )+ _install(+ monkeypatch,+ ["datasets/metadata.jsonl", "datasets/audio/a.wav", "datasets/audio/b.mp3"],+ contents = {"datasets/metadata.jsonl": manifest + "\n"},+ )++ files = s3_dataset.download_s3_dataset(_cfg(), dest_dir = str(tmp_path))+ rows = _rows(files[0])++ local_a = str(tmp_path / "audio" / "a.wav")+ local_b = str(tmp_path / "audio" / "b.mp3")+ assert rows[0]["audio"] == local_a+ assert rows[1]["audio"] == local_b+ assert rows[2]["audio"]["path"] == local_a+ assert rows[3]["audio"] == "https://example.com/c.wav"+ assert all(os.path.isabs(p) for p in (rows[0]["audio"], rows[1]["audio"]))+ assert rows[0]["text"] == "one"+++def test_json_lines_in_a_json_manifest_are_rewritten(monkeypatch, tmp_path):+ manifest = "".join(+ json.dumps({"audio": name, "text": "hi"}) + "\n" for name in ("a.wav", "b.wav")+ )+ _install(+ monkeypatch,+ ["datasets/train.json", "datasets/a.wav", "datasets/b.wav"],+ contents = {"datasets/train.json": manifest},+ )+ files = s3_dataset.download_s3_dataset(_cfg(), dest_dir = str(tmp_path))+ assert [row["audio"] for row in _rows(files[0])] == [+ str(tmp_path / "a.wav"),+ str(tmp_path / "b.wav"),+ ]+++def test_manifest_relative_references_resolve_against_the_manifest_dir(monkeypatch, tmp_path):+ _install(+ monkeypatch,+ ["datasets/train/metadata.jsonl", "datasets/train/clips/a.wav"],+ contents = {+ "datasets/train/metadata.jsonl": json.dumps({"audio": "clips/a.wav", "text": "hi"})+ + "\n"+ },+ )+ files = s3_dataset.download_s3_dataset(_cfg(), dest_dir = str(tmp_path))+ rows = _rows(files[0])+ assert rows[0]["audio"] == str(tmp_path / "train" / "clips" / "a.wav")+++def test_csv_audio_references_are_rewritten_to_local_paths(monkeypatch, tmp_path):+ _install(+ monkeypatch,+ ["datasets/metadata.csv", "datasets/audio/a.wav"],+ contents = {+ "datasets/metadata.csv": "audio,text\naudio/a.wav,hello there\nmissing.wav,kept\n"+ },+ )+ files = s3_dataset.download_s3_dataset(_cfg(), dest_dir = str(tmp_path))+ with open(files[0], encoding = "utf-8") as f:+ rows = list(csv.DictReader(f))+ assert rows[0]["audio"] == str(tmp_path / "audio" / "a.wav")+ assert rows[0]["text"] == "hello there"+ # An unmatched reference stays; it may be absolute on the training host.+ assert rows[1]["audio"] == "missing.wav"+++def test_tabular_only_prefixes_keep_the_flat_layout(monkeypatch, tmp_path):+ # #6222's flat, collision-renamed layout is unchanged without audio.+ _install(monkeypatch, ["datasets/sub/train.parquet", "datasets/other/train.parquet"])+ files = s3_dataset.download_s3_dataset(_cfg(), dest_dir = str(tmp_path))+ assert sorted(os.path.basename(f) for f in files) == ["train.parquet", "train_1.parquet"]+ assert not (tmp_path / "sub").exists()+++def test_a_key_with_dotdot_segments_cannot_escape_the_download_dir(monkeypatch, tmp_path):+ client = _install(+ monkeypatch,+ ["datasets/metadata.jsonl", "datasets/../../evil.wav"],+ contents = {"datasets/metadata.jsonl": '{"audio": "a.wav", "text": "hi"}\n'},+ )+ target = tmp_path / "download"+ target.mkdir()+ with pytest.raises(ValueError, match = "\\.\\."):+ s3_dataset.download_s3_dataset(_cfg(), dest_dir = str(target))+ escaped = tmp_path / "evil.wav"+ assert not escaped.exists()+ assert all("evil" not in key for (_b, key, _p) in client.downloaded)diff --git a/studio/backend/tests/test_s3_audio_dataset_live.py b/studio/backend/tests/test_s3_audio_dataset_live.pynew file mode 100644index 00000000000..fac3c698337--- /dev/null+++ b/studio/backend/tests/test_s3_audio_dataset_live.py@@ -0,0 +1,96 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""The audio S3 loader against a real, writable bucket (ambient AWS credentials; set+``AWS_ENDPOINT_URL_S3`` for an S3-compatible server). Opt-in; uploads are deleted after.++ UNSLOTH_S3_LIVE_BUCKET=my-bucket pytest studio/backend/tests/test_s3_audio_dataset_live.py -q+"""++from __future__ import annotations++import io+import json+import os+import struct+import sys+import uuid+import wave+from pathlib import Path++import pytest++_BACKEND = Path(__file__).resolve().parents[1]+if str(_BACKEND) not in sys.path:+ sys.path.insert(0, str(_BACKEND))++BUCKET = os.environ.get("UNSLOTH_S3_LIVE_BUCKET", "")+pytestmark = pytest.mark.skipif(not BUCKET, reason = "UNSLOTH_S3_LIVE_BUCKET not set")+++def _wav(frames: int = 800) -> bytes:+ buf = io.BytesIO()+ with wave.open(buf, "wb") as w:+ w.setnchannels(1)+ w.setsampwidth(2)+ w.setframerate(8000)+ w.writeframes(+ b"".join(struct.pack("<h", 3000 if i % 20 < 10 else -3000) for i in range(frames))+ )+ return buf.getvalue()+++def uploaded():+ boto3 = pytest.importorskip("boto3")+ client = boto3.client("s3", region_name = os.environ.get("AWS_DEFAULT_REGION", "us-east-1"))+ prefix = f"unsloth-live-{uuid.uuid4().hex[:8]}/"+ manifest = "\n".join(+ [+ json.dumps({"audio": "audio/a.wav", "text": "one"}),+ json.dumps({"audio": f"s3://{BUCKET}/{prefix}audio/sub/b.wav", "text": "two"}),+ json.dumps({"audio": {"path": "audio/a.wav"}, "text": "three"}),+ json.dumps({"audio": "https://example.com/c.wav", "text": "four"}),+ ]+ )+ objects = {+ f"{prefix}metadata.jsonl": (manifest + "\n").encode(),+ f"{prefix}audio/a.wav": _wav(),+ f"{prefix}audio/sub/b.wav": _wav(),+ }+ for key, body in objects.items():+ client.put_object(Bucket = BUCKET, Key = key, Body = body)+ try:+ yield prefix+ finally:+ client.delete_objects(Bucket = BUCKET, Delete = {"Objects": [{"Key": key} for key in objects]})+++def test_audio_dataset_round_trips_through_a_real_bucket(uploaded, tmp_path):+ from core.training import s3_dataset++ cfg = {+ "bucket": BUCKET,+ "region": os.environ.get("AWS_DEFAULT_REGION", "us-east-1"),+ "prefix": uploaded,+ "access_key_id": os.environ.get("AWS_ACCESS_KEY_ID"),+ "secret_access_key": os.environ.get("AWS_SECRET_ACCESS_KEY"),+ "use_iam_role": not os.environ.get("AWS_ACCESS_KEY_ID"),+ }+ files = s3_dataset.download_s3_dataset(cfg, dest_dir = str(tmp_path))++ assert [os.path.relpath(f, tmp_path) for f in files] == ["metadata.jsonl"]+ a = str(tmp_path / "audio" / "a.wav")+ b = str(tmp_path / "audio" / "sub" / "b.wav")+ assert os.path.isfile(a) and os.path.isfile(+ b+ ), "audio lands beside the manifest, structure kept"+ for path in (a, b):+ with wave.open(path) as w:+ assert w.getnframes() == 800, "bytes survive the trip"++ rows = [json.loads(line) for line in open(files[0], encoding = "utf-8") if line.strip()]+ assert rows[0]["audio"] == a+ assert rows[1]["audio"] == b+ assert rows[2]["audio"]["path"] == a+ assert rows[3]["audio"] == "https://example.com/c.wav"diff --git a/studio/frontend/src/features/studio/sections/dataset-section.tsx b/studio/frontend/src/features/studio/sections/dataset-section.tsxindex f9877057fac..8be26e92d51 100644--- a/studio/frontend/src/features/studio/sections/dataset-section.tsx+++ b/studio/frontend/src/features/studio/sections/dataset-section.tsx@@ -38,34 +38,27 @@ export function DatasetPanel() {datasetSource,restoreBrowseDatasetSource,isVisionModel,- isAudioModel,modelType,} = useTrainingConfigStore(useShallow((state) => ({datasetSource: state.datasetSource,restoreBrowseDatasetSource: state.restoreBrowseDatasetSource,isVisionModel: state.isVisionModel,- isAudioModel: state.isAudioModel,modelType: state.modelType,})),);const localDatasetInventory = useLocalDatasetInventory(datasetSource);const uploads = useDatasetUploads();- const effectiveModelType = modelType ?? "text";- const isMultimodalModel =- effectiveModelType === "vision" ||- effectiveModelType === "audio" ||- isVisionModel ||- isAudioModel;+ const isVisionTraining = (modelType ?? "text") === "vision" || isVisionModel;useEffect(() => {- if (datasetSource === "s3" && isMultimodalModel) {+ if (datasetSource === "s3" && isVisionTraining) {restoreBrowseDatasetSource();toast.info(t("studio.training.validation.s3MultimodalUnsupported"), {id: "training-s3-multimodal-source-reset",});}- }, [datasetSource, isMultimodalModel, restoreBrowseDatasetSource, t]);+ }, [datasetSource, isVisionTraining, restoreBrowseDatasetSource, t]);return (<div className="flex min-w-0 flex-col gap-5">diff --git a/studio/frontend/src/features/studio/sections/dataset-source-toggle.tsx b/studio/frontend/src/features/studio/sections/dataset-source-toggle.tsxindex 7c26d27e8cc..b53d6eca430 100644--- a/studio/frontend/src/features/studio/sections/dataset-source-toggle.tsx+++ b/studio/frontend/src/features/studio/sections/dataset-source-toggle.tsx@@ -11,18 +11,18 @@ type DatasetSourceMode = "browse" | "s3";export function DatasetSourceToggle({datasetSource,- isMultimodalModel,+ isVisionModel,restoreBrowseDatasetSource,selectS3Source,}: {datasetSource: DatasetSource;- isMultimodalModel: boolean;+ isVisionModel: boolean;restoreBrowseDatasetSource: () => void;selectS3Source: () => void;}) {const t = useT();- if (isMultimodalModel) {+ if (isVisionModel) {return null;}@@ -57,7 +57,6 @@ export function DatasetSourceToggleAction() {selectS3Source,restoreBrowseDatasetSource,isVisionModel,- isAudioModel,modelType,} = useTrainingConfigStore(useShallow((state) => ({@@ -65,7 +64,6 @@ export function DatasetSourceToggleAction() {selectS3Source: state.selectS3Source,restoreBrowseDatasetSource: state.restoreBrowseDatasetSource,isVisionModel: state.isVisionModel,- isAudioModel: state.isAudioModel,modelType: state.modelType,})),);@@ -74,12 +72,7 @@ export function DatasetSourceToggleAction() {return (<DatasetSourceToggledatasetSource={datasetSource}- isMultimodalModel={- effectiveModelType === "vision" ||- effectiveModelType === "audio" ||- isVisionModel ||- isAudioModel- }+ isVisionModel={effectiveModelType === "vision" || isVisionModel}restoreBrowseDatasetSource={restoreBrowseDatasetSource}selectS3Source={selectS3Source}/>diff --git a/studio/frontend/src/features/training/lib/validation.ts b/studio/frontend/src/features/training/lib/validation.tsindex ec2e2951e6a..61b86a0c8b8 100644--- a/studio/frontend/src/features/training/lib/validation.ts+++ b/studio/frontend/src/features/training/lib/validation.ts@@ -64,12 +64,8 @@ export function hasIncompatibleTrainingModalities(export function validateS3Source(config: TrainingConfigState,): StartValidationResult {- if (- config.modelType === "vision" ||- config.modelType === "audio" ||- config.isVisionModel ||- config.isAudioModel- ) {+ // Audio manifests are rewritten to downloaded paths (#4539); image references are not.+ if (config.modelType === "vision" || config.isVisionModel) {return {ok: false,errorKey: "studio.training.validation.s3MultimodalUnsupported",diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.tsindex e3df847da81..4e4943fd40f 100644--- a/studio/frontend/src/i18n/locales/ar.ts+++ b/studio/frontend/src/i18n/locales/ar.ts@@ -3187,7 +3187,7 @@ export const ar = {"تغيّر إعداد التدريب أثناء التحقق منه. راجعه ثم ابدأ التدريب مجددًا.",validation: {s3MultimodalUnsupported:- "مجموعات بيانات S3 غير مدعومة بعد لتدريب الرؤية أو الصوت.",+ "مجموعات بيانات S3 غير مدعومة بعد لتدريب الرؤية.",s3BucketRequired: "أدخل اسم حاوية S3 أولًا.",s3CredentialsRequired: "أدخل مفاتيح الوصول إلى S3 أو فعّل دور IAM.",modelRequired: "اختر نموذجًا أساسيًا أولًا.",diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.tsindex 3653e1ea8ae..a58b87f0840 100644--- a/studio/frontend/src/i18n/locales/de.ts+++ b/studio/frontend/src/i18n/locales/de.ts@@ -3245,7 +3245,7 @@ export const de = {"Die Trainingseinstellungen haben sich während der Überprüfung geändert. Prüfen Sie sie und starten Sie das Training erneut.",validation: {s3MultimodalUnsupported:- "S3-Datensätze werden für Vision- oder Audio-Training noch nicht unterstützt.",+ "S3-Datensätze werden für Vision-Training noch nicht unterstützt.",s3BucketRequired: "Geben Sie zuerst den Namen eines S3-Buckets ein.",s3CredentialsRequired:"Geben Sie S3-Zugriffsschlüssel an oder aktivieren Sie die IAM-Rolle.",diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex 965e76ef49e..10b8acb1dab 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -3195,7 +3195,7 @@ export const en = {chooseModelAndDataset: "Choose model and dataset",validation: {s3MultimodalUnsupported:- "S3 datasets are not supported for vision or audio training yet.",+ "S3 datasets are not supported for vision training yet.",s3BucketRequired: "Enter an S3 bucket name first.",s3CredentialsRequired: "Provide S3 access keys or enable IAM role.",modelRequired: "Select a base model first.",diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.tsindex 801dfd830cd..6dd5e1c7042 100644--- a/studio/frontend/src/i18n/locales/es.ts+++ b/studio/frontend/src/i18n/locales/es.ts@@ -3238,7 +3238,7 @@ export const es = {"La configuración del entrenamiento cambió mientras se comprobaba. Revísala y vuelve a iniciar el entrenamiento.",validation: {s3MultimodalUnsupported:- "Los conjuntos de datos de S3 todavía no son compatibles con el entrenamiento de visión o audio.",+ "Los conjuntos de datos de S3 todavía no son compatibles con el entrenamiento de visión.",s3BucketRequired: "Introduce primero el nombre de un bucket de S3.",s3CredentialsRequired:"Proporciona las claves de acceso de S3 o activa el rol de IAM.",diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.tsindex 6aa31cb58db..bc257cc1695 100644--- a/studio/frontend/src/i18n/locales/fr.ts+++ b/studio/frontend/src/i18n/locales/fr.ts@@ -3255,7 +3255,7 @@ export const fr = {"La configuration de l'entraînement a changé pendant sa vérification. Vérifiez-la, puis relancez l'entraînement.",validation: {s3MultimodalUnsupported:- "Les jeux de données S3 ne sont pas encore pris en charge pour l'entraînement de modèles de vision ou audio.",+ "Les jeux de données S3 ne sont pas encore pris en charge pour l'entraînement de modèles de vision.",s3BucketRequired: "Saisissez d'abord le nom d'un bucket S3.",s3CredentialsRequired:"Indiquez des clés d'accès S3 ou activez le rôle IAM.",diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.tsindex 8909cf5bd42..2266b4d8211 100644--- a/studio/frontend/src/i18n/locales/hi.ts+++ b/studio/frontend/src/i18n/locales/hi.ts@@ -3194,7 +3194,7 @@ export const hi = {"जांच के दौरान ट्रेनिंग सेटअप बदल गया। इसकी समीक्षा करें और फिर से ट्रेनिंग शुरू करें।",validation: {s3MultimodalUnsupported:- "S3 डेटासेट अभी विज़न या ऑडियो ट्रेनिंग के लिए समर्थित नहीं हैं।",+ "S3 डेटासेट अभी विज़न ट्रेनिंग के लिए समर्थित नहीं हैं।",s3BucketRequired: "पहले S3 बकेट का नाम दर्ज करें।",s3CredentialsRequired: "S3 एक्सेस कुंजियाँ दें या IAM रोल सक्षम करें।",modelRequired: "पहले बेस मॉडल चुनें।",diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.tsindex 2074596d4f5..c20cc1c7c1b 100644--- a/studio/frontend/src/i18n/locales/it.ts+++ b/studio/frontend/src/i18n/locales/it.ts@@ -3227,7 +3227,7 @@ export const it = {chooseModelAndDataset: "Scegli modello e dataset",validation: {s3MultimodalUnsupported:- "I dataset S3 non sono ancora supportati per l'addestramento visivo o audio.",+ "I dataset S3 non sono ancora supportati per l'addestramento visivo.",s3BucketRequired: "Inserisci prima il nome di un bucket S3.",s3CredentialsRequired:"Fornisci le chiavi di accesso S3 oppure attiva il ruolo IAM.",diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.tsindex 996fb0d1534..733faf1caf7 100644--- a/studio/frontend/src/i18n/locales/ja.ts+++ b/studio/frontend/src/i18n/locales/ja.ts@@ -3149,7 +3149,7 @@ export const ja = {"確認中にトレーニング設定が変更されました。設定を確認してから、トレーニングをもう一度開始してください。",validation: {s3MultimodalUnsupported:- "S3 データセットは、ビジョンまたはオーディオのトレーニングではまだサポートされていません。",+ "S3 データセットは、ビジョンのトレーニングではまだサポートされていません。",s3BucketRequired: "先に S3 バケット名を入力してください。",s3CredentialsRequired:"S3 アクセスキーを指定するか、IAM ロールを有効にしてください。",diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.tsindex 1025a09bd03..d072920e960 100644--- a/studio/frontend/src/i18n/locales/ko.ts+++ b/studio/frontend/src/i18n/locales/ko.ts@@ -3191,7 +3191,7 @@ export const ko = {"확인하는 동안 학습 설정이 변경되었습니다. 설정을 검토한 후 학습을 다시 시작하세요.",validation: {s3MultimodalUnsupported:- "비전 또는 오디오 학습에는 아직 S3 데이터셋을 사용할 수 없습니다.",+ "비전 학습에는 아직 S3 데이터셋을 사용할 수 없습니다.",s3BucketRequired: "S3 버킷 이름을 먼저 입력하세요.",s3CredentialsRequired:"S3 액세스 키를 입력하거나 IAM 역할을 활성화하세요.",diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.tsindex 3dca4b7428c..2914fdb2fa3 100644--- a/studio/frontend/src/i18n/locales/pt-br.ts+++ b/studio/frontend/src/i18n/locales/pt-br.ts@@ -3211,7 +3211,7 @@ export const ptBR = {"A configuração de treinamento mudou durante a verificação. Revise-a e inicie o treinamento novamente.",validation: {s3MultimodalUnsupported:- "Datasets do S3 ainda não são compatíveis com treinamento de visão ou áudio.",+ "Datasets do S3 ainda não são compatíveis com treinamento de visão.",s3BucketRequired: "Insira primeiro o nome de um bucket do S3.",s3CredentialsRequired:"Forneça as chaves de acesso do S3 ou ative a função do IAM.",diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.tsindex 6bd2d34ffae..13846054a40 100644--- a/studio/frontend/src/i18n/locales/ru.ts+++ b/studio/frontend/src/i18n/locales/ru.ts@@ -3222,7 +3222,7 @@ export const ru = {"Настройки обучения изменились во время проверки. Проверьте их и снова запустите обучение.",validation: {s3MultimodalUnsupported:- "Датасеты S3 пока не поддерживаются для обучения моделей зрения или аудио.",+ "Датасеты S3 пока не поддерживаются для обучения моделей зрения.",s3BucketRequired: "Сначала введите имя бакета S3.",s3CredentialsRequired:"Укажите ключи доступа S3 или включите роль IAM.",diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.tsindex f46defd34fb..5b6b868eae6 100644--- a/studio/frontend/src/i18n/locales/zh-CN.ts+++ b/studio/frontend/src/i18n/locales/zh-CN.ts@@ -3112,7 +3112,7 @@ export const zhCN = {"无法验证数据集与此模型是否兼容。请检查网络连接或 Hugging Face token;开始训练时会重试检查。",setupChanged: "检查期间,训练设置发生了变化。请确认设置后重新开始训练。",validation: {- s3MultimodalUnsupported: "S3 数据集暂不支持视觉或音频训练。",+ s3MultimodalUnsupported: "S3 数据集暂不支持视觉训练。",s3BucketRequired: "请先输入 S3 存储桶名称。",s3CredentialsRequired: "请提供 S3 访问密钥或启用 IAM 角色。",modelRequired: "请先选择基础模型。",diff --git a/studio/frontend/tests/training-validation.test.ts b/studio/frontend/tests/training-validation.test.tsindex d75258f5189..f774484eb04 100644--- a/studio/frontend/tests/training-validation.test.ts+++ b/studio/frontend/tests/training-validation.test.ts@@ -9,7 +9,7 @@ import { registerBundlerResolver } from "./helpers/kit.ts";registerBundlerResolver();-const { validateTrainingConfig } = await import(+const { validateS3Source, validateTrainingConfig } = await import("../src/features/training/lib/validation.ts");@@ -323,3 +323,26 @@ test("training validation keeps CPT and embedding training available off MLX", ({ ok: true, errorKey: null },);});++const s3Config = {+ ...validConfig,+ datasetSource: "s3" as const,+ s3Config: { bucket: "my-bucket", region: "us-east-1", useIamRole: true },+};++test("an audio model can start from S3 (#4539: the audio is downloaded beside its manifest)", () => {+ assert.deepEqual(+ validateS3Source({ ...s3Config, modelType: "audio", isAudioModel: true }),+ { ok: true, errorKey: null },+ );+});++test("a vision model still cannot start from S3", () => {+ assert.deepEqual(+ validateS3Source({ ...s3Config, modelType: "vision", isVisionModel: true }),+ {+ ok: false,+ errorKey: "studio.training.validation.s3MultimodalUnsupported",+ },+ );+});