Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/prime/src/prime_cli/commands/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from ..client import APIClient, APIError
from ..utils import output_data_as_json, validate_output_format
from ..utils.eval_push import push_eval_results_to_hub
from ..utils.formatters import format_file_size

app = typer.Typer(help="Manage verifiers environments", no_args_is_help=True)
console = Console()
Expand All @@ -32,6 +33,7 @@
MAX_FILES_TO_SHOW = 10
DEFAULT_HASH_LENGTH = 8
DEFAULT_LIST_LIMIT = 20
MAX_TARBALL_SIZE_LIMIT = 250 * 1024 * 1024 # 250MB


def should_include_file_in_archive(file_path: Path, base_path: Path) -> bool:
Expand Down Expand Up @@ -565,6 +567,32 @@ def push(
arcname = file.relative_to(env_path)
tar.add(file, arcname=str(arcname))

# Check tarball size
tarball_size = Path(tmp.name).stat().st_size
tarball_size_formatted = format_file_size(tarball_size)
console.print(f"Source archive size: {tarball_size_formatted}")

if tarball_size > MAX_TARBALL_SIZE_LIMIT:
max_size_formatted = format_file_size(MAX_TARBALL_SIZE_LIMIT)
console.print(
f"\n[yellow]⚠ Warning: Your tarball size ({tarball_size_formatted}) "
f"exceeds the recommended limit of {max_size_formatted}.[/yellow]"
)
console.print(
"[yellow]Large environment uploads may cause issues. Consider:[/yellow]"
)
console.print(
"[yellow] • Excluding large data files or model weights[/yellow]"
)
console.print(
"[yellow] • Checking for accidentally included build "
"artifacts[/yellow]"
)
console.print(
"[yellow] • Using .gitignore patterns to exclude unnecessary "
"files[/yellow]\n"
)

with open(tmp.name, "rb") as f:
source_sha256 = hashlib.sha256(f.read()).hexdigest()

Expand Down
12 changes: 12 additions & 0 deletions packages/prime/src/prime_cli/utils/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,15 @@ def format_resources(cpu_cores: int, memory_gb: int, gpu_count: int = 0) -> str:
def format_gpu_spec(gpu_type: str, gpu_count: int) -> str:
"""Format GPU specification as 'Type x Count'."""
return f"{gpu_type} x{gpu_count}"


def format_file_size(size_bytes: int) -> str:
"""Format file size in human-readable format."""
if size_bytes >= 1024 * 1024 * 1024:
return f"{size_bytes / (1024 * 1024 * 1024):.1f} GB"
elif size_bytes >= 1024 * 1024:
return f"{size_bytes / (1024 * 1024):.1f} MB"
elif size_bytes >= 1024:
return f"{size_bytes / 1024:.1f} KB"
else:
return f"{size_bytes} bytes"