Skip to content

Commit c26ed2d

Browse files
[Fix] Improve experiment termination system (#43)
* fix experiment wrong check * fix container kill * remove docker id from node config, remove unusued code * remove stop button when scenario is finished --------- Co-authored-by: Alejandro.A.S <jandrosambasil@gmail.com>
1 parent 0bf706a commit c26ed2d

File tree

6 files changed

+93
-146
lines changed

6 files changed

+93
-146
lines changed

nebula/core/engine.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import logging
33
import os
4+
import socket
45
import time
56

67
import docker
@@ -86,7 +87,6 @@ def __init__(
8687
self.addr = config.participant["network_args"]["addr"]
8788
self.role = config.participant["device_args"]["role"]
8889
self.name = config.participant["device_args"]["name"]
89-
self.docker_id = config.participant["device_args"]["docker_id"]
9090
self.client = docker.from_env()
9191

9292
print_banner()
@@ -601,22 +601,20 @@ async def _learning_cycle(self):
601601
if self.config.participant["scenario_args"]["controller"] != "nebula-test":
602602
result = await self.reporter.report_scenario_finished()
603603
if result:
604-
pass
604+
logging.info("📝 Scenario finished reported succesfully")
605605
else:
606-
logging.error("Error reporting scenario finished")
607-
608-
logging.info("Checking if all my connections reached the total rounds...")
609-
while not self.cm.check_finished_experiment():
610-
await asyncio.sleep(1)
606+
logging.error("📝 Error reporting scenario finished")
611607

612608
await asyncio.sleep(5)
613609

614610
# Kill itself
615611
if self.config.participant["scenario_args"]["deployment"] == "docker":
616612
try:
617-
self.client.containers.get(self.docker_id).stop()
613+
docker_id = socket.gethostname()
614+
logging.info(f"📦 Killing docker container with ID {docker_id}")
615+
self.client.containers.get(docker_id).kill()
618616
except Exception as e:
619-
print(f"Error stopping Docker container with ID {self.docker_id}: {e}")
617+
logging.exception(f"📦 Error stopping Docker container with ID {docker_id}: {e}")
620618

621619
async def _extended_learning_cycle(self):
622620
"""

0 commit comments

Comments
 (0)