#! /usr/bin/env python
# _*_ coding: utf-8 _*_
"""
author:     Chen XuHui
date:       2024/10/8
file:       node.py
version:
doc:        节点信息字典格式.
"""
from typing import Optional, TypedDict


class ResourceInfo(TypedDict):
    """节点资源信息"""
    # node:127.0.0.1: float  # 比如, 1.0
    object_store_memory: float  # 专门用于存储Ray对象的内存, 比如, 37778053939.0
    memory: float  # Ray节点上的可用系统内存，它与操作系统共享, 比如, 78148792525.0
    GPU: Optional[float]  # 比如, 1.0
    CPU: float  # 比如, 32.0
    # accelerator_type:G: float  # 比如, 1.0
    # node:__internal_head__: float  # 比如, 1.0


class NodeInfo(TypedDict):
    NodeID: str  # 比如, 9952d754aa76f06ad0a320708bc94daa9317bc2c00d90f29a99fefb5
    Alive: bool  # 比如, True
    NodeManagerAddress: str  # 比如, 127.0.0.1
    NodeManagerHostname: str  # 比如, DESKTOP-395NK0D
    NodeManagerPort: int  # 比如, 54570
    ObjectManagerPort: int  # 比如, 54568
    ObjectStoreSocketName: str  # 比如, tcp://127.0.0.1:64785
    RayletSocketName: str  # 比如, tcp://127.0.0.1:62165
    MetricsExportPort: int  # 比如, 59930
    NodeName: str  # 比如, 127.0.0.1
    RuntimeEnvAgentPort: int  # 比如, 60005
    alive: bool  # 比如, True
    Resources: ResourceInfo
    Labels: dict  # 比如, {'ray.io/node_id': '9952d754aa76f06ad0a320708bc94daa9317bc2c00d90f29a99fefb5'}
