Skip to content

Commit cdbd28b

Browse files
fix minor details
1 parent 7cfd6b8 commit cdbd28b

5 files changed

Lines changed: 14 additions & 35 deletions

File tree

nebula/controller/federation/controllers/docker_federation_controller.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,9 @@ async def update_nodes(self, scenario_name: str, request: Request):
222222
if index == idx:
223223
if index in additionals:
224224
self.logger.info(f"Deploying additional participant: {index}")
225-
deployed_successfully = self._start_node(node, nebula_federation.network_name, nebula_federation.base_network_name, nebula_federation.base, nebula_federation.last_index_deployed, nebula_federation)
225+
deployed_successfully = self._start_node(nebula_federation.scenario_name, node, nebula_federation.network_name, nebula_federation.base_network_name, nebula_federation.base, nebula_federation.last_index_deployed, nebula_federation)
226226
if deployed_successfully:
227227
self.logger.info(f"Deployment successfully for additional participant: {index}")
228-
nebula_federation.participants_alive += 1
229228
nebula_federation.last_index_deployed += 1
230229
#additionals.remove(index)
231230
adds_deployed.add(index)
@@ -522,12 +521,12 @@ def _start_initial_nodes(self, sb: ScenarioBuilder, federation: NebulaFederation
522521
# deploy initial nodes
523522
self.logger.info(f"Deployment starting for participant {idx}")
524523
federation.round_per_participant[idx] = 0
525-
deployed_successfully = self._start_node(sb, node, federation.network_name, federation.base_network_name, federation.base, federation.last_index_deployed, federation)
524+
deployed_successfully = self._start_node(sb.get_scenario_name(), node, federation.network_name, federation.base_network_name, federation.base, federation.last_index_deployed, federation)
526525
if deployed_successfully:
527526
federation.last_index_deployed += 1
528527
federation.participants_alive += 1
529528

530-
def _start_node(self, sb: ScenarioBuilder, node, network_name, base_network_name, base, i, federation: NebulaFederationDocker):
529+
def _start_node(self, scenario_name, node, network_name, base_network_name, base, i, federation: NebulaFederationDocker):
531530
success = True
532531
client = docker.from_env()
533532

@@ -536,7 +535,7 @@ def _start_node(self, sb: ScenarioBuilder, node, network_name, base_network_name
536535
container_names = [] # Track names for metadata
537536

538537
image = "nebula-core"
539-
name = self._get_participant_container_name(sb.get_scenario_name(), node["device_args"]["idx"])
538+
name = self._get_participant_container_name(scenario_name, node["device_args"]["idx"])
540539
if node["device_args"]["accelerator"] == "gpu":
541540
environment = {
542541
"NVIDIA_DISABLE_REQUIRE": True,
@@ -562,7 +561,7 @@ def _start_node(self, sb: ScenarioBuilder, node, network_name, base_network_name
562561
command = [
563562
"/bin/bash",
564563
"-c",
565-
f"{start_command} && ifconfig && echo '{base}.1 host.docker.internal' >> /etc/hosts && python /nebula/nebula/core/node.py /nebula/app/config/{sb.get_scenario_name()}/participant_{node['device_args']['idx']}.json",
564+
f"{start_command} && ifconfig && echo '{base}.1 host.docker.internal' >> /etc/hosts && python /nebula/nebula/core/node.py /nebula/app/config/{scenario_name}/participant_{node['device_args']['idx']}.json",
566565
]
567566
networking_config = client.api.create_networking_config({
568567
network_name: client.api.create_endpoint_config(
@@ -571,9 +570,9 @@ def _start_node(self, sb: ScenarioBuilder, node, network_name, base_network_name
571570
base_network_name: client.api.create_endpoint_config(),
572571
})
573572
node["tracking_args"]["log_dir"] = "/nebula/app/logs"
574-
node["tracking_args"]["config_dir"] = f"/nebula/app/config/{sb.get_scenario_name()}"
573+
node["tracking_args"]["config_dir"] = f"/nebula/app/config/{scenario_name}"
575574
node["scenario_args"]["controller"] = self.url
576-
node["scenario_args"]["deployment"] = sb.get_deployment()
575+
node["scenario_args"]["deployment"] = "docker"
577576
node["security_args"]["certfile"] = f"/nebula/app/certs/participant_{node['device_args']['idx']}_cert.pem"
578577
node["security_args"]["keyfile"] = f"/nebula/app/certs/participant_{node['device_args']['idx']}_key.pem"
579578
node["security_args"]["cafile"] = "/nebula/app/certs/ca_cert.pem"

nebula/controller/federation/controllers/processes_federation_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ async def stop_scenario(self, federation_id: str = ""):
134134
nebula_base_dir = os.path.abspath(os.path.join(current_dir, "..", ".."))
135135
nebula_config_dir = os.path.join(nebula_base_dir, "app", "config")
136136
self.logger.info(f"NEBULA_CONFIG_DIR not found. Using default path: {nebula_config_dir}")
137-
if id:
137+
if federation_id:
138138
if os.environ.get("NEBULA_HOST_PLATFORM") == "windows":
139139
scenario_commands_file = os.path.join(
140140
nebula_config_dir, federation_name, "current_scenario_commands.ps1"

nebula/controller/federation/federation_api.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from nebula.utils import LoggerUtils
1111
from nebula.controller.federation.federation_controller import FederationController
1212
from nebula.controller.federation.factory_federation_controller import federation_controller_factory
13-
from nebula.controller.federation.utils_requests import InitFederationRequest, RunScenarioRequest, StopScenarioRequest
13+
from nebula.controller.federation.utils_requests import RunScenarioRequest, StopScenarioRequest
1414

1515
#TODO Route the request to the right controller
1616

@@ -54,25 +54,6 @@ async def read_root():
5454
logger.info("Test curl succesfull")
5555
return {"message": "Welcome to the NEBULA Federation Controller API"}
5656

57-
# @app.post("/init")
58-
# async def init_federation_experiment(ifr: InitFederationRequest):
59-
# global fed_controller
60-
61-
# experiment_type = ifr.experiment_type
62-
# logger = logging.getLogger("Federation-Controller")
63-
# logger.info(f"Experiment type received: {experiment_type}")
64-
65-
# #TODO Modify when deploying controllers on differents systems
66-
# hub_port = os.environ.get("NEBULA_CONTROLLER_PORT")
67-
# controller_host = os.environ.get("NEBULA_CONTROLLER_HOST")
68-
69-
# hub_url = f"http://{controller_host}:{hub_port}"
70-
# logger.info(f"Docker Hub URL => {hub_url}")
71-
# fed_controller = federation_controller_factory(str(experiment_type), hub_url, logger)
72-
# logger.info("Federation controller created.")
73-
74-
# return {"message": f"{experiment_type} controller initialized"}
75-
7657
@app.post("/scenarios/run")
7758
async def run_scenario(run_scenario_request: RunScenarioRequest):
7859
global fed_controllers

nebula/controller/federation/utils_requests.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from pydantic import BaseModel
22
from typing import Dict, Any
33

4-
class InitFederationRequest(BaseModel):
5-
experiment_type: str
6-
74
class RunScenarioRequest(BaseModel):
85
scenario_data: Dict[str, Any]
96
user: str

nebula/controller/web_app_controller.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
)
2626
from nebula.controller.http_helpers import remote_get, remote_post_form
2727
from nebula.utils import DockerUtils, APIUtils
28-
from nebula.controller.federation.utils_requests import RunScenarioRequest, InitFederationRequest, StopScenarioRequest, factory_requests_path
28+
from nebula.controller.federation.utils_requests import RunScenarioRequest, StopScenarioRequest, factory_requests_path
2929

3030

3131
# Setup controller logger
@@ -107,6 +107,7 @@ def configure_logger(controller_log):
107107
handler.setFormatter(logging.Formatter("[%(asctime)s] [%(name)s] [%(levelname)s] %(message)s"))
108108
logger.addHandler(handler)
109109

110+
id_counter = 1
110111

111112
@asynccontextmanager
112113
async def lifespan(app: FastAPI):
@@ -317,15 +318,16 @@ async def run_scenario(
317318
"""
318319

319320
import subprocess
320-
321+
global id_counter
321322
from nebula.controller.scenarios import ScenarioManagement
322323
try:
323324
fed_controller_port = os.environ.get("NEBULA_FEDERATION_CONTROLLER_PORT")
324325
fed_controller_host = os.environ.get("NEBULA_CONTROLLER_HOST")
325326
url_init_fed_controller = f"http://{fed_controller_host}:{fed_controller_port}" + factory_requests_path("init")
326327
url_run_scenario = f"http://{fed_controller_host}:{fed_controller_port}" + factory_requests_path("run")
327328
#init_fed_req = InitFederationRequest(experiment_type="docker")
328-
run_scenario_req = RunScenarioRequest(scenario_data=scenario_data, federation_id="id_nebula", user=user) #TODO ID per experiment
329+
run_scenario_req = RunScenarioRequest(scenario_data=scenario_data, federation_id=f"id_nebula_{id_counter}", user=user) #TODO ID per experiment
330+
id_counter += 1
329331
#await APIUtils.post(url_init_fed_controller, init_fed_req.model_dump())
330332
await APIUtils.post(url_run_scenario, run_scenario_req.model_dump())
331333
except Exception as e:

0 commit comments

Comments
 (0)