MCPcopy Create free account
hub / github.com/MoonshotAI/checkpoint-engine / get_ip

Function get_ip

checkpoint_engine/device_utils.py:14–25  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12
13@lru_cache(maxsize=1)
14def get_ip() -> str:
15 try:
16 # try to get ip from network interface
17 with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
18 s.connect(("8.8.8.8", 80))
19 return s.getsockname()[0]
20 except Exception as e: # noqa: BLE001
21 # fallback to get ip from hostname
22 logger.warning(
23 f"fail to get ip from network interface, fallback to get ip from hostname: {e}"
24 )
25 return socket.gethostbyname(socket.gethostname())
26
27
28def npu_generate_uuid() -> str:

Callers 3

gather_metasMethod · 0.90
__init__Method · 0.90
npu_generate_uuidFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected