genarena 0.0.1__py3-none-any.whl → 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- genarena/__init__.py +49 -2
- genarena/__main__.py +10 -0
- genarena/arena.py +1685 -0
- genarena/battle.py +337 -0
- genarena/bt_elo.py +507 -0
- genarena/cli.py +1581 -0
- genarena/data.py +476 -0
- genarena/deploy/Dockerfile +22 -0
- genarena/deploy/README.md +55 -0
- genarena/deploy/__init__.py +5 -0
- genarena/deploy/app.py +84 -0
- genarena/experiments.py +121 -0
- genarena/leaderboard.py +270 -0
- genarena/logs.py +409 -0
- genarena/models.py +412 -0
- genarena/prompts/__init__.py +127 -0
- genarena/prompts/mmrb2.py +373 -0
- genarena/sampling.py +336 -0
- genarena/state.py +656 -0
- genarena/sync/__init__.py +105 -0
- genarena/sync/auto_commit.py +118 -0
- genarena/sync/deploy_ops.py +543 -0
- genarena/sync/git_ops.py +422 -0
- genarena/sync/hf_ops.py +891 -0
- genarena/sync/init_ops.py +431 -0
- genarena/sync/packer.py +587 -0
- genarena/sync/submit.py +837 -0
- genarena/utils.py +103 -0
- genarena/validation/__init__.py +19 -0
- genarena/validation/schema.py +327 -0
- genarena/validation/validator.py +329 -0
- genarena/visualize/README.md +148 -0
- genarena/visualize/__init__.py +14 -0
- genarena/visualize/app.py +938 -0
- genarena/visualize/data_loader.py +2430 -0
- genarena/visualize/static/app.js +3762 -0
- genarena/visualize/static/model_aliases.json +86 -0
- genarena/visualize/static/style.css +4104 -0
- genarena/visualize/templates/index.html +413 -0
- genarena/vlm.py +519 -0
- genarena-0.1.1.dist-info/METADATA +178 -0
- genarena-0.1.1.dist-info/RECORD +44 -0
- {genarena-0.0.1.dist-info → genarena-0.1.1.dist-info}/WHEEL +1 -2
- genarena-0.1.1.dist-info/entry_points.txt +2 -0
- genarena-0.0.1.dist-info/METADATA +0 -26
- genarena-0.0.1.dist-info/RECORD +0 -5
- genarena-0.0.1.dist-info/top_level.txt +0 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Sync module for GenArena.
|
|
3
|
+
|
|
4
|
+
This module provides Git version control and Huggingface synchronization
|
|
5
|
+
capabilities for arena data.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from genarena.sync.git_ops import (
|
|
9
|
+
is_git_initialized,
|
|
10
|
+
git_init,
|
|
11
|
+
ensure_gitignore,
|
|
12
|
+
git_add_all,
|
|
13
|
+
git_commit,
|
|
14
|
+
has_uncommitted_changes,
|
|
15
|
+
git_remote_add,
|
|
16
|
+
git_remote_get_url,
|
|
17
|
+
git_push,
|
|
18
|
+
git_sync,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from genarena.sync.auto_commit import (
|
|
22
|
+
auto_commit_and_push,
|
|
23
|
+
with_auto_commit,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
from genarena.sync.hf_ops import (
|
|
27
|
+
get_hf_token,
|
|
28
|
+
require_hf_token,
|
|
29
|
+
validate_dataset_repo,
|
|
30
|
+
list_repo_files,
|
|
31
|
+
get_repo_file_info,
|
|
32
|
+
upload_file,
|
|
33
|
+
upload_files_batch,
|
|
34
|
+
download_file,
|
|
35
|
+
check_file_exists,
|
|
36
|
+
upload_arena_data,
|
|
37
|
+
pull_arena_data,
|
|
38
|
+
list_repo_contents,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
from genarena.sync.packer import (
|
|
42
|
+
pack_model_dir,
|
|
43
|
+
pack_exp_dir,
|
|
44
|
+
unpack_zip,
|
|
45
|
+
collect_upload_tasks,
|
|
46
|
+
collect_download_tasks,
|
|
47
|
+
TempPackingContext,
|
|
48
|
+
TaskType,
|
|
49
|
+
PackTask,
|
|
50
|
+
UnpackTask,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
from genarena.sync.init_ops import (
|
|
54
|
+
DEFAULT_BENCHMARK_REPO,
|
|
55
|
+
DEFAULT_ARENA_REPO,
|
|
56
|
+
discover_repo_subsets,
|
|
57
|
+
download_benchmark_data,
|
|
58
|
+
init_arena,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
__all__ = [
|
|
62
|
+
# Git operations
|
|
63
|
+
"is_git_initialized",
|
|
64
|
+
"git_init",
|
|
65
|
+
"ensure_gitignore",
|
|
66
|
+
"git_add_all",
|
|
67
|
+
"git_commit",
|
|
68
|
+
"has_uncommitted_changes",
|
|
69
|
+
"git_remote_add",
|
|
70
|
+
"git_remote_get_url",
|
|
71
|
+
"git_push",
|
|
72
|
+
"git_sync",
|
|
73
|
+
# Auto commit
|
|
74
|
+
"auto_commit_and_push",
|
|
75
|
+
"with_auto_commit",
|
|
76
|
+
# Huggingface operations
|
|
77
|
+
"get_hf_token",
|
|
78
|
+
"require_hf_token",
|
|
79
|
+
"validate_dataset_repo",
|
|
80
|
+
"list_repo_files",
|
|
81
|
+
"get_repo_file_info",
|
|
82
|
+
"upload_file",
|
|
83
|
+
"upload_files_batch",
|
|
84
|
+
"download_file",
|
|
85
|
+
"check_file_exists",
|
|
86
|
+
"upload_arena_data",
|
|
87
|
+
"pull_arena_data",
|
|
88
|
+
"list_repo_contents",
|
|
89
|
+
# Packer utilities
|
|
90
|
+
"pack_model_dir",
|
|
91
|
+
"pack_exp_dir",
|
|
92
|
+
"unpack_zip",
|
|
93
|
+
"collect_upload_tasks",
|
|
94
|
+
"collect_download_tasks",
|
|
95
|
+
"TempPackingContext",
|
|
96
|
+
"TaskType",
|
|
97
|
+
"PackTask",
|
|
98
|
+
"UnpackTask",
|
|
99
|
+
# Init operations
|
|
100
|
+
"DEFAULT_BENCHMARK_REPO",
|
|
101
|
+
"DEFAULT_ARENA_REPO",
|
|
102
|
+
"discover_repo_subsets",
|
|
103
|
+
"download_benchmark_data",
|
|
104
|
+
"init_arena",
|
|
105
|
+
]
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Copyright 2026 Ruihang Li.
|
|
2
|
+
# Licensed under the Apache License, Version 2.0.
|
|
3
|
+
# See LICENSE file in the project root for details.
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Auto commit module for GenArena.
|
|
7
|
+
|
|
8
|
+
This module provides automatic commit and push functionality
|
|
9
|
+
that is triggered after command execution.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import logging
|
|
13
|
+
from typing import Callable, TypeVar
|
|
14
|
+
|
|
15
|
+
from genarena.sync.git_ops import (
|
|
16
|
+
is_git_initialized,
|
|
17
|
+
has_uncommitted_changes,
|
|
18
|
+
git_commit,
|
|
19
|
+
git_push,
|
|
20
|
+
git_remote_get_url,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger(__name__)
|
|
24
|
+
|
|
25
|
+
# Type variable for generic decorator
|
|
26
|
+
T = TypeVar("T")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def auto_commit_and_push(arena_dir: str, command_name: str) -> None:
|
|
30
|
+
"""
|
|
31
|
+
Automatically commit and push changes after a command execution.
|
|
32
|
+
|
|
33
|
+
This function is designed to be called after commands that modify
|
|
34
|
+
arena_dir content (e.g., run, merge, delete). It silently skips
|
|
35
|
+
if Git is not initialized, and only warns on failure without
|
|
36
|
+
interrupting the main command flow.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
arena_dir: Path to the arena directory
|
|
40
|
+
command_name: Name of the command that triggered this auto-commit
|
|
41
|
+
"""
|
|
42
|
+
# Skip silently if Git is not initialized
|
|
43
|
+
if not is_git_initialized(arena_dir):
|
|
44
|
+
return
|
|
45
|
+
|
|
46
|
+
# Check if there are uncommitted changes
|
|
47
|
+
if not has_uncommitted_changes(arena_dir):
|
|
48
|
+
logger.debug(f"No changes to commit after {command_name}")
|
|
49
|
+
return
|
|
50
|
+
|
|
51
|
+
# Try to commit
|
|
52
|
+
try:
|
|
53
|
+
success, msg = git_commit(arena_dir, command_name=command_name)
|
|
54
|
+
if success:
|
|
55
|
+
if "Nothing to commit" not in msg:
|
|
56
|
+
logger.info(f"Auto-committed changes: {msg}")
|
|
57
|
+
else:
|
|
58
|
+
logger.warning(f"Auto-commit failed: {msg}")
|
|
59
|
+
return
|
|
60
|
+
except Exception as e:
|
|
61
|
+
logger.warning(f"Auto-commit failed with exception: {e}")
|
|
62
|
+
return
|
|
63
|
+
|
|
64
|
+
# Check if remote is configured and try to push
|
|
65
|
+
remote_url = git_remote_get_url(arena_dir)
|
|
66
|
+
if not remote_url:
|
|
67
|
+
logger.debug("No remote configured, skipping auto-push")
|
|
68
|
+
return
|
|
69
|
+
|
|
70
|
+
# Try to push
|
|
71
|
+
try:
|
|
72
|
+
success, msg = git_push(arena_dir)
|
|
73
|
+
if success:
|
|
74
|
+
logger.info(f"Auto-pushed changes: {msg}")
|
|
75
|
+
else:
|
|
76
|
+
logger.warning(f"Auto-push failed: {msg}")
|
|
77
|
+
except Exception as e:
|
|
78
|
+
logger.warning(f"Auto-push failed with exception: {e}")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def with_auto_commit(command_name: str):
|
|
82
|
+
"""
|
|
83
|
+
Decorator that adds auto-commit functionality to command functions.
|
|
84
|
+
|
|
85
|
+
The decorated function must have 'arena_dir' as an argument or
|
|
86
|
+
in its args namespace.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
command_name: Name of the command for commit message
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
Decorator function
|
|
93
|
+
"""
|
|
94
|
+
def decorator(func: Callable[..., int]) -> Callable[..., int]:
|
|
95
|
+
def wrapper(*args, **kwargs) -> int:
|
|
96
|
+
# Execute the original command
|
|
97
|
+
result = func(*args, **kwargs)
|
|
98
|
+
|
|
99
|
+
# Only auto-commit if the command succeeded (return code 0)
|
|
100
|
+
if result == 0:
|
|
101
|
+
# Try to get arena_dir from args
|
|
102
|
+
arena_dir = None
|
|
103
|
+
|
|
104
|
+
# Check kwargs first
|
|
105
|
+
if "arena_dir" in kwargs:
|
|
106
|
+
arena_dir = kwargs["arena_dir"]
|
|
107
|
+
# Check if first arg is argparse.Namespace
|
|
108
|
+
elif args and hasattr(args[0], "arena_dir"):
|
|
109
|
+
arena_dir = args[0].arena_dir
|
|
110
|
+
|
|
111
|
+
if arena_dir:
|
|
112
|
+
auto_commit_and_push(arena_dir, command_name)
|
|
113
|
+
|
|
114
|
+
return result
|
|
115
|
+
|
|
116
|
+
return wrapper
|
|
117
|
+
|
|
118
|
+
return decorator
|