def _get_kubernetes_node_by_ip(self, node_ip: str) -> Optional[str]: """Return node name by internal or external IP""" kubernetes.config.load_incluster_config() api = kubernetes.client.CoreV1Api() pods = api.list_namespaced_pod(self._namespace) for pod in pods.items: if pod.status.host_ip == node_ip or pod.status.pod_ip == node_ip: return pod.metadata.name logger.error( "Could not find Kubernetes pod name for IP {}".format(node_ip)) return None
import os from multiprocessing import Process, Queue from numbers import Number from ray import logger from ray.tune import Trainable from ray.tune.function_runner import FunctionRunner from ray.tune.logger import Logger from ray.tune.utils import flatten_dict try: import wandb except ImportError: logger.error("pip install 'wandb' to use WandbLogger/WandbTrainableMixin.") wandb = None WANDB_ENV_VAR = "WANDB_API_KEY" _WANDB_QUEUE_END = (None, ) def wandb_mixin(func): """wandb_mixin Weights and biases (https://www.wandb.com/) is a tool for experiment tracking, model optimization, and dataset versioning. This Ray Tune Trainable mixin helps initializing the Wandb API for use with the ``Trainable`` class or with `@wandb_mixin` for the function API. For basic usage, just prepend your training function with the ``@wandb_mixin`` decorator:
def _missing_(cls, value): logger.error(f'Missing weapon type {value}') return cls.MISSING
def __post_init__(self): self.weapon = Weapons(self.gun_type).name if self.weapon == Weapons.MISSING.value: logger.error(self)