unslothai/unsloth · info · S3DownloadCancelled
S3 dataset download cancelled
Error message
S3 dataset download cancelled
What it means
S3DownloadCancelled (a RuntimeError subclass, s3_dataset.py:39) raised by _raise_if_cancelled when the caller-supplied cancel_callback returns True. The download loop polls the callback at each phase (client build, listing, per-object download) so long S3 transfers can be aborted cooperatively. It is a control-flow signal, not a failure — the caller requested the cancellation.
Source
Thrown at studio/backend/core/training/s3_dataset.py:145
f"({', '.join(families)}). Keep one dataset format under the selected prefix."
)
def _unique_local_path(target_dir: str, filename: str, used_paths: set[str]) -> str:
"""Return an unused flattened path for an S3 object basename."""
stem, ext = os.path.splitext(filename)
candidate = os.path.join(target_dir, filename)
suffix = 1
while candidate in used_paths or os.path.exists(candidate):
candidate = os.path.join(target_dir, f"{stem}_{suffix}{ext}")
suffix += 1
used_paths.add(candidate)
return candidate
def _raise_if_cancelled(cancel_callback: Optional[Callable[[], bool]]) -> None:
if cancel_callback is not None and cancel_callback():
raise S3DownloadCancelled("S3 dataset download cancelled")
def prepare_s3_dataset_download(
s3_config: dict,
dest_dir: Optional[str] = None,
cancel_callback: Optional[Callable[[], bool]] = None,
) -> S3DatasetDownload:
"""Download supported dataset files from S3 to a local directory.
Returns the local files plus the owned temporary directory, when one was
created. Call ``cleanup()`` after the dataset loader has materialized data.
Raises ``RuntimeError`` if boto3 is missing, and ``ValueError`` if the
bucket/prefix contains no supported dataset files.
"""
if not boto3_available():
raise RuntimeError("S3 dataset loading requires boto3. Install it with: pip install boto3")
View on GitHub (pinned to 203007d190)
Solutions
- Catch S3DownloadCancelled explicitly in the caller and treat it as a normal cancellation (stop the workflow, clean the temp dir via the returned object's cleanup() or your own dest_dir).
- If the cancellation was unintended, fix the callback's state — e.g. a shared flag that a previous failed run left set to True.
- Reset/clear the cancel flag before starting a new download.
Example fix
// before
try:
dl = prepare_s3_dataset_download(cfg, cancel_callback=cb)
except RuntimeError as e: # swallows cancellation as generic failure
log.error(e)
// after
from core.training.s3_dataset import S3DownloadCancelled
try:
dl = prepare_s3_dataset_download(cfg, cancel_callback=cb)
except S3DownloadCancelled:
log.info("Download cancelled by user")
return Defensive patterns
Strategy: try-catch
Validate before calling
if cancel_callback is not None and cancel_callback():
# skip the call entirely — user already cancelled
return None Try / catch
from core.training.s3_dataset import S3DownloadCancelled
try:
dl = prepare_s3_dataset_download(cfg, cancel_callback=cb)
except S3DownloadCancelled:
# expected control flow: abort the training job cleanly
abort_job(reason='download_cancelled')
return Prevention
- Catch S3DownloadCancelled separately from generic RuntimeError.
- Reset the cancel flag before each new download attempt.
- Wire the cancel flag to the UI action once, and clear it on job teardown.
When it happens
Trigger: Passing cancel_callback=lambda: True (or one that flips to True after the user clicks Stop) into prepare_s3_dataset_download; the exception surfaces at the next callback checkpoint — during listing or between object downloads.
Common situations: UI 'Cancel' button wired to a flag the download polls; job orchestration cancelling a queued training run; timeouts implemented by the caller via a deadline-based callback.
Related errors
- Diffusion generation was cancelled.
- Audio generation cancelled
- Transcription cancelled.
- S3 prefix contains mixed dataset formats ({', '.join(familie
- S3 dataset loading requires boto3. Install it with: pip inst
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/511e4c28fd7881a0.
Report an issue: GitHub.