-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
138 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
export function pricePerGPUHourToTotalPrice(pricePerGPUHourInCenticents: number, durationSeconds: number, nodes: number, gpusPerNode: number) { | ||
return Math.ceil(pricePerGPUHourInCenticents * durationSeconds / 3600 * nodes * gpusPerNode); | ||
export function pricePerGPUHourToTotalPrice( | ||
pricePerGPUHourInCenticents: number, | ||
durationSeconds: number, | ||
nodes: number, | ||
gpusPerNode: number, | ||
) { | ||
return Math.ceil( | ||
((pricePerGPUHourInCenticents * durationSeconds) / 3600) * | ||
nodes * | ||
gpusPerNode, | ||
); | ||
} | ||
|
||
export function totalPriceToPricePerGPUHour(totalPriceInCenticents: number, durationSeconds: number, nodes: number, gpusPerNode: number) { | ||
return totalPriceInCenticents / nodes / gpusPerNode / (durationSeconds / 3600); | ||
} | ||
export function totalPriceToPricePerGPUHour( | ||
totalPriceInCenticents: number, | ||
durationSeconds: number, | ||
nodes: number, | ||
gpusPerNode: number, | ||
) { | ||
return ( | ||
totalPriceInCenticents / nodes / gpusPerNode / (durationSeconds / 3600) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
import ora from "ora"; | ||
import chalk from "chalk"; | ||
import { getOrder } from "./fetchers"; | ||
import ora from "ora"; | ||
import { logAndQuit } from "./errors"; | ||
import { getOrder } from "./fetchers"; | ||
|
||
export async function waitForOrderToNotBePending(orderId: string) { | ||
const spinner = ora(`Order ${orderId} - pending (this can take a moment)`).start(); | ||
const maxTries = 25; | ||
for (let i = 0; i < maxTries; i++) { | ||
const order = await getOrder(orderId); | ||
const spinner = ora( | ||
`Order ${orderId} - pending (this can take a moment)`, | ||
).start(); | ||
const maxTries = 25; | ||
for (let i = 0; i < maxTries; i++) { | ||
const order = await getOrder(orderId); | ||
|
||
if (order && order?.status !== "pending") { | ||
spinner.text = `Order ${orderId} - ${order?.status}`; | ||
spinner.succeed(); | ||
console.log(chalk.green("Order placed successfully")); | ||
return order; | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, 500)); | ||
if (order && order?.status !== "pending") { | ||
spinner.text = `Order ${orderId} - ${order?.status}`; | ||
spinner.succeed(); | ||
console.log(chalk.green("Order placed successfully")); | ||
return order; | ||
} | ||
await new Promise((resolve) => setTimeout(resolve, 500)); | ||
} | ||
|
||
spinner.fail(); | ||
logAndQuit(`Order ${orderId} - possibly failed`); | ||
spinner.fail(); | ||
logAndQuit(`Order ${orderId} - possibly failed`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const GPUS_PER_NODE = 8; | ||
export const GPUS_PER_NODE = 8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters