Skip to content

Commit 19dd25d

Browse files
committed
States for main build tasks
1 parent afc011b commit 19dd25d

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

app.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def api_tasks():
136136
for name,host in running_tasks.items():
137137
for task in host:
138138
if task["type"] == "tasks.build_video":
139+
state = app_cel.AsyncResult(task["id"])
140+
state.ready()
139141
result["data"].append({
140142
"time_start": datetime.datetime.fromtimestamp(task["time_start"]).strftime('%Y-%m-%d %H:%M:%S'),
141143
"id": task["id"],
@@ -144,13 +146,16 @@ def api_tasks():
144146
"presenter": task["args"][1]["presenter"],
145147
"in_tc": task["args"][2],
146148
"out_tc": task["args"][3],
147-
"node": task["hostname"]
149+
"node": task["hostname"],
150+
"state": state.state
148151
})
149152

150153
if scheduled_tasks:
151154
for name,host in scheduled_tasks.items():
152155
for task in host:
153156
if task["type"] == "tasks.build_video":
157+
state = app_cel.AsyncResult(task["id"])
158+
state.ready()
154159
result["data"].append({
155160
"time_start": None,
156161
"id": task["id"],
@@ -159,7 +164,8 @@ def api_tasks():
159164
"presenter": task["args"][1]["presenter"],
160165
"in_tc": task["args"][2],
161166
"out_tc": task["args"][3],
162-
"node": task["hostname"]
167+
"node": task["hostname"],
168+
"state": state.state
163169
})
164170
return flask.jsonify(result)
165171

formvideo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,15 @@ def form_video(task, video, talk, start_tc, end_tc, framerate = FRAMERATE, out_d
196196

197197
# Build all the text assets
198198
logger.info("Building text assets.")
199+
task.update_state(state="Building text assets")
199200
subprocess.check_output(start_title_args)
200201
subprocess.check_output(start_pres_arg)
201202
subprocess.check_output(copyright_args)
202203

203204
# First FFmpeg pass for getting loudness stats
204205
logger.info("Detecting loudness information.")
205206
logger.debug(ffmpeg_loudness_args)
207+
task.update_state(state="Analysing Loudness")
206208
with open(loud_log, "a") as error_log:
207209
loud_output = subprocess.check_output(ffmpeg_loudness_args, stderr=subprocess.STDOUT, cwd=working_dir).decode("utf-8")
208210
error_log.writelines(loud_output)
@@ -274,6 +276,7 @@ def form_video(task, video, talk, start_tc, end_tc, framerate = FRAMERATE, out_d
274276
]
275277
logger.info("Running main build.")
276278
logger.debug(ffmpeg_args)
279+
task.update_state(state="Running main build")
277280
with open(build_log, "a") as error_log:
278281
subprocess.check_output(ffmpeg_args, stderr=error_log, cwd=working_dir)
279282
logger.info("Completed main build.")

templates/tasks-table-body.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ <h1>Running Tasks</h1>
1111
<th>Video Start TC</th>
1212
<th>Video End TC</th>
1313
<th>Worker node</th>
14+
<th>Status</th>
1415
</tr>
1516
</thead>
1617
</table>

templates/tasks-table-head.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
{ data: 'presenter' },
1313
{ data: 'in_tc' },
1414
{ data: 'out_tc' },
15-
{ data: 'node' }
15+
{ data: 'node' },
16+
{ data: 'state' }
1617
]
1718
} );
1819
setInterval(function () {
1920
table.ajax.reload(null, false);
20-
}, 30000);
21+
}, 5000);
2122
} );
2223
</script>

0 commit comments

Comments
 (0)