Skip to content

Commit 155fd08

Browse files
committed
fix: find free frontend port, stop containers with the username
refactor: app -> assign_availale_gpu (comments added)
1 parent 6fee315 commit 155fd08

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

nebula/controller.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def __init__(self, args):
366366
self.controller_port = SocketUtils.find_free_port()
367367

368368
if not SocketUtils.is_port_open(self.frontend_port):
369-
self.frontend_port = SocketUtils.find_free_port()
369+
self.frontend_port = SocketUtils.find_free_port(self.controller_port + 1)
370370

371371
if not SocketUtils.is_port_open(self.statistics_port):
372372
self.statistics_port = SocketUtils.find_free_port(self.frontend_port + 1)
@@ -716,8 +716,7 @@ def stop_waf():
716716
@staticmethod
717717
def stop():
718718
logging.info("Closing NEBULA (exiting from components)... Please wait")
719-
DockerUtils.remove_containers_by_prefix(f"{os.environ['USER']}_nebula")
720-
DockerUtils.remove_containers_by_prefix(f"nebula_")
719+
DockerUtils.remove_containers_by_prefix(f"{os.environ['USER']}_")
721720
ScenarioManagement.stop_blockchain()
722721
ScenarioManagement.stop_participants()
723722
Controller.stop_waf()

nebula/frontend/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,13 +1240,15 @@ async def assign_available_gpu(scenario_data, role):
12401240
# Obtain currently used gpus
12411241
if running_scenarios:
12421242
running_gpus = []
1243+
# Obtain associated gpus of the running scenarios
12431244
for scenario in running_scenarios:
12441245
scenario_gpus = json.loads(scenario["gpu_id"])
1246+
# Obtain the list of gpus in use without duplicates
12451247
for gpu in scenario_gpus:
12461248
if gpu not in running_gpus:
12471249
running_gpus.append(gpu)
12481250

1249-
# Obtain gpus that are not in use
1251+
# Add available system gpus if they are not in use
12501252
for gpu in available_system_gpus:
12511253
if gpu not in running_gpus:
12521254
available_gpus.append(gpu)

0 commit comments

Comments
 (0)