Skip to content

Commit

Permalink
Fix lint, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffxy committed Mar 30, 2024
1 parent 17f5c5f commit 4864e90
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
14 changes: 9 additions & 5 deletions src/brad/ui/manager_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ def get_workload_clients(runner_port: Optional[int] = None) -> ClientState:
if r.status_code != 200:
raise HTTPException(r.status_code, r.reason)
return ClientState(**r.json())
except requests.ConnectionError:
raise HTTPException(400, f"Unable to connect to port {runner_port}")
except requests.ConnectionError as ex:
raise HTTPException(400, f"Unable to connect to port {runner_port}") from ex


@app.post("/api/1/clients")
Expand All @@ -220,12 +220,16 @@ def set_clients(clients: SetClientState) -> ClientState:
return ClientState(max_clients=12, curr_clients=clients.curr_clients)
else:
try:
r = requests.post(f"http://localhost:{clients.runner_port}/clients", timeout=2)
r = requests.post(
f"http://localhost:{clients.runner_port}/clients", timeout=2
)
if r.status_code != 200:
raise HTTPException(r.status_code, r.reason)
return ClientState(**r.json())
except requests.ConnectionError:
raise HTTPException(400, f"Unable to connect to port {clients.runner_port}")
except requests.ConnectionError as ex:
raise HTTPException(
400, f"Unable to connect to port {clients.runner_port}"
) from ex


def _analytics_table_mapper_temp(table_name: str, blueprint: Blueprint) -> List[str]:
Expand Down
11 changes: 8 additions & 3 deletions ui/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,23 @@ async function fetchSystemState(filterTablesForDemo) {
}

async function fetchWorkloadClients(port) {
const args = port != null ? {params: {runner_port: port}} : {};
const args = port != null ? { params: { runner_port: port } } : {};
const result = await axios.get(`${API_PREFIX}/clients`, args);
return result.data;
}

async function setWorkloadClients(port, numClients) {
const args = {curr_clients: numClients};
const args = { curr_clients: numClients };
if (port != null) {
args.runner_port = port;
}
const result = await axios.post(`${API_PREFIX}/clients`, args);
return result.data;
}

export { fetchMetrics, fetchSystemState, fetchWorkloadClients, setWorkloadClients };
export {
fetchMetrics,
fetchSystemState,
fetchWorkloadClients,
setWorkloadClients,
};
10 changes: 7 additions & 3 deletions ui/src/components/VirtualInfraView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function VirtualInfraView({
return;
}
const endpoint = workloadRunners[vdbeIndex];
const newWorkloadState = await setWorkloadClients(endpoint.port, numClients);
const newWorkloadState = await setWorkloadClients(
endpoint.port,
numClients,
);

// Skip the state update if there was no change.
const existingWorkloadState = workloadStates[vdbeIndex];
Expand All @@ -44,8 +47,9 @@ function VirtualInfraView({

useEffect(async () => {
const { workloadRunners } = endpoints;
const promises = workloadRunners
.map((endpoint) => fetchWorkloadClients(endpoint.port));
const promises = workloadRunners.map((endpoint) =>
fetchWorkloadClients(endpoint.port),
);
const results = await Promise.all(promises);
setWorkloadStates(results);
}, [endpoints]);
Expand Down

0 comments on commit 4864e90

Please sign in to comment.