fix: Make agent names unique for det deploy local agent-up
import argparse
+import socket
import sys
from pathlib import Path
from typing import Callable, Dict
@@ -8,6 +9,8 @@ from determined.common.declarative_argparse import Arg, BoolOptArg, Cmd, Group
from . import cluster_utils
from .preflight import check_docker_install
+AGENT_NAME_DEFAULT = "det-agent-<hostname>"
+
def handle_cluster_up(args: argparse.Namespace) -> None:
if not args.no_preflight_checks:
@@ -58,11 +61,16 @@ def handle_master_down(args: argparse.Namespace) -> None:
def handle_agent_up(args: argparse.Namespace) -> None:
+
+ agent_name = args.agent_name
+ if args.agent_name == AGENT_NAME_DEFAULT:
+ agent_name = f"det-agent-{socket.gethostname()}"
+
cluster_utils.agent_up(
master_host=args.master_host,
master_port=args.master_port,
gpu=args.gpu,
- agent_name=args.agent_name,
+ agent_name=agent_name,
agent_label=args.agent_label,
agent_resource_pool=args.agent_resource_pool,
image_repo_prefix=args.image_repo_prefix,
@@ -74,10 +82,15 @@ def handle_agent_up(args: argparse.Namespace) -> None:
def handle_agent_down(args: argparse.Namespace) -> None:
+
+ agent_name = args.agent_name
+ if args.agent_name == AGENT_NAME_DEFAULT:
+ agent_name = f"det-agent-{socket.gethostname()}"
+
if args.all:
cluster_utils.stop_all_agents()
else:
- cluster_utils.stop_agent(agent_name=args.agent_name)
+ cluster_utils.stop_agent(agent_name=agent_name)
def deploy_local(args: argparse.Namespace) -> None:
@@ -284,7 +297,7 @@ args_description = Cmd(
Arg("master_host", type=str, help="master hostname"),
Arg("--master-port", type=int, default=8080, help="master port"),
Arg("--det-version", type=str, default=None, help="version or commit to use"),
- Arg("--agent-name", type=str, default="det-agent", help="agent name"),
+ Arg("--agent-name", type=str, default=AGENT_NAME_DEFAULT, help="agent name"),
Arg("--agent-label", type=str, default=None, help="agent label"),
Arg("--agent-resource-pool", type=str, default=None, help="agent resource pool"),
BoolOptArg(
@@ -313,7 +326,7 @@ args_description = Cmd(
handle_agent_down,
"Stop a Determined agent",
[
- Arg("--agent-name", type=str, default="det-agent", help="agent name"),
+ Arg("--agent-name", type=str, default=AGENT_NAME_DEFAULT, help="agent name"),
Arg("--all", help="stop all running agents", action="store_true"),
Arg(
"--cluster-name",
