From 107eef55b45432f70fda926994a7a158cd964067 Mon Sep 17 00:00:00 2001 From: Kastan Day Date: Tue, 12 Mar 2024 10:41:24 -0600 Subject: [PATCH] Fix mimetype parsing for ValueError: not enough values to unpack (expected 2, got 1) --- ai_ta_backend/beam/ingest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ai_ta_backend/beam/ingest.py b/ai_ta_backend/beam/ingest.py index 5dfca7fd..a8ec7786 100644 --- a/ai_ta_backend/beam/ingest.py +++ b/ai_ta_backend/beam/ingest.py @@ -14,7 +14,7 @@ import uuid from pathlib import Path from tempfile import NamedTemporaryFile -from typing import Any, Callable, Dict, List, Union +from typing import Any, Callable, Dict, List, Optional, Union import beam import boto3 @@ -245,7 +245,7 @@ def _ingest_single(ingest_method: Callable, s3_path, *args, **kwargs): with NamedTemporaryFile(suffix=file_extension) as tmpfile: self.s3_client.download_fileobj(Bucket=os.environ['S3_BUCKET_NAME'], Key=s3_path, Fileobj=tmpfile) mime_type = str(mimetypes.guess_type(tmpfile.name, strict=False)[0]) - mime_category, mime_subcategory = mime_type.split('/') + mime_category = mime_type.split('/')[0] if '/' in mime_type else mime_type if file_extension in file_ingest_methods: # Use specialized functions when possible, fallback to mimetype. Else raise error.