Buckets:
| ; | |
| var __importDefault = (this && this.__importDefault) || function (mod) { | |
| return (mod && mod.__esModule) ? mod : { "default": mod }; | |
| }; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.default = processQueue; | |
| const prisma_1 = __importDefault(require("../prisma")); | |
| const startJob_1 = __importDefault(require("./startJob")); | |
| async function processQueue() { | |
| const queues = await prisma_1.default.queue.findMany({ | |
| orderBy: { | |
| id: 'asc', | |
| }, | |
| }); | |
| for (const queue of queues) { | |
| if (!queue.is_running) { | |
| // stop any running jobs first | |
| const runningJobs = await prisma_1.default.job.findMany({ | |
| where: { | |
| status: 'running', | |
| gpu_ids: queue.gpu_ids, | |
| }, | |
| }); | |
| for (const job of runningJobs) { | |
| console.log(`Stopping job ${job.id} on GPU(s) ${job.gpu_ids}`); | |
| await prisma_1.default.job.update({ | |
| where: { id: job.id }, | |
| data: { | |
| return_to_queue: true, | |
| info: 'Stopping job...', | |
| }, | |
| }); | |
| } | |
| } | |
| if (queue.is_running) { | |
| // first see if one is already running, status of running or stopping | |
| const runningJob = await prisma_1.default.job.findFirst({ | |
| where: { | |
| status: { in: ['running', 'stopping'] }, | |
| gpu_ids: queue.gpu_ids, | |
| }, | |
| }); | |
| if (runningJob) { | |
| // already running, nothing to do | |
| continue; // skip to next queue | |
| } | |
| else { | |
| // find the next job in the queue | |
| const nextJob = await prisma_1.default.job.findFirst({ | |
| where: { | |
| status: 'queued', | |
| gpu_ids: queue.gpu_ids, | |
| }, | |
| orderBy: { | |
| queue_position: 'asc', | |
| }, | |
| }); | |
| if (nextJob) { | |
| console.log(`Starting job ${nextJob.id} on GPU(s) ${nextJob.gpu_ids}`); | |
| await (0, startJob_1.default)(nextJob.id); | |
| } | |
| else { | |
| // no more jobs, stop the queue | |
| console.log(`No more jobs in queue for GPU(s) ${queue.gpu_ids}, stopping queue`); | |
| await prisma_1.default.queue.update({ | |
| where: { id: queue.id }, | |
| data: { is_running: false }, | |
| }); | |
| } | |
| } | |
| } | |
| } | |
| } | |
Xet Storage Details
- Size:
- 2.76 kB
- Xet hash:
- e155c2d2b9f9401434331bf673fc3fc760c1dda4489a82f923544457ca8d1634
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.