Spaces:
Paused
Paused
Julian Bilcke
commited on
Commit
·
585f76c
1
Parent(s):
57adb5c
let's try again
Browse files
src/scheduler/processTask.mts
CHANGED
|
@@ -23,7 +23,19 @@ export const processTask = async (task: VideoTask) => {
|
|
| 23 |
return
|
| 24 |
}
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
for (const shot of task.shots) {
|
|
|
|
|
|
|
| 27 |
// skip shots completed previously
|
| 28 |
if (shot.completed) {
|
| 29 |
continue
|
|
@@ -62,6 +74,9 @@ export const processTask = async (task: VideoTask) => {
|
|
| 62 |
|
| 63 |
shot.hasGeneratedPreview = true
|
| 64 |
shot.nbCompletedSteps++
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
await updatePendingTask(task)
|
| 67 |
|
|
@@ -97,6 +112,9 @@ export const processTask = async (task: VideoTask) => {
|
|
| 97 |
|
| 98 |
shot.hasGeneratedVideo = true
|
| 99 |
shot.nbCompletedSteps++
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
await updatePendingTask(task)
|
| 102 |
|
|
@@ -119,6 +137,9 @@ export const processTask = async (task: VideoTask) => {
|
|
| 119 |
|
| 120 |
shot.hasUpscaledVideo = true
|
| 121 |
shot.nbCompletedSteps++
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
await updatePendingTask(task)
|
| 124 |
|
|
@@ -157,6 +178,9 @@ export const processTask = async (task: VideoTask) => {
|
|
| 157 |
|
| 158 |
shot.hasInterpolatedVideo = true
|
| 159 |
shot.nbCompletedSteps++
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
await updatePendingTask(task)
|
| 162 |
|
|
@@ -187,6 +211,9 @@ export const processTask = async (task: VideoTask) => {
|
|
| 187 |
|
| 188 |
shot.hasPostProcessedVideo = true
|
| 189 |
shot.nbCompletedSteps++
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
await updatePendingTask(task)
|
| 192 |
|
|
@@ -203,6 +230,8 @@ export const processTask = async (task: VideoTask) => {
|
|
| 203 |
|
| 204 |
shot.completed = true
|
| 205 |
shot.completedAt = new Date().toISOString()
|
|
|
|
|
|
|
| 206 |
task.nbCompletedShots++
|
| 207 |
|
| 208 |
await updatePendingTask(task)
|
|
@@ -246,6 +275,8 @@ export const processTask = async (task: VideoTask) => {
|
|
| 246 |
}
|
| 247 |
}
|
| 248 |
|
|
|
|
|
|
|
| 249 |
task.completed = true
|
| 250 |
task.completedAt = new Date().toISOString()
|
| 251 |
await updatePendingTask(task)
|
|
|
|
| 23 |
return
|
| 24 |
}
|
| 25 |
|
| 26 |
+
// always count 1 more step, for the final assembly
|
| 27 |
+
|
| 28 |
+
let nbTotalSteps = 1
|
| 29 |
+
|
| 30 |
+
for (const shot of task.shots) {
|
| 31 |
+
nbTotalSteps += shot.nbTotalSteps
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
let nbCompletedSteps = 0
|
| 35 |
+
|
| 36 |
for (const shot of task.shots) {
|
| 37 |
+
nbCompletedSteps += shot.nbCompletedSteps
|
| 38 |
+
|
| 39 |
// skip shots completed previously
|
| 40 |
if (shot.completed) {
|
| 41 |
continue
|
|
|
|
| 74 |
|
| 75 |
shot.hasGeneratedPreview = true
|
| 76 |
shot.nbCompletedSteps++
|
| 77 |
+
nbCompletedSteps++
|
| 78 |
+
shot.progressPercent = Math.round((shot.nbCompletedSteps / shot.nbTotalSteps) * 100)
|
| 79 |
+
task.progressPercent = Math.round((nbCompletedSteps / nbTotalSteps) * 100)
|
| 80 |
|
| 81 |
await updatePendingTask(task)
|
| 82 |
|
|
|
|
| 112 |
|
| 113 |
shot.hasGeneratedVideo = true
|
| 114 |
shot.nbCompletedSteps++
|
| 115 |
+
nbCompletedSteps++
|
| 116 |
+
shot.progressPercent = Math.round((shot.nbCompletedSteps / shot.nbTotalSteps) * 100)
|
| 117 |
+
task.progressPercent = Math.round((nbCompletedSteps / nbTotalSteps) * 100)
|
| 118 |
|
| 119 |
await updatePendingTask(task)
|
| 120 |
|
|
|
|
| 137 |
|
| 138 |
shot.hasUpscaledVideo = true
|
| 139 |
shot.nbCompletedSteps++
|
| 140 |
+
nbCompletedSteps++
|
| 141 |
+
shot.progressPercent = Math.round((shot.nbCompletedSteps / shot.nbTotalSteps) * 100)
|
| 142 |
+
task.progressPercent = Math.round((nbCompletedSteps / nbTotalSteps) * 100)
|
| 143 |
|
| 144 |
await updatePendingTask(task)
|
| 145 |
|
|
|
|
| 178 |
|
| 179 |
shot.hasInterpolatedVideo = true
|
| 180 |
shot.nbCompletedSteps++
|
| 181 |
+
nbCompletedSteps++
|
| 182 |
+
shot.progressPercent = Math.round((shot.nbCompletedSteps / shot.nbTotalSteps) * 100)
|
| 183 |
+
task.progressPercent = Math.round((nbCompletedSteps / nbTotalSteps) * 100)
|
| 184 |
|
| 185 |
await updatePendingTask(task)
|
| 186 |
|
|
|
|
| 211 |
|
| 212 |
shot.hasPostProcessedVideo = true
|
| 213 |
shot.nbCompletedSteps++
|
| 214 |
+
nbCompletedSteps++
|
| 215 |
+
shot.progressPercent = Math.round((shot.nbCompletedSteps / shot.nbTotalSteps) * 100)
|
| 216 |
+
task.progressPercent = Math.round((nbCompletedSteps / nbTotalSteps) * 100)
|
| 217 |
|
| 218 |
await updatePendingTask(task)
|
| 219 |
|
|
|
|
| 230 |
|
| 231 |
shot.completed = true
|
| 232 |
shot.completedAt = new Date().toISOString()
|
| 233 |
+
shot.progressPercent = 100
|
| 234 |
+
|
| 235 |
task.nbCompletedShots++
|
| 236 |
|
| 237 |
await updatePendingTask(task)
|
|
|
|
| 275 |
}
|
| 276 |
}
|
| 277 |
|
| 278 |
+
nbCompletedSteps++
|
| 279 |
+
task.progressPercent = 100
|
| 280 |
task.completed = true
|
| 281 |
task.completedAt = new Date().toISOString()
|
| 282 |
await updatePendingTask(task)
|