Skip to content

Commit

Permalink
refactor: GPU option removed from frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
FerTV committed Dec 20, 2024
1 parent 4b2a772 commit 5fdb4ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 51 deletions.
15 changes: 9 additions & 6 deletions nebula/frontend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,12 +1279,11 @@ async def node_stopped(scenario_name: str, request: Request):
async def assign_available_gpu(scenario_data, role):
available_gpus = []

if scenario_data["accelerator"] == "cpu":
scenario_data["gpu_id"] = []
else:
response = await get_available_gpus()
# Obtain available system_gpus
available_system_gpus = response.get("available_gpus")
response = await get_available_gpus()
# Obtain available system_gpus
available_system_gpus = response.get("available_gpus", None) if response is not None else None

if available_system_gpus:
running_scenarios = get_running_scenario(get_all=True)
# Obtain currently used gpus
if running_scenarios:
Expand All @@ -1307,12 +1306,16 @@ async def assign_available_gpu(scenario_data, role):
# Assign gpus based in user role
if len(available_gpus) > 0:
if role == "user":
scenario_data["accelerator"] = "gpu"
scenario_data["gpu_id"] = [available_gpus.pop()]
elif role == "admin":
scenario_data["accelerator"] = "gpu"
scenario_data["gpu_id"] = available_gpus
else:
scenario_data["accelerator"] = "cpu"
scenario_data["gpu_id"] = []
else:
scenario_data["accelerator"] = "cpu"
scenario_data["gpu_id"] = []

return scenario_data
Expand Down
54 changes: 9 additions & 45 deletions nebula/frontend/templates/deployment.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,27 +452,6 @@ <h5 class="step-title">Reporting</h5>
<h5 class="step-title">Individual participants</h5>
<div id="participant-items" class="row"></div>
</div>
<!-- Advanced Deployment -->
<div class="form-group row container-shadow tiny grey">
<h5 class="step-number">Advanced Deployment <i class="fa fa-cloud-upload"></i>
<input type="checkbox" id="accelerator-lock" onchange="lock('resourceUsage', checked)" style="display: none;">
<label for="accelerator-lock" class="icon-container" style="float: right;">
<i class="fa fa-lock"></i>
</label>
</h5>
<h5 class="step-title">Accelerator definition</h5>
<div class="form-check">
<select class="form-control" id="resourceUsage" name="resources"
style="display: inline; width: 20%">
{% if gpu_available %}
<option value="gpu" selected>GPU</option>
<option value="cpu">CPU</option>
{% else %}
<option value="cpu" selected>CPU</option>
{% endif %}
</select>
</div>
</div>
<!-- Advanced Topology -->
<div class="form-group row container-shadow tiny grey">
<h5 class="step-number">Advanced Topology <i class="fa fa-sitemap"></i>
Expand Down Expand Up @@ -1048,7 +1027,7 @@ <h5 class="step-title">Schema of deployment</h5>
data["logginglevel"] = document.getElementById("loggingLevel").value === "true"
data["report_status_data_queue"] = document.getElementById("reportingSwitch").checked
// Step 9
data["accelerator"] = document.getElementById("resourceUsage").value
data["accelerator"] = ""
// Step 10
data["network_subnet"] = "192.168.50.0/24"
data["network_gateway"] = "192.168.50.1"
Expand Down Expand Up @@ -1149,11 +1128,9 @@ <h5 class="step-title">Schema of deployment</h5>
} else {
document.getElementById("reportingSwitch").disabled = false;
}
// Step 9
document.getElementById("resourceUsage").value = data["accelerator"];
// Step 11
// Step 10
document.getElementById("epochs").value = data["epochs"];
// Step 12
// Step 11
var selectElement = document.getElementById("poisoning-attack-select");
selectElement.value = data["attacks"];
selectElement.dispatchEvent(new Event('change'));
Expand All @@ -1171,15 +1148,15 @@ <h5 class="step-title">Schema of deployment</h5>
}
document.getElementById("poisoned-sample-percent").value = data["poisoned_sample_percent"];
document.getElementById("poisoned-noise-percent").value = data["poisoned_noise_percent"];
// Step 13
// Step 12
document.getElementById("with-reputation-btn").checked = data["with_reputation"];
if (data["with_reputation"]) {
document.getElementById("mtd-strategy").style.display = "block";
}
document.getElementById("dynamic-topology-btn").checked = data["is_dynamic_topology"];
document.getElementById("dynamic-aggregation-btn").checked = data["is_dynamic_aggregation"];
document.getElementById("targetAggregationSelect").value = data["target_aggregation"];
// Step 14
// Step 13
document.getElementById("random-geo-btn").checked = data["random_geo"];
document.getElementById("latitude").value = data["latitude"];
document.getElementById("longitude").value = data["longitude"];
Expand Down Expand Up @@ -1718,19 +1695,15 @@ <h5 class="step-title">Schema of deployment</h5>
document.getElementById("loggingLevel").value = false;
}
// Step 9
if(!document.getElementById("accelerator-lock").checked){
document.getElementById("resourceUsage").value = "cpu";
}
// Step 10
if(!document.getElementById("distance-lock").checked){
document.getElementById("distanceInput").value = document.getElementById("distanceInput").defaultValue;
document.getElementById("distanceValue").value = document.getElementById("distanceValue").defaultValue;
}
// Step 11
// Step 10
if(!document.getElementById("epochs-lock").checked){
document.getElementById("epochs").value = document.getElementById("epochs").defaultValue;
}
// Step 12
// Step 11
if(!document.getElementById("robustness-lock").checked){
var selectElement = document.getElementById("poisoning-attack-select");
selectElement.value = "No Attack";
Expand All @@ -1739,7 +1712,7 @@ <h5 class="step-title">Schema of deployment</h5>
document.getElementById("poisoned-noise-percent").value = document.getElementById("poisoned-noise-percent").defaultValue;
document.getElementById("poisoned-node-percent").value = document.getElementById("poisoned-node-percent").defaultValue;
}
// Step 13
// Step 12
if(!document.getElementById("defense-lock").checked){
document.getElementById("without-reputation-btn").checked = true;
document.getElementById("dynamic-aggregation-btn").checked = false;
Expand All @@ -1748,7 +1721,7 @@ <h5 class="step-title">Schema of deployment</h5>
document.getElementById("without-reputation-btn").click();
document.getElementById("dynamic-topology-btn").checked = false;
}
// Step 14
// Step 13
if(!document.getElementById("mobility-lock").checked){
document.getElementById("random-geo-btn").checked = true;
document.getElementById("longitude").value = document.getElementById("longitude").defaultValue;
Expand Down Expand Up @@ -1931,15 +1904,6 @@ <h5 class="step-title">Schema of deployment</h5>

//Generate a scenario
function generateScenarios(){

//selected accelerator
if(document.getElementById("mod-cpu").checked){
document.getElementById("resourceUsage").value = "cpu";
}
else{
document.getElementById("resourceUsage").value = "gpu";
}

//One or more options selected in every case
var aggregation_methods = ['mod-fedavg', 'mod-krum', 'mod-trimmed', 'mod-median'];
if (!atLeastOneChecked(aggregation_methods)) {
Expand Down

0 comments on commit 5fdb4ba

Please sign in to comment.