Perilon commited on
Commit
5a4b416
·
1 Parent(s): 2daffd5
Files changed (3) hide show
  1. .hf-space +2 -1
  2. Dockerfile +2 -2
  3. flask_app.py +6 -2
.hf-space CHANGED
@@ -14,4 +14,5 @@ config:
14
  cpu: 1
15
  memory: 1
16
  gpu: null
17
- restarts: true
 
 
14
  cpu: 1
15
  memory: 1
16
  gpu: null
17
+ restarts: true
18
+ sdk: docker
Dockerfile CHANGED
@@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y ffmpeg && apt-get clean
12
  # Copy application code
13
  COPY . .
14
 
15
- # Set environment variables for HF Spaces
16
  ENV PYTHONUNBUFFERED=1
17
  ENV PORT=7860
18
  ENV SPACE_ID="true"
@@ -29,5 +29,5 @@ RUN mkdir -p data/videos data/annotations data/temp data/word_timestamps data/al
29
  # Make port available
30
  EXPOSE 7860
31
 
32
- # Run with gunicorn for better stability
33
  CMD exec gunicorn --bind :7860 --workers 1 --threads 2 --timeout 600 "flask_app:app"
 
12
  # Copy application code
13
  COPY . .
14
 
15
+ # Set environment variables
16
  ENV PYTHONUNBUFFERED=1
17
  ENV PORT=7860
18
  ENV SPACE_ID="true"
 
29
  # Make port available
30
  EXPOSE 7860
31
 
32
+ # Run with gunicorn
33
  CMD exec gunicorn --bind :7860 --workers 1 --threads 2 --timeout 600 "flask_app:app"
flask_app.py CHANGED
@@ -654,6 +654,10 @@ def get_s3_client():
654
 
655
  def list_s3_videos():
656
  """List all videos in the S3 bucket with the given prefix."""
 
 
 
 
657
  try:
658
  s3_client = get_s3_client()
659
  response = s3_client.list_objects_v2(
@@ -676,8 +680,8 @@ def list_s3_videos():
676
  videos.append(video_id)
677
 
678
  return videos
679
- except ClientError as e:
680
- logger.error(f"Error listing videos from S3: {str(e)}")
681
  return []
682
 
683
  def download_video_from_s3(video_id):
 
654
 
655
  def list_s3_videos():
656
  """List all videos in the S3 bucket with the given prefix."""
657
+ if not os.environ.get('AWS_ACCESS_KEY_ID') or not os.environ.get('AWS_SECRET_ACCESS_KEY'):
658
+ logger.warning("AWS credentials not found. Returning empty video list.")
659
+ return []
660
+
661
  try:
662
  s3_client = get_s3_client()
663
  response = s3_client.list_objects_v2(
 
680
  videos.append(video_id)
681
 
682
  return videos
683
+ except Exception as e:
684
+ logger.error(f"Error listing S3 videos: {str(e)}")
685
  return []
686
 
687
  def download_video_from_s3(video_id):