def stop_container(self, container_info: ContainerInfo) -> None:

        for container in self.client.containers.list():
            if container.name == get_name_from_alias(container_info.name):
                container.kill()
                delete_alias(container_info.name)
                return
        raise ContainerNotFound(additional_message="Job Not Killed ",
                                container_name=container_info.name)
Exemplo n.º 2
0
 def tensorboard_refresh(self, container_info: ContainerInfo) -> None:
     if get_name_from_alias(container_info.name) in map(
             lambda container: container.name,
             self.client.containers.list()):
         self.training_api_tensorboard_service.refresh_training_api_tensorboard(
             container_info)
     else:
         self.tensorboard_service.tensorboard_stop(container_info)
         self.tensorboard_service.tensorboard_start(container_info)
    def get_container_logs(self, container_info: ContainerInfo) -> List[str]:
        logs: str = ""
        container_alias: str = get_name_from_alias(alias=container_info.name)

        try:
            for container in self.client.containers.list():
                if container.name == container_alias:
                    logs = container.logs()

            log_list: List[str] = logs.decode('utf-8').splitlines()
            return log_list
        except Exception:
            raise ContainerNotFound(container_name=container_info.name)
 def get_tensorboard_port(self,
                          container_info: ContainerInfo) -> TensorboardPort:
     tensorboard_port: int = None
     api_port: int = None
     try:
         for container in self.client.containers.list():
             if (container.name == get_name_from_alias(
                     container_info.name)):
                 tensorboard_port = int(
                     container.ports['6006/tcp'][0]['HostPort'])
                 api_port = int(container.ports['5252/tcp'][0]['HostPort'])
         return TensorboardPort(tensorboard_port=tensorboard_port,
                                api_port=api_port)
     except Exception:
         raise ContainerNotFound(container_name=container_info.name)
    def refresh_training_api_tensorboard(
            self, container_info: ContainerInfo) -> None:
        api_port: int = None
        try:
            for container in self.client.containers.list():
                if container.name == get_name_from_alias(container_info.name):
                    api_port = int(container.ports['5252/tcp'][0]['HostPort'])

            refresh_url = self.url.base_url + str(
                api_port) + self.url.training_ip_tensorboard_refresh
            response = requests.get(refresh_url)
        except requests.exceptions.RequestException as e:
            print(e)
            raise ApiRequestException(additional_message=e.__str__(),
                                      container_name=container_info.name)
        except Exception as e:
            raise ContainerNotFound(additional_message=e.__str__(),
                                    container_name=container_info.name)