Spaces:
Running
Running
update readme
Browse files
README.md
CHANGED
@@ -13,42 +13,76 @@ short_description: AI Phone Leaderboard
|
|
13 |
|
14 |
# AI Phone Benchmark Leaderboard
|
15 |
|
16 |
-
Streamlit
|
17 |
|
18 |
-
##
|
19 |
|
20 |
-
|
21 |
-
-
|
22 |
-
-
|
23 |
-
-
|
24 |
-
- Responsive design
|
25 |
|
26 |
-
|
27 |
|
28 |
-
1.
|
29 |
```bash
|
30 |
-
|
|
|
31 |
```
|
32 |
|
33 |
-
2.
|
34 |
```bash
|
|
|
35 |
make setup-dev
|
36 |
```
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
```
|
43 |
|
44 |
-
|
45 |
```bash
|
46 |
make run
|
47 |
```
|
48 |
|
49 |
-
## Deployment
|
50 |
-
|
51 |
-
This application is configured for deployment on Hugging Face Spaces:
|
52 |
|
53 |
1. Create a new Space:
|
54 |
- Go to huggingface.co/spaces
|
@@ -56,25 +90,54 @@ This application is configured for deployment on Hugging Face Spaces:
|
|
56 |
- Select "Streamlit" as the SDK
|
57 |
- Choose a name for your space
|
58 |
|
59 |
-
2. Add
|
60 |
-
- Go to Space Settings
|
61 |
-
-
|
62 |
-
-
|
|
|
63 |
|
64 |
-
|
|
|
|
|
|
|
65 |
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
-
##
|
73 |
|
74 |
-
The application
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
## Development
|
80 |
|
@@ -88,4 +151,35 @@ make lint # Run code linter
|
|
88 |
make format # Format code using black
|
89 |
make test # Run tests
|
90 |
make clean # Clean cache files
|
91 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# AI Phone Benchmark Leaderboard
|
15 |
|
16 |
+
A Streamlit dashboard for displaying and analyzing mobile device AI benchmark results. The dashboard fetches data from Firebase Firestore and provides interactive visualizations and filtering capabilities.
|
17 |
|
18 |
+
## Setup
|
19 |
|
20 |
+
### Prerequisites
|
21 |
+
- Python 3.10+
|
22 |
+
- Firebase project with Firestore database
|
23 |
+
- Hugging Face account (for deployment)
|
|
|
24 |
|
25 |
+
### Local Development
|
26 |
|
27 |
+
1. Clone the repository:
|
28 |
```bash
|
29 |
+
git clone https://github.com/yourusername/ai-phone-leaderboard.git
|
30 |
+
cd ai-phone-leaderboard
|
31 |
```
|
32 |
|
33 |
+
2. Create a virtual environment and install dependencies:
|
34 |
```bash
|
35 |
+
make venv
|
36 |
make setup-dev
|
37 |
```
|
38 |
|
39 |
+
### Firebase Configuration
|
40 |
+
|
41 |
+
1. Create a Firebase Service Account:
|
42 |
+
- Go to Firebase Console β Project Settings β Service Accounts
|
43 |
+
- Create a new service account for the dashboard:
|
44 |
+
```bash
|
45 |
+
# Create service account
|
46 |
+
gcloud iam service-accounts create dashboard-firestore-reader \
|
47 |
+
--description="Service account for reading Firestore data in the dashboard" \
|
48 |
+
--display-name="Dashboard Firestore Reader"
|
49 |
+
```
|
50 |
+
- Grant minimal required permissions:
|
51 |
+
```bash
|
52 |
+
# Grant Firestore read-only access
|
53 |
+
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
|
54 |
+
--member="serviceAccount:dashboard-firestore-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com" \
|
55 |
+
--role="roles/datastore.viewer"
|
56 |
+
```
|
57 |
+
- Generate and download the service account key:
|
58 |
+
- Click "Generate New Private Key"
|
59 |
+
- Save the JSON file (don't commit this to git)
|
60 |
+
|
61 |
+
2. For local development, create `.streamlit/secrets.toml`:
|
62 |
+
```toml
|
63 |
+
FIREBASE_CREDENTIALS = '''
|
64 |
+
{
|
65 |
+
"type": "service_account",
|
66 |
+
"project_id": "your-project-id",
|
67 |
+
"private_key_id": "your-private-key-id",
|
68 |
+
"private_key": "your-private-key",
|
69 |
+
"client_email": "your-client-email",
|
70 |
+
"client_id": "your-client-id",
|
71 |
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
72 |
+
"token_uri": "https://oauth2.googleapis.com/token",
|
73 |
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
74 |
+
"client_x509_cert_url": "your-client-cert-url",
|
75 |
+
"universe_domain": "googleapis.com"
|
76 |
+
}
|
77 |
+
'''
|
78 |
```
|
79 |
|
80 |
+
3. Run the application:
|
81 |
```bash
|
82 |
make run
|
83 |
```
|
84 |
|
85 |
+
## Deployment to Hugging Face Spaces
|
|
|
|
|
86 |
|
87 |
1. Create a new Space:
|
88 |
- Go to huggingface.co/spaces
|
|
|
90 |
- Select "Streamlit" as the SDK
|
91 |
- Choose a name for your space
|
92 |
|
93 |
+
2. Add Firebase credentials to Spaces:
|
94 |
+
- Go to Space Settings β Repository Secrets
|
95 |
+
- Add a new secret named `FIREBASE_CREDENTIALS`
|
96 |
+
- Value should be your Firebase credentials as a minified JSON string (single line)
|
97 |
+
- Note: Convert the private key's newlines to `\n` in the JSON
|
98 |
|
99 |
+
Example of minified credentials for HF Spaces:
|
100 |
+
```json
|
101 |
+
{"type":"service_account","project_id":"your-project-id","private_key_id":"your-key-id","private_key":"-----BEGIN PRIVATE KEY-----\\nYour\\nPrivate\\nKey\\nHere\\n-----END PRIVATE KEY-----\\n","client_email":"your-email","client_id":"your-client-id","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_x509_cert_url":"your-cert-url","universe_domain":"googleapis.com"}
|
102 |
+
```
|
103 |
|
104 |
+
3. The application will automatically deploy when you push to the repository.
|
105 |
|
106 |
+
## Project Structure
|
107 |
+
```
|
108 |
+
.
|
109 |
+
βββ .gitignore
|
110 |
+
βββ .streamlit/
|
111 |
+
β βββ secrets.toml
|
112 |
+
βββ requirements/
|
113 |
+
β βββ base.txt
|
114 |
+
β βββ dev.txt
|
115 |
+
β βββ prod.txt
|
116 |
+
βββ src/
|
117 |
+
β βββ components/
|
118 |
+
β β βββ filters.py
|
119 |
+
β β βββ header.py
|
120 |
+
β β βββ visualizations.py
|
121 |
+
β βββ core/
|
122 |
+
β β βββ config.py
|
123 |
+
β βββ services/
|
124 |
+
β βββ firebase.py
|
125 |
+
βββ main.py
|
126 |
+
βββ requirements.txt
|
127 |
+
```
|
128 |
|
129 |
+
## Firebase Data Structure
|
130 |
|
131 |
+
The application expects the following Firestore collection structure:
|
132 |
+
```
|
133 |
+
benchmarks/
|
134 |
+
βββ v1/
|
135 |
+
βββ submissions/
|
136 |
+
βββ [benchmark_uuid]/
|
137 |
+
βββ benchmarkResult: {...}
|
138 |
+
βββ deviceInfo: {...}
|
139 |
+
βββ metadata: {...}
|
140 |
+
```
|
141 |
|
142 |
## Development
|
143 |
|
|
|
151 |
make format # Format code using black
|
152 |
make test # Run tests
|
153 |
make clean # Clean cache files
|
154 |
+
```
|
155 |
+
|
156 |
+
## Security Considerations
|
157 |
+
|
158 |
+
1. Never commit sensitive credentials to git:
|
159 |
+
```gitignore
|
160 |
+
# Add to .gitignore
|
161 |
+
.streamlit/secrets.toml
|
162 |
+
*firebase*.json
|
163 |
+
```
|
164 |
+
|
165 |
+
2. Use environment-specific secrets:
|
166 |
+
- Local: Use `.streamlit/secrets.toml`
|
167 |
+
- Production: Use HF Spaces secrets
|
168 |
+
|
169 |
+
3. Firebase Security:
|
170 |
+
- Create a dedicated service account with minimal permissions
|
171 |
+
- Only grant read access to the required Firestore collections
|
172 |
+
|
173 |
+
## Dependencies
|
174 |
+
|
175 |
+
Key dependencies are pinned to specific versions to ensure stability:
|
176 |
+
```
|
177 |
+
firebase-admin==6.6.0
|
178 |
+
streamlit>=1.28.0
|
179 |
+
pandas>=2.1.3
|
180 |
+
plotly>=5.18.0
|
181 |
+
```
|
182 |
+
|
183 |
+
## License
|
184 |
+
|
185 |
+
[MIT License](LICENSE)
|