Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -366,6 +366,25 @@ def clear_data():
|
|
| 366 |
print(f"The directory '{dir_path}' does not exist.")
|
| 367 |
|
| 368 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 369 |
def merge_loop():
|
| 370 |
"""
|
| 371 |
Main function that orchestrates the merge.
|
|
@@ -381,7 +400,7 @@ def merge_loop():
|
|
| 381 |
df = make_df("open-llm-leaderboard.csv", N_ROWS)
|
| 382 |
|
| 383 |
# Sample two models
|
| 384 |
-
|
| 385 |
sample = df.sample(n=2)
|
| 386 |
models = [sample.iloc[i] for i in range(2)]
|
| 387 |
|
|
@@ -397,31 +416,30 @@ def merge_loop():
|
|
| 397 |
# Merge configs
|
| 398 |
yaml_config = create_config(models)
|
| 399 |
print(f"YAML config:{yaml_config}")
|
| 400 |
-
|
| 401 |
|
| 402 |
# Merge models
|
| 403 |
merge_models()
|
| 404 |
print("Model merged!")
|
| 405 |
-
|
| 406 |
-
subprocess.run(["ls", "-larth"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
| 407 |
|
| 408 |
# Create model card
|
| 409 |
print("Create model card")
|
| 410 |
create_model_card(yaml_config, model_name, USERNAME, license)
|
| 411 |
-
|
| 412 |
|
| 413 |
# Upload model
|
| 414 |
print("Upload model")
|
| 415 |
upload_model(api, USERNAME, model_name)
|
| 416 |
-
|
| 417 |
|
| 418 |
# Clear data
|
| 419 |
clear_data()
|
| 420 |
-
|
| 421 |
|
| 422 |
# Evaluate model on Runpod
|
| 423 |
create_pod(model_name, USERNAME)
|
| 424 |
-
|
| 425 |
|
| 426 |
|
| 427 |
# Install scrape-open-llm-leaderboard and mergekit
|
|
|
|
| 366 |
print(f"The directory '{dir_path}' does not exist.")
|
| 367 |
|
| 368 |
|
| 369 |
+
def get_size(start_path):
|
| 370 |
+
total_size = 0
|
| 371 |
+
for dirpath, dirnames, filenames in os.walk(start_path):
|
| 372 |
+
for f in filenames:
|
| 373 |
+
fp = os.path.join(dirpath, f)
|
| 374 |
+
# skip if it is symbolic link
|
| 375 |
+
if not os.path.islink(fp):
|
| 376 |
+
total_size += os.path.getsize(fp)
|
| 377 |
+
return total_size
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
def human_readable_size(size, decimal_places=2):
|
| 381 |
+
for unit in ['B', 'KB', 'MB', 'GB', 'TB', 'PB']:
|
| 382 |
+
if size < 1024.0:
|
| 383 |
+
break
|
| 384 |
+
size /= 1024.0
|
| 385 |
+
return f"{size:.{decimal_places}f} {unit}"
|
| 386 |
+
|
| 387 |
+
|
| 388 |
def merge_loop():
|
| 389 |
"""
|
| 390 |
Main function that orchestrates the merge.
|
|
|
|
| 400 |
df = make_df("open-llm-leaderboard.csv", N_ROWS)
|
| 401 |
|
| 402 |
# Sample two models
|
| 403 |
+
print(f"Total size: {human_readable_size(get_size('.'))}")
|
| 404 |
sample = df.sample(n=2)
|
| 405 |
models = [sample.iloc[i] for i in range(2)]
|
| 406 |
|
|
|
|
| 416 |
# Merge configs
|
| 417 |
yaml_config = create_config(models)
|
| 418 |
print(f"YAML config:{yaml_config}")
|
| 419 |
+
print(f"Total size: {human_readable_size(get_size('.'))}")
|
| 420 |
|
| 421 |
# Merge models
|
| 422 |
merge_models()
|
| 423 |
print("Model merged!")
|
| 424 |
+
print(f"Total size: {human_readable_size(get_size('.'))}")
|
|
|
|
| 425 |
|
| 426 |
# Create model card
|
| 427 |
print("Create model card")
|
| 428 |
create_model_card(yaml_config, model_name, USERNAME, license)
|
| 429 |
+
print(f"Total size: {human_readable_size(get_size('.'))}")
|
| 430 |
|
| 431 |
# Upload model
|
| 432 |
print("Upload model")
|
| 433 |
upload_model(api, USERNAME, model_name)
|
| 434 |
+
print(f"Total size: {human_readable_size(get_size('.'))}")
|
| 435 |
|
| 436 |
# Clear data
|
| 437 |
clear_data()
|
| 438 |
+
print(f"Total size: {human_readable_size(get_size('.'))}")
|
| 439 |
|
| 440 |
# Evaluate model on Runpod
|
| 441 |
create_pod(model_name, USERNAME)
|
| 442 |
+
print(f"Total size: {human_readable_size(get_size('.'))}")
|
| 443 |
|
| 444 |
|
| 445 |
# Install scrape-open-llm-leaderboard and mergekit
|