add random name genration to agent registration
Some checks failed
Build Sphinx Docs Set / Build Docs (pull_request) Successful in 20s
Build Project / Build Project (3.10) (pull_request) Successful in 11m17s
Build Project / Build Project (3.12) (pull_request) Successful in 11m2s
Build Project / Build Project (3.11) (pull_request) Successful in 13m18s
Test with tox / Test with tox (3.11) (pull_request) Successful in 15m24s
Test with tox / Test with tox (3.10) (pull_request) Failing after 17m19s
Test with tox / Test with tox (3.12) (pull_request) Successful in 17m48s
Some checks failed
Build Sphinx Docs Set / Build Docs (pull_request) Successful in 20s
Build Project / Build Project (3.10) (pull_request) Successful in 11m17s
Build Project / Build Project (3.12) (pull_request) Successful in 11m2s
Build Project / Build Project (3.11) (pull_request) Successful in 13m18s
Test with tox / Test with tox (3.11) (pull_request) Successful in 15m24s
Test with tox / Test with tox (3.10) (pull_request) Failing after 17m19s
Test with tox / Test with tox (3.12) (pull_request) Successful in 17m48s
This commit is contained in:
parent
5035f0654a
commit
ea8ed56a7d
|
|
@ -23,6 +23,7 @@ import sys
|
||||||
from . import config as _config
|
from . import config as _config
|
||||||
from .hardware import available_devices
|
from .hardware import available_devices
|
||||||
from .legacy_executor import main as _legacy_main
|
from .legacy_executor import main as _legacy_main
|
||||||
|
from .namegen import generate_agent_name
|
||||||
|
|
||||||
_LEGACY_ALIASES = {"--hub", "--key", "--name", "--device", "--insecure", "--log-level", "--config"}
|
_LEGACY_ALIASES = {"--hub", "--key", "--name", "--device", "--insecure", "--log-level", "--config"}
|
||||||
|
|
||||||
|
|
@ -42,7 +43,8 @@ def _cmd_register(args: argparse.Namespace) -> int:
|
||||||
|
|
||||||
hub_url = args.hub.rstrip("/")
|
hub_url = args.hub.rstrip("/")
|
||||||
url = f"{hub_url}/screens/agents/register"
|
url = f"{hub_url}/screens/agents/register"
|
||||||
body = json.dumps({"name": args.name or ""}).encode()
|
name = args.name or generate_agent_name()
|
||||||
|
body = json.dumps({"name": name}).encode()
|
||||||
req = urllib.request.Request(
|
req = urllib.request.Request(
|
||||||
url,
|
url,
|
||||||
data=body,
|
data=body,
|
||||||
|
|
@ -66,8 +68,7 @@ def _cmd_register(args: argparse.Namespace) -> int:
|
||||||
cfg.agent_id = agent_id
|
cfg.agent_id = agent_id
|
||||||
cfg.token = token
|
cfg.token = token
|
||||||
cfg.api_key = args.api_key
|
cfg.api_key = args.api_key
|
||||||
if args.name:
|
cfg.name = name
|
||||||
cfg.name = args.name
|
|
||||||
cfg.insecure = bool(args.insecure)
|
cfg.insecure = bool(args.insecure)
|
||||||
cfg.tx_enabled = bool(getattr(args, "allow_tx", False))
|
cfg.tx_enabled = bool(getattr(args, "allow_tx", False))
|
||||||
if (v := getattr(args, "tx_max_gain_db", None)) is not None:
|
if (v := getattr(args, "tx_max_gain_db", None)) is not None:
|
||||||
|
|
|
||||||
147
src/ria_toolkit_oss/agent/namegen.py
Normal file
147
src/ria_toolkit_oss/agent/namegen.py
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
"""Generate random human-readable agent names.
|
||||||
|
|
||||||
|
Produces names in the form ``adjective-colour-animal``, e.g.
|
||||||
|
``swift-teal-falcon`` or ``brave-coral-otter``. All words are chosen
|
||||||
|
to be friendly and inoffensive.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import random
|
||||||
|
|
||||||
|
ADJECTIVES: list[str] = [
|
||||||
|
"brave",
|
||||||
|
"bright",
|
||||||
|
"calm",
|
||||||
|
"clever",
|
||||||
|
"cool",
|
||||||
|
"daring",
|
||||||
|
"eager",
|
||||||
|
"fair",
|
||||||
|
"fancy",
|
||||||
|
"fast",
|
||||||
|
"fierce",
|
||||||
|
"gentle",
|
||||||
|
"grand",
|
||||||
|
"happy",
|
||||||
|
"jolly",
|
||||||
|
"keen",
|
||||||
|
"kind",
|
||||||
|
"lively",
|
||||||
|
"lucky",
|
||||||
|
"mighty",
|
||||||
|
"noble",
|
||||||
|
"plucky",
|
||||||
|
"proud",
|
||||||
|
"quick",
|
||||||
|
"quiet",
|
||||||
|
"sharp",
|
||||||
|
"shiny",
|
||||||
|
"sleek",
|
||||||
|
"smart",
|
||||||
|
"steady",
|
||||||
|
"stellar",
|
||||||
|
"strong",
|
||||||
|
"sturdy",
|
||||||
|
"sunny",
|
||||||
|
"sure",
|
||||||
|
"swift",
|
||||||
|
"tall",
|
||||||
|
"vivid",
|
||||||
|
"warm",
|
||||||
|
"wise",
|
||||||
|
]
|
||||||
|
|
||||||
|
COLOURS: list[str] = [
|
||||||
|
"amber",
|
||||||
|
"aqua",
|
||||||
|
"azure",
|
||||||
|
"beige",
|
||||||
|
"blue",
|
||||||
|
"bronze",
|
||||||
|
"coral",
|
||||||
|
"copper",
|
||||||
|
"crimson",
|
||||||
|
"cyan",
|
||||||
|
"denim",
|
||||||
|
"gold",
|
||||||
|
"green",
|
||||||
|
"grey",
|
||||||
|
"indigo",
|
||||||
|
"ivory",
|
||||||
|
"jade",
|
||||||
|
"lemon",
|
||||||
|
"lilac",
|
||||||
|
"lime",
|
||||||
|
"maroon",
|
||||||
|
"mint",
|
||||||
|
"navy",
|
||||||
|
"olive",
|
||||||
|
"onyx",
|
||||||
|
"peach",
|
||||||
|
"pearl",
|
||||||
|
"plum",
|
||||||
|
"red",
|
||||||
|
"rose",
|
||||||
|
"ruby",
|
||||||
|
"rust",
|
||||||
|
"sage",
|
||||||
|
"sand",
|
||||||
|
"scarlet",
|
||||||
|
"silver",
|
||||||
|
"slate",
|
||||||
|
"steel",
|
||||||
|
"teal",
|
||||||
|
"violet",
|
||||||
|
]
|
||||||
|
|
||||||
|
ANIMALS: list[str] = [
|
||||||
|
"badger",
|
||||||
|
"bear",
|
||||||
|
"bison",
|
||||||
|
"crane",
|
||||||
|
"deer",
|
||||||
|
"dolphin",
|
||||||
|
"eagle",
|
||||||
|
"elk",
|
||||||
|
"falcon",
|
||||||
|
"finch",
|
||||||
|
"fox",
|
||||||
|
"gecko",
|
||||||
|
"hawk",
|
||||||
|
"heron",
|
||||||
|
"horse",
|
||||||
|
"ibis",
|
||||||
|
"jaguar",
|
||||||
|
"jay",
|
||||||
|
"kite",
|
||||||
|
"koala",
|
||||||
|
"lark",
|
||||||
|
"lion",
|
||||||
|
"lynx",
|
||||||
|
"marten",
|
||||||
|
"moose",
|
||||||
|
"newt",
|
||||||
|
"orca",
|
||||||
|
"osprey",
|
||||||
|
"otter",
|
||||||
|
"owl",
|
||||||
|
"panda",
|
||||||
|
"puma",
|
||||||
|
"raven",
|
||||||
|
"robin",
|
||||||
|
"salmon",
|
||||||
|
"seal",
|
||||||
|
"shark",
|
||||||
|
"stork",
|
||||||
|
"swift",
|
||||||
|
"wolf",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def generate_agent_name() -> str:
|
||||||
|
"""Return a random ``adjective-colour-animal`` name."""
|
||||||
|
adj = random.choice(ADJECTIVES)
|
||||||
|
col = random.choice(COLOURS)
|
||||||
|
ani = random.choice(ANIMALS)
|
||||||
|
return f"{adj}-{col}-{ani}"
|
||||||
Loading…
Reference in New Issue
Block a user