Skip to content

Commit

Permalink
snake_case all the props
Browse files Browse the repository at this point in the history
  • Loading branch information
JEMeyer committed Jul 27, 2024
1 parent 5a1e432 commit 3fc9b57
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 44 deletions.
6 changes: 3 additions & 3 deletions scripts/http/assignments.rest
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Content-Type: application/json

{
"name": "New Assignment",
"modelName": "Model1",
"model_name": "Model1",
"maestroPort": 8080,
"gpuIds": [1, 2]
"gpu_ids": [1, 2]
}

### Delete an assignment
Expand All @@ -29,5 +29,5 @@ Content-Type: application/json
"name": "Updated Assignment",
"modelName": "Model2",
"maestroPort": 8081,
"gpuIds": [2, 3]
"gpu_ids": [2, 3]
}
11 changes: 7 additions & 4 deletions scripts/http/computers.rest
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ Content-Type: application/json
DELETE {{baseMaestroUrl}}:{{maestroPort}}/api/computers/<ID>

### Update an computer
PUT {{baseMaestroUrl}}:{{maestroPort}}/api/computers/<ID>
PUT {{baseMaestroUrl}}:{{maestroPort}}/api/computers/1
Content-Type: application/json

{
"name": "Updated Computer",
"ipAddr": "0.0.0.1"
}
"id": 1,
"name": "3090 Cluster - 1",
"ip_addr": "192.168.1.32",
"edge_server_port": 4000,
"display_order": 1
}
8 changes: 4 additions & 4 deletions scripts/http/gpus.rest
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Content-Type: application/json

{
"name": "New GPU",
"vramSize": 4,
"computerId": 123,
"vram_size": 4,
"computer_id": 123,
"weight": 1
}

Expand All @@ -24,7 +24,7 @@ Content-Type: application/json

{
"name": "Updated GPU",
"vramSize": 4.3,
"computerId": 123,
"vram_size": 4.3,
"computer_id": 123,
"weight": 15
}
22 changes: 11 additions & 11 deletions src/controllers/assignments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export const getAllAssignments = async (_req: Request, res: Response) => {
const assignmentGpusForAssignment = assignmentGpus.filter(
({ assignment_id }) => assignment_id === assignment.id
);
const gpuIds = assignmentGpusForAssignment.map(({ gpu_id }) => gpu_id);
const gpu_ids = assignmentGpusForAssignment.map(({ gpu_id }) => gpu_id);
return {
...assignment,
gpuIds: gpuIds,
gpu_ids: gpu_ids,
};
});

Expand All @@ -33,11 +33,11 @@ export const getAssignmentById = async (req: Request, res: Response) => {
};

export const createAssignment = async (req: Request, res: Response) => {
const { name, modelName, port, gpuIds, display_order } = req.body as {
const { name, modelName, port, gpu_ids, display_order } = req.body as {
name: string;
modelName: string;
port: number;
gpuIds: number[];
gpu_ids: number[];
display_order: number;
};
const assignmentId = await AssignmentService.createAssignment(
Expand All @@ -47,7 +47,7 @@ export const createAssignment = async (req: Request, res: Response) => {
display_order
);
await Promise.all(
gpuIds.map((gpuId) =>
gpu_ids.map((gpuId) =>
AssignmentGpuService.createDBAssignmentGPU(assignmentId, gpuId)
)
);
Expand All @@ -64,11 +64,11 @@ export const deleteAssignment = async (req: Request, res: Response) => {

export const updateAssignment = async (req: Request, res: Response) => {
const { id } = req.params;
const { name, modelName, port, gpuIds, display_order } = req.body as {
const { name, modelName, port, gpu_ids, display_order } = req.body as {
name: string;
modelName: string;
port: number;
gpuIds: number[];
gpu_ids: number[];
display_order: number;
};
const idAsNumber = Number(id);
Expand All @@ -87,7 +87,7 @@ export const updateAssignment = async (req: Request, res: Response) => {

// Now look to see which assignment gpus we need to delete/create
await Promise.all(
gpuIds
gpu_ids
.map((gpuId) => {
if (!currentAssignmentGpus.find((ag) => ag.gpu_id === gpuId)) {
return AssignmentGpuService.createDBAssignmentGPU(idAsNumber, gpuId);
Expand All @@ -96,7 +96,7 @@ export const updateAssignment = async (req: Request, res: Response) => {
.concat(
currentAssignmentGpus
.map((ag) => {
if (!gpuIds.find((gpuId) => ag.gpu_id === gpuId)) {
if (!gpu_ids.find((gpuId) => ag.gpu_id === gpuId)) {
return AssignmentGpuService.deleteAssignmentGpu(
idAsNumber,
ag.gpu_id
Expand Down Expand Up @@ -128,7 +128,7 @@ export const deployAssignments = async (req: Request, res: Response) => {
const makeAndLoadContainerPromises: Promise<void>[] = [];
assignments.forEach((assignment) => {
const ipAddr = computers.find(({ id }) => {
return id === gpus[0].computerId;
return id === gpus[0].computer_id;
})?.ip_addr;
const isDiffusionModel = diffusors.some(
({ name }) => name === assignment.model_name
Expand All @@ -139,7 +139,7 @@ export const deployAssignments = async (req: Request, res: Response) => {
await EdgeServerService.makeContainer(ipAddr, {
containerName: assignment.name,
port: String(assignment.port),
gpuIds: assignmentGpus
gpu_ids: assignmentGpus
.filter(({ assignment_id }) => assignment.id === assignment_id)
.map(({ gpu_id }) => gpu_id),
diffusionModel: isDiffusionModel
Expand Down
8 changes: 4 additions & 4 deletions src/controllers/computer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const getComputerById = async (req: Request, res: Response) => {
};

export const createComputer = async (req: Request, res: Response) => {
const { name, ipAddr, display_order } = req.body;
const id = await ComputerService.createComputer(name, ipAddr, display_order);
const { name, ip_addr, display_order } = req.body;
const id = await ComputerService.createComputer(name, ip_addr, display_order);
res.json({ id });
};

Expand All @@ -26,11 +26,11 @@ export const deleteComputer = async (req: Request, res: Response) => {
};

export const updateComputer = async (req: Request, res: Response) => {
const { id, name, ipAddr, display_order } = req.body;
const { id, name, ip_addr, display_order } = req.body;
const affectedRows = await ComputerService.updateComputer(
id,
name,
ipAddr,
ip_addr,
display_order
);
res.json({ affectedRows });
Expand Down
12 changes: 6 additions & 6 deletions src/controllers/gpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const getGpuById = async (req: Request, res: Response) => {
};

export const createGPU = async (req: Request, res: Response) => {
const { name, vramSize, computerId, weight, display_order } = req.body;
const { name, vram_size, computer_id, weight, display_order } = req.body;
const id = await GpuService.createGPU(
name,
vramSize,
computerId,
vram_size,
computer_id,
display_order,
weight
);
Expand All @@ -34,12 +34,12 @@ export const deleteGPU = async (req: Request, res: Response) => {

export const updateGPU = async (req: Request, res: Response) => {
const { id } = req.params;
const { name, vramSize, computerId, weight, display_order } = req.body;
const { name, vram_size, computer_id, weight, display_order } = req.body;
await GpuService.updateGPU(
Number(id),
name,
vramSize,
computerId,
vram_size,
computer_id,
display_order,
weight
);
Expand Down
2 changes: 1 addition & 1 deletion src/services/edge.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interface MakeContainerProps {
containerName: string;
port: string;
gpuIds: number[];
gpu_ids: number[];
diffusionModel?: string; // 'sdxl-turbo' or 'sd-turbo'
}

Expand Down
20 changes: 10 additions & 10 deletions src/services/tables/gpus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ import { pool } from '../db';
interface GPU {
id: number;
name: string;
vramSize: number;
computerId: number;
vram_size: number;
computer_id: number;
weight?: number;
}

// Create a new GPU
export const createGPU = async (
name: string,
vramSize: number,
computerId: number,
vram_size: number,
computer_id: number,
display_order: number,
weight?: number
): Promise<number> => {
const query =
'INSERT INTO gpus (name, vram_size, computer_id, weight, display_order) VALUES (?, ?, ?, ?)';
const result = await pool.query(query, [
name,
vramSize,
computerId,
vram_size,
computer_id,
weight || null,
display_order,
]);
Expand Down Expand Up @@ -50,17 +50,17 @@ export const getGPUById = async (id: number): Promise<GPU | null> => {
export const updateGPU = async (
id: number,
name: string,
vramSize: number,
computerId: number,
vram_size: number,
computer_id: number,
display_order: number,
weight?: number
): Promise<number> => {
const query =
'UPDATE gpus SET name = ?, vram_size = ?, computer_id = ?, weight = ?, display_order = ? WHERE id = ?';
const result = await pool.query(query, [
name,
vramSize,
computerId,
vram_size,
computer_id,
weight || null,
display_order,
id,
Expand Down
2 changes: 1 addition & 1 deletion src/services/tables/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface Assignment {
id: number;
name: string;
model_name: string;
gpuIds: number[];
gpu_ids: number[];
port: number;
display_order: number;
}

0 comments on commit 3fc9b57

Please sign in to comment.