Files
aitbc/cli/parsers/resource.py
aitbc 340d781f02
Some checks failed
CLI Tests / test-cli (push) Has been cancelled
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Documentation Validation / validate-docs (push) Has been cancelled
Documentation Validation / validate-policies-strict (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled
Python Tests / test-python (push) Failing after 1m34s
feat: add stub implementations for CLI commands to support graceful degradation
Added stub data returns and error handling across multiple CLI handlers to prevent
training script failures when services are unavailable:

- AI handlers: Return stub job data instead of sys.exit on errors, fix coordinator_url
  parameter handling, wrap task_data in proper structure for job submission
- Agent SDK: Add complete stub implementation for create/register/list/status/capabilities
- System handlers: Add graceful fall
2026-05-04 16:49:35 +02:00

37 lines
2.3 KiB
Python

"""Resource command registration for the unified CLI."""
import argparse
from parser_context import ParserContext
def register(subparsers: argparse._SubParsersAction, ctx: ParserContext) -> None:
resource_parser = subparsers.add_parser("resource", help="Resource utilization and allocation")
resource_parser.set_defaults(handler=lambda parsed, parser=resource_parser: parser.print_help())
resource_subparsers = resource_parser.add_subparsers(dest="resource_action")
resource_status_parser = resource_subparsers.add_parser("status", help="Show resource status")
resource_status_parser.add_argument("--type", choices=["cpu", "memory", "storage", "network", "all"], default="all")
resource_status_parser.set_defaults(handler=ctx.handle_resource_status)
resource_allocate_parser = resource_subparsers.add_parser("allocate", help="Allocate resources")
resource_allocate_parser.add_argument("--agent-id", required=True)
resource_allocate_parser.add_argument("--cpu", type=float)
resource_allocate_parser.add_argument("--memory", type=int)
resource_allocate_parser.add_argument("--duration", type=int)
resource_allocate_parser.set_defaults(handler=ctx.handle_resource_allocate)
resource_optimize_parser = resource_subparsers.add_parser("optimize", help="Optimize resource usage")
resource_optimize_parser.add_argument("--agent-id")
resource_optimize_parser.add_argument("--target", choices=["cpu", "memory", "all"], default="all")
resource_optimize_parser.set_defaults(handler=ctx.handle_resource_optimize)
resource_benchmark_parser = resource_subparsers.add_parser("benchmark", help="Run resource benchmark")
resource_benchmark_parser.add_argument("--type", choices=["cpu", "memory", "io", "all"], default="all")
resource_benchmark_parser.set_defaults(handler=ctx.handle_resource_benchmark)
resource_monitor_parser = resource_subparsers.add_parser("monitor", help="Monitor resource utilization")
resource_monitor_parser.add_argument("--interval", type=int, default=5, help="Monitoring interval in seconds")
resource_monitor_parser.add_argument("--duration", type=int, default=60, help="Monitoring duration in seconds")
resource_monitor_parser.set_defaults(handler=ctx.handle_resource_monitor)