Tuan Tran commited on
Commit
8838bd8
·
1 Parent(s): 671849b

update app

Browse files
Files changed (2) hide show
  1. .gitattributes +1 -0
  2. backend/app.py +44 -14
.gitattributes CHANGED
@@ -36,3 +36,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
36
  *.png filter=lfs diff=lfs merge=lfs -text
37
  *.wav filter=lfs diff=lfs merge=lfs -text
38
  *.mp4 filter=lfs diff=lfs merge=lfs -text
 
 
36
  *.png filter=lfs diff=lfs merge=lfs -text
37
  *.wav filter=lfs diff=lfs merge=lfs -text
38
  *.mp4 filter=lfs diff=lfs merge=lfs -text
39
+ backend/data/* filter=lfs diff=lfs merge=lfs -text
backend/app.py CHANGED
@@ -1,20 +1,33 @@
1
- import json
2
- import logging
3
- import mimetypes
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  import os
5
- from urllib.parse import unquote
6
-
 
 
 
 
 
 
 
7
  import requests
 
 
8
 
9
- import pandas as pd
10
- from backend.config import ABS_DATASET_DOMAIN, get_dataset_config, get_datasets
11
- from backend.descriptions import (DATASET_DESCRIPTIONS, DESCRIPTIONS,
12
- METRIC_DESCRIPTIONS, MODEL_DESCRIPTIONS)
13
- from backend.examples import get_examples_tab
14
- from flask import Flask, Response, request, send_from_directory
15
- from flask_cors import CORS
16
- from tools import get_leaderboard_filters # Import your function
17
- from tools import get_old_format_dataframe
18
 
19
  logger = logging.getLogger(__name__)
20
  if not logger.hasHandlers():
@@ -75,6 +88,23 @@ def data_files(dataset_name):
75
  return "File not found", 404
76
 
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  @app.route("/examples/<path:type>")
79
  def example_files(type):
80
  """
 
1
+ from backend.config import (
2
+ ABS_DATASET_DOMAIN,
3
+ get_dataset_config,
4
+ get_datasets,
5
+ )
6
+ from backend.descriptions import (
7
+ DATASET_DESCRIPTIONS,
8
+ DESCRIPTIONS,
9
+ METRIC_DESCRIPTIONS,
10
+ MODEL_DESCRIPTIONS,
11
+ )
12
+ from backend.examples import (
13
+ get_examples_tab,
14
+ )
15
+ from flask import Flask, Response, send_from_directory, request
16
+ from flask_cors import CORS
17
  import os
18
+ import logging
19
+ import pandas as pd
20
+ import json
21
+ from io import StringIO
22
+ from tools import (
23
+ get_leaderboard_filters,
24
+ get_old_format_dataframe,
25
+ ) # Import your function
26
+ import typing as tp
27
  import requests
28
+ from urllib.parse import unquote
29
+ import mimetypes
30
 
 
 
 
 
 
 
 
 
 
31
 
32
  logger = logging.getLogger(__name__)
33
  if not logger.hasHandlers():
 
88
  return "File not found", 404
89
 
90
 
91
+ @app.route("/files/<path:file_path>")
92
+ def serve_file_path(file_path):
93
+ """
94
+ Serves files from S3 or locally based on config
95
+ """
96
+ # Get the absolute path to the file
97
+ abs_path = file_path
98
+ logger.info(f"Looking for file: {abs_path}")
99
+ try:
100
+ with open(abs_path, "rb") as f:
101
+ content = f.read()
102
+ return Response(content, mimetype="application/octet-stream")
103
+ except FileNotFoundError:
104
+ logger.error(f"Failed to fetch file: {abs_path}")
105
+ return "File not found", 404
106
+
107
+
108
  @app.route("/examples/<path:type>")
109
  def example_files(type):
110
  """