Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions nebula/core/engine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import logging
import os
import socket
import time

import docker
Expand Down Expand Up @@ -86,7 +87,6 @@ def __init__(
self.addr = config.participant["network_args"]["addr"]
self.role = config.participant["device_args"]["role"]
self.name = config.participant["device_args"]["name"]
self.docker_id = config.participant["device_args"]["docker_id"]
self.client = docker.from_env()

print_banner()
Expand Down Expand Up @@ -601,22 +601,20 @@ async def _learning_cycle(self):
if self.config.participant["scenario_args"]["controller"] != "nebula-test":
result = await self.reporter.report_scenario_finished()
if result:
pass
logging.info("📝 Scenario finished reported succesfully")
else:
logging.error("Error reporting scenario finished")

logging.info("Checking if all my connections reached the total rounds...")
while not self.cm.check_finished_experiment():
await asyncio.sleep(1)
logging.error("📝 Error reporting scenario finished")

await asyncio.sleep(5)

# Kill itself
if self.config.participant["scenario_args"]["deployment"] == "docker":
try:
self.client.containers.get(self.docker_id).stop()
docker_id = socket.gethostname()
logging.info(f"📦 Killing docker container with ID {docker_id}")
self.client.containers.get(docker_id).kill()
except Exception as e:
print(f"Error stopping Docker container with ID {self.docker_id}: {e}")
logging.exception(f"📦 Error stopping Docker container with ID {docker_id}: {e}")

async def _extended_learning_cycle(self):
"""
Expand Down
Loading
Loading