|
5 | 5 | from dotenv import load_dotenv |
6 | 6 | from loguru import logger |
7 | 7 |
|
| 8 | +from ajet.utils.cleaner import fast_kill_by_keyword_bash |
8 | 9 | from ajet.utils.config_utils import prepare_experiment_config |
9 | 10 | from ajet.utils.launch_utils import ( |
10 | 11 | dict_to_namespace, |
@@ -41,6 +42,21 @@ def start_swarm_server(env, config, port): |
41 | 42 |
|
42 | 43 | def cmd_start(args): |
43 | 44 | """Handle the 'start' subcommand.""" |
| 45 | + if args.autokill: |
| 46 | + args.kill = "ray|vllm|VLLM|python" |
| 47 | + |
| 48 | + if args.kill: |
| 49 | + logger.info(f"Killing processes matching keywords: {args.kill}") |
| 50 | + for keyword in args.kill.split("|"): |
| 51 | + logger.info(f"Killing processes matching keyword: {keyword}") |
| 52 | + killed_pids = fast_kill_by_keyword_bash(keyword) |
| 53 | + if killed_pids: |
| 54 | + logger.success( |
| 55 | + f"Successfully killed processes with PIDs: {killed_pids}" |
| 56 | + ) |
| 57 | + else: |
| 58 | + logger.warning(f"No processes found matching keyword: {keyword}") |
| 59 | + |
44 | 60 | # Use default config if not provided |
45 | 61 | exp_base_dir = args.exp_dir or DEFAULT_DIR |
46 | 62 | if not args.conf: |
@@ -126,6 +142,19 @@ def main(): |
126 | 142 | required=False, |
127 | 143 | help="Debug tags; enables Ray post-mortem and DEBUG_TAGS env", |
128 | 144 | ) |
| 145 | + parser_start.add_argument( |
| 146 | + "--kill", |
| 147 | + type=str, |
| 148 | + default="", |
| 149 | + required=False, |
| 150 | + help="list of keywords for killing processes", |
| 151 | + ) |
| 152 | + parser_start.add_argument( |
| 153 | + "--autokill", |
| 154 | + action="store_true", |
| 155 | + default=False, |
| 156 | + help="Kill system processes (ray + vllm + python) that may block the current experiment", |
| 157 | + ) |
129 | 158 |
|
130 | 159 | parser_start.set_defaults(func=cmd_start) |
131 | 160 |
|
|
0 commit comments