Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
d5fba7c
1
Parent(s):
630e591
Update route.ts
Browse files
ui/src/app/api/hf-jobs/route.ts
CHANGED
|
@@ -1058,27 +1058,39 @@ async function checkHFJobsCapacity(token: string): Promise<any> {
|
|
| 1058 |
});
|
| 1059 |
|
| 1060 |
childProcess.on('close', (code) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1061 |
if (code === 0) {
|
| 1062 |
try {
|
| 1063 |
-
console.log('Raw hf jobs ps output:', output);
|
| 1064 |
-
|
| 1065 |
// Count RUNNING jobs in the output
|
| 1066 |
-
|
|
|
|
| 1067 |
let runningCount = 0;
|
| 1068 |
|
| 1069 |
-
console.log(`Total lines in output: ${lines.length}`);
|
| 1070 |
|
| 1071 |
for (let i = 0; i < lines.length; i++) {
|
| 1072 |
const line = lines[i];
|
|
|
|
|
|
|
|
|
|
| 1073 |
if (line.includes('RUNNING')) {
|
| 1074 |
runningCount++;
|
| 1075 |
-
console.log(`Line ${i} contains RUNNING:
|
| 1076 |
}
|
| 1077 |
}
|
| 1078 |
|
| 1079 |
const atCapacity = runningCount >= 32;
|
| 1080 |
|
|
|
|
| 1081 |
console.log(`Found ${runningCount} RUNNING jobs. At capacity: ${atCapacity}`);
|
|
|
|
| 1082 |
|
| 1083 |
resolve({
|
| 1084 |
runningJobs: runningCount,
|
|
|
|
| 1058 |
});
|
| 1059 |
|
| 1060 |
childProcess.on('close', (code) => {
|
| 1061 |
+
console.log(`hf jobs ps process exited with code: ${code}`);
|
| 1062 |
+
console.log('=== RAW OUTPUT START ===');
|
| 1063 |
+
console.log(output);
|
| 1064 |
+
console.log('=== RAW OUTPUT END ===');
|
| 1065 |
+
console.log('=== RAW ERROR START ===');
|
| 1066 |
+
console.log(error);
|
| 1067 |
+
console.log('=== RAW ERROR END ===');
|
| 1068 |
+
|
| 1069 |
if (code === 0) {
|
| 1070 |
try {
|
|
|
|
|
|
|
| 1071 |
// Count RUNNING jobs in the output
|
| 1072 |
+
// Split by newline and filter out empty lines
|
| 1073 |
+
const lines = output.split(/\r?\n/).filter(line => line.trim().length > 0);
|
| 1074 |
let runningCount = 0;
|
| 1075 |
|
| 1076 |
+
console.log(`Total non-empty lines in output: ${lines.length}`);
|
| 1077 |
|
| 1078 |
for (let i = 0; i < lines.length; i++) {
|
| 1079 |
const line = lines[i];
|
| 1080 |
+
console.log(`Line ${i}: "${line}"`);
|
| 1081 |
+
|
| 1082 |
+
// Check if line contains RUNNING (case-sensitive as shown in your output)
|
| 1083 |
if (line.includes('RUNNING')) {
|
| 1084 |
runningCount++;
|
| 1085 |
+
console.log(` ✓ Line ${i} contains RUNNING (count: ${runningCount})`);
|
| 1086 |
}
|
| 1087 |
}
|
| 1088 |
|
| 1089 |
const atCapacity = runningCount >= 32;
|
| 1090 |
|
| 1091 |
+
console.log(`\n=== FINAL COUNT ===`);
|
| 1092 |
console.log(`Found ${runningCount} RUNNING jobs. At capacity: ${atCapacity}`);
|
| 1093 |
+
console.log(`==================\n`);
|
| 1094 |
|
| 1095 |
resolve({
|
| 1096 |
runningJobs: runningCount,
|