Spaces:
Sleeping
Sleeping
Update backend/utils/analyze_prod_models.py
Browse files
backend/utils/analyze_prod_models.py
CHANGED
|
@@ -5,7 +5,7 @@ from datetime import datetime
|
|
| 5 |
from pathlib import Path
|
| 6 |
from huggingface_hub import HfApi
|
| 7 |
from dotenv import load_dotenv
|
| 8 |
-
from app.config.hf_config import HF_ORGANIZATION
|
| 9 |
|
| 10 |
# Get the backend directory path
|
| 11 |
BACKEND_DIR = Path(__file__).parent.parent
|
|
@@ -22,22 +22,22 @@ logging.basicConfig(
|
|
| 22 |
logger = logging.getLogger(__name__)
|
| 23 |
|
| 24 |
# Initialize Hugging Face API
|
| 25 |
-
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 26 |
-
if not HF_TOKEN:
|
| 27 |
-
raise ValueError("HF_TOKEN not found in environment variables")
|
| 28 |
api = HfApi(token=HF_TOKEN)
|
| 29 |
|
| 30 |
def count_evaluated_models():
|
| 31 |
"""Count the number of evaluated models"""
|
| 32 |
try:
|
| 33 |
# Get dataset info
|
| 34 |
-
dataset_info = api.dataset_info(repo_id=f"{HF_ORGANIZATION}/
|
| 35 |
|
| 36 |
# Get file list
|
| 37 |
-
files = api.list_repo_files(f"{HF_ORGANIZATION}/
|
| 38 |
|
| 39 |
# Get last commit info
|
| 40 |
-
commits = api.list_repo_commits(f"{HF_ORGANIZATION}/
|
| 41 |
last_commit = next(commits, None)
|
| 42 |
|
| 43 |
# Count lines in jsonl files
|
|
@@ -47,7 +47,7 @@ def count_evaluated_models():
|
|
| 47 |
try:
|
| 48 |
# Download file content
|
| 49 |
content = api.hf_hub_download(
|
| 50 |
-
repo_id=f"{HF_ORGANIZATION}/
|
| 51 |
filename=file,
|
| 52 |
repo_type="dataset"
|
| 53 |
)
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
from huggingface_hub import HfApi
|
| 7 |
from dotenv import load_dotenv
|
| 8 |
+
from app.config.hf_config import HF_TOKEN, HF_ORGANIZATION, HF_AGGREGATED
|
| 9 |
|
| 10 |
# Get the backend directory path
|
| 11 |
BACKEND_DIR = Path(__file__).parent.parent
|
|
|
|
| 22 |
logger = logging.getLogger(__name__)
|
| 23 |
|
| 24 |
# Initialize Hugging Face API
|
| 25 |
+
# HF_TOKEN = os.getenv("HF_TOKEN")
|
| 26 |
+
# if not HF_TOKEN:
|
| 27 |
+
# raise ValueError("HF_TOKEN not found in environment variables")
|
| 28 |
api = HfApi(token=HF_TOKEN)
|
| 29 |
|
| 30 |
def count_evaluated_models():
|
| 31 |
"""Count the number of evaluated models"""
|
| 32 |
try:
|
| 33 |
# Get dataset info
|
| 34 |
+
dataset_info = api.dataset_info(repo_id=f"{HF_ORGANIZATION}/{HF_AGGREGATED}", repo_type="dataset")
|
| 35 |
|
| 36 |
# Get file list
|
| 37 |
+
files = api.list_repo_files(f"{HF_ORGANIZATION}/{HF_AGGREGATED}", repo_type="dataset")
|
| 38 |
|
| 39 |
# Get last commit info
|
| 40 |
+
commits = api.list_repo_commits(f"{HF_ORGANIZATION}/{HF_AGGREGATED}", repo_type="dataset")
|
| 41 |
last_commit = next(commits, None)
|
| 42 |
|
| 43 |
# Count lines in jsonl files
|
|
|
|
| 47 |
try:
|
| 48 |
# Download file content
|
| 49 |
content = api.hf_hub_download(
|
| 50 |
+
repo_id=f"{HF_ORGANIZATION}/{HF_AGGREGATED}",
|
| 51 |
filename=file,
|
| 52 |
repo_type="dataset"
|
| 53 |
)
|