MCPcopy Create free account
hub / github.com/cactus-compute/cactus / cmd_clean

Function cmd_clean

python/src/cli.py:1568–1697  ·  view source on GitHub ↗

Remove all build artifacts, caches, and downloaded weights.

(args)

Source from the content-addressed store, hash-verified

1566
1567
1568def cmd_clean(args):
1569 """Remove all build artifacts, caches, and downloaded weights."""
1570 print_color(BLUE, "Cleaning all build artifacts from Cactus project...")
1571 print(f"Project root: {PROJECT_ROOT}")
1572 print()
1573
1574 def remove_if_exists(path):
1575 if path.is_dir():
1576 print(f"Removing: {path}")
1577 shutil.rmtree(path)
1578 else:
1579 print(f"Not found: {path}")
1580
1581 remove_if_exists(PROJECT_ROOT / "cactus" / "build")
1582
1583 remove_if_exists(PROJECT_ROOT / "android" / "build")
1584 remove_if_exists(PROJECT_ROOT / "android" / "libs")
1585 remove_if_exists(PROJECT_ROOT / "android" / "arm64-v8a")
1586
1587 remove_if_exists(PROJECT_ROOT / "apple" / "build")
1588
1589 remove_if_exists(PROJECT_ROOT / "tests" / "build")
1590
1591 remove_if_exists(PROJECT_ROOT / "venv")
1592
1593 remove_if_exists(PROJECT_ROOT / "weights")
1594
1595 # Clean telemetry cache
1596 telemetry_cache = Path.home() / "Library" / "Caches" / "cactus" / "telemetry"
1597 if telemetry_cache.exists():
1598 print(f"Removing telemetry cache: {telemetry_cache}")
1599 shutil.rmtree(telemetry_cache)
1600 else:
1601 print(f"Telemetry cache not found: {telemetry_cache}")
1602
1603 # Re-cache API key from config so users don't need to run `cactus auth` again
1604 from .config_utils import CactusConfig
1605 config = CactusConfig()
1606 saved_key = config.load_config().get("api_key", "")
1607 if saved_key:
1608 config.cache_api_key(saved_key)
1609 masked = saved_key[:4] + "..." + saved_key[-4:]
1610 print(f"Restored cached API key: {masked}")
1611
1612 print()
1613 print("Removing compiled libraries and frameworks...")
1614
1615 preserve_roots = [
1616 PROJECT_ROOT / "libs" / "curl",
1617 PROJECT_ROOT / "android" / "mbedtls",
1618 PROJECT_ROOT / "libs" / "mbedtls",
1619 ]
1620
1621 def should_preserve_artifact(path: Path) -> bool:
1622 try:
1623 resolved = path.resolve()
1624 except FileNotFoundError:
1625 return False

Callers 1

mainFunction · 0.85

Calls 7

load_configMethod · 0.95
cache_api_keyMethod · 0.95
print_colorFunction · 0.85
remove_if_existsFunction · 0.85
CactusConfigClass · 0.85
should_preserve_artifactFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected