Skip to content

Commit 5fdb4ba

Browse files
committed
refactor: GPU option removed from frontend
1 parent 4b2a772 commit 5fdb4ba

File tree

2 files changed

+18
-51
lines changed

2 files changed

+18
-51
lines changed

nebula/frontend/app.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,12 +1279,11 @@ async def node_stopped(scenario_name: str, request: Request):
12791279
async def assign_available_gpu(scenario_data, role):
12801280
available_gpus = []
12811281

1282-
if scenario_data["accelerator"] == "cpu":
1283-
scenario_data["gpu_id"] = []
1284-
else:
1285-
response = await get_available_gpus()
1286-
# Obtain available system_gpus
1287-
available_system_gpus = response.get("available_gpus")
1282+
response = await get_available_gpus()
1283+
# Obtain available system_gpus
1284+
available_system_gpus = response.get("available_gpus", None) if response is not None else None
1285+
1286+
if available_system_gpus:
12881287
running_scenarios = get_running_scenario(get_all=True)
12891288
# Obtain currently used gpus
12901289
if running_scenarios:
@@ -1307,12 +1306,16 @@ async def assign_available_gpu(scenario_data, role):
13071306
# Assign gpus based in user role
13081307
if len(available_gpus) > 0:
13091308
if role == "user":
1309+
scenario_data["accelerator"] = "gpu"
13101310
scenario_data["gpu_id"] = [available_gpus.pop()]
13111311
elif role == "admin":
1312+
scenario_data["accelerator"] = "gpu"
13121313
scenario_data["gpu_id"] = available_gpus
13131314
else:
1315+
scenario_data["accelerator"] = "cpu"
13141316
scenario_data["gpu_id"] = []
13151317
else:
1318+
scenario_data["accelerator"] = "cpu"
13161319
scenario_data["gpu_id"] = []
13171320

13181321
return scenario_data

nebula/frontend/templates/deployment.html

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -452,27 +452,6 @@ <h5 class="step-title">Reporting</h5>
452452
<h5 class="step-title">Individual participants</h5>
453453
<div id="participant-items" class="row"></div>
454454
</div>
455-
<!-- Advanced Deployment -->
456-
<div class="form-group row container-shadow tiny grey">
457-
<h5 class="step-number">Advanced Deployment <i class="fa fa-cloud-upload"></i>
458-
<input type="checkbox" id="accelerator-lock" onchange="lock('resourceUsage', checked)" style="display: none;">
459-
<label for="accelerator-lock" class="icon-container" style="float: right;">
460-
<i class="fa fa-lock"></i>
461-
</label>
462-
</h5>
463-
<h5 class="step-title">Accelerator definition</h5>
464-
<div class="form-check">
465-
<select class="form-control" id="resourceUsage" name="resources"
466-
style="display: inline; width: 20%">
467-
{% if gpu_available %}
468-
<option value="gpu" selected>GPU</option>
469-
<option value="cpu">CPU</option>
470-
{% else %}
471-
<option value="cpu" selected>CPU</option>
472-
{% endif %}
473-
</select>
474-
</div>
475-
</div>
476455
<!-- Advanced Topology -->
477456
<div class="form-group row container-shadow tiny grey">
478457
<h5 class="step-number">Advanced Topology <i class="fa fa-sitemap"></i>
@@ -1048,7 +1027,7 @@ <h5 class="step-title">Schema of deployment</h5>
10481027
data["logginglevel"] = document.getElementById("loggingLevel").value === "true"
10491028
data["report_status_data_queue"] = document.getElementById("reportingSwitch").checked
10501029
// Step 9
1051-
data["accelerator"] = document.getElementById("resourceUsage").value
1030+
data["accelerator"] = ""
10521031
// Step 10
10531032
data["network_subnet"] = "192.168.50.0/24"
10541033
data["network_gateway"] = "192.168.50.1"
@@ -1149,11 +1128,9 @@ <h5 class="step-title">Schema of deployment</h5>
11491128
} else {
11501129
document.getElementById("reportingSwitch").disabled = false;
11511130
}
1152-
// Step 9
1153-
document.getElementById("resourceUsage").value = data["accelerator"];
1154-
// Step 11
1131+
// Step 10
11551132
document.getElementById("epochs").value = data["epochs"];
1156-
// Step 12
1133+
// Step 11
11571134
var selectElement = document.getElementById("poisoning-attack-select");
11581135
selectElement.value = data["attacks"];
11591136
selectElement.dispatchEvent(new Event('change'));
@@ -1171,15 +1148,15 @@ <h5 class="step-title">Schema of deployment</h5>
11711148
}
11721149
document.getElementById("poisoned-sample-percent").value = data["poisoned_sample_percent"];
11731150
document.getElementById("poisoned-noise-percent").value = data["poisoned_noise_percent"];
1174-
// Step 13
1151+
// Step 12
11751152
document.getElementById("with-reputation-btn").checked = data["with_reputation"];
11761153
if (data["with_reputation"]) {
11771154
document.getElementById("mtd-strategy").style.display = "block";
11781155
}
11791156
document.getElementById("dynamic-topology-btn").checked = data["is_dynamic_topology"];
11801157
document.getElementById("dynamic-aggregation-btn").checked = data["is_dynamic_aggregation"];
11811158
document.getElementById("targetAggregationSelect").value = data["target_aggregation"];
1182-
// Step 14
1159+
// Step 13
11831160
document.getElementById("random-geo-btn").checked = data["random_geo"];
11841161
document.getElementById("latitude").value = data["latitude"];
11851162
document.getElementById("longitude").value = data["longitude"];
@@ -1718,19 +1695,15 @@ <h5 class="step-title">Schema of deployment</h5>
17181695
document.getElementById("loggingLevel").value = false;
17191696
}
17201697
// Step 9
1721-
if(!document.getElementById("accelerator-lock").checked){
1722-
document.getElementById("resourceUsage").value = "cpu";
1723-
}
1724-
// Step 10
17251698
if(!document.getElementById("distance-lock").checked){
17261699
document.getElementById("distanceInput").value = document.getElementById("distanceInput").defaultValue;
17271700
document.getElementById("distanceValue").value = document.getElementById("distanceValue").defaultValue;
17281701
}
1729-
// Step 11
1702+
// Step 10
17301703
if(!document.getElementById("epochs-lock").checked){
17311704
document.getElementById("epochs").value = document.getElementById("epochs").defaultValue;
17321705
}
1733-
// Step 12
1706+
// Step 11
17341707
if(!document.getElementById("robustness-lock").checked){
17351708
var selectElement = document.getElementById("poisoning-attack-select");
17361709
selectElement.value = "No Attack";
@@ -1739,7 +1712,7 @@ <h5 class="step-title">Schema of deployment</h5>
17391712
document.getElementById("poisoned-noise-percent").value = document.getElementById("poisoned-noise-percent").defaultValue;
17401713
document.getElementById("poisoned-node-percent").value = document.getElementById("poisoned-node-percent").defaultValue;
17411714
}
1742-
// Step 13
1715+
// Step 12
17431716
if(!document.getElementById("defense-lock").checked){
17441717
document.getElementById("without-reputation-btn").checked = true;
17451718
document.getElementById("dynamic-aggregation-btn").checked = false;
@@ -1748,7 +1721,7 @@ <h5 class="step-title">Schema of deployment</h5>
17481721
document.getElementById("without-reputation-btn").click();
17491722
document.getElementById("dynamic-topology-btn").checked = false;
17501723
}
1751-
// Step 14
1724+
// Step 13
17521725
if(!document.getElementById("mobility-lock").checked){
17531726
document.getElementById("random-geo-btn").checked = true;
17541727
document.getElementById("longitude").value = document.getElementById("longitude").defaultValue;
@@ -1931,15 +1904,6 @@ <h5 class="step-title">Schema of deployment</h5>
19311904

19321905
//Generate a scenario
19331906
function generateScenarios(){
1934-
1935-
//selected accelerator
1936-
if(document.getElementById("mod-cpu").checked){
1937-
document.getElementById("resourceUsage").value = "cpu";
1938-
}
1939-
else{
1940-
document.getElementById("resourceUsage").value = "gpu";
1941-
}
1942-
19431907
//One or more options selected in every case
19441908
var aggregation_methods = ['mod-fedavg', 'mod-krum', 'mod-trimmed', 'mod-median'];
19451909
if (!atLeastOneChecked(aggregation_methods)) {

0 commit comments

Comments
 (0)