| author | wenzelm |
| Thu, 16 Oct 2025 21:38:26 +0200 | |
| changeset 83295 | 094d96f05cba |
| parent 83287 | 24000abcefab |
| child 83299 | 7d8713e1890b |
| permissions | -rw-r--r-- |
| 79502 | 1 |
/* Title: Pure/Build/build_job.scala |
| 72662 | 2 |
Author: Makarius |
3 |
||
4 |
Build job running prover process, with rudimentary PIDE session. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
| 83262 | 10 |
import java.io.BufferedWriter |
11 |
import java.nio.file.Files |
|
| 72662 | 12 |
|
13 |
||
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
14 |
trait Build_Job {
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
15 |
def cancel(): Unit = () |
| 77298 | 16 |
def is_finished: Boolean = false |
|
79887
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
17 |
def join: Build_Job.Result = Build_Job.no_result |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
18 |
} |
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
19 |
|
| 75393 | 20 |
object Build_Job {
|
| 78530 | 21 |
sealed case class Result(process_result: Process_Result, output_shasum: SHA1.Shasum) |
|
79887
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
22 |
val no_result: Result = Result(Process_Result.undefined, SHA1.no_shasum) |
| 78530 | 23 |
|
24 |
||
| 77396 | 25 |
/* build session */ |
26 |
||
| 77474 | 27 |
def start_session( |
| 78421 | 28 |
build_context: Build.Context, |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
29 |
session_context: Session_Context, |
| 77505 | 30 |
progress: Progress, |
31 |
log: Logger, |
|
| 78372 | 32 |
server: SSH.Server, |
| 77474 | 33 |
session_background: Sessions.Background, |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
34 |
sources_shasum: SHA1.Shasum, |
| 77474 | 35 |
input_shasum: SHA1.Shasum, |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
36 |
node_info: Host.Node_Info, |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
37 |
store_heap: Boolean |
| 77505 | 38 |
): Session_Job = {
|
| 78372 | 39 |
new Session_Job(build_context, session_context, progress, log, server, |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
40 |
session_background, sources_shasum, input_shasum, node_info, store_heap) |
| 77505 | 41 |
} |
| 77474 | 42 |
|
| 77442 | 43 |
object Session_Context {
|
44 |
def load( |
|
| 78374 | 45 |
database_server: Option[SQL.Database], |
|
77529
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77521
diff
changeset
|
46 |
build_uuid: String, |
|
77444
0c704aba71e3
clarified signature: reduce explicit access to static Sessions.Structure;
wenzelm
parents:
77442
diff
changeset
|
47 |
name: String, |
|
0c704aba71e3
clarified signature: reduce explicit access to static Sessions.Structure;
wenzelm
parents:
77442
diff
changeset
|
48 |
deps: List[String], |
|
0c704aba71e3
clarified signature: reduce explicit access to static Sessions.Structure;
wenzelm
parents:
77442
diff
changeset
|
49 |
ancestors: List[String], |
|
77610
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77587
diff
changeset
|
50 |
session_prefs: String, |
| 77458 | 51 |
sources_shasum: SHA1.Shasum, |
| 77442 | 52 |
timeout: Time, |
| 78178 | 53 |
store: Store, |
| 78374 | 54 |
progress: Progress = new Progress |
| 77442 | 55 |
): Session_Context = {
|
| 77450 | 56 |
def default: Session_Context = |
| 77496 | 57 |
Session_Context( |
|
77610
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77587
diff
changeset
|
58 |
name, deps, ancestors, session_prefs, sources_shasum, timeout, |
|
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77587
diff
changeset
|
59 |
Time.zero, Bytes.empty, build_uuid) |
|
77444
0c704aba71e3
clarified signature: reduce explicit access to static Sessions.Structure;
wenzelm
parents:
77442
diff
changeset
|
60 |
|
| 78374 | 61 |
def read(db: SQL.Database): Session_Context = {
|
62 |
def ignore_error(msg: String) = {
|
|
63 |
progress.echo_warning( |
|
64 |
"Ignoring bad database " + db + " for session " + quote(name) + |
|
65 |
if_proper(msg, ":\n" + msg)) |
|
66 |
default |
|
67 |
} |
|
68 |
try {
|
|
69 |
val command_timings = store.read_command_timings(db, name) |
|
| 83243 | 70 |
val elapsed = Time.seconds(Markup.Elapsed.get(store.read_session_timing(db, name))) |
| 78374 | 71 |
new Session_Context( |
72 |
name, deps, ancestors, session_prefs, sources_shasum, timeout, |
|
73 |
elapsed, command_timings, build_uuid) |
|
74 |
} |
|
75 |
catch {
|
|
76 |
case ERROR(msg) => ignore_error(msg) |
|
77 |
case exn: java.lang.Error => ignore_error(Exn.message(exn)) |
|
78 |
case _: XML.Error => ignore_error("XML.Error")
|
|
79 |
} |
|
80 |
} |
|
81 |
||
82 |
database_server match {
|
|
83 |
case Some(db) => if (store.session_info_exists(db)) read(db) else default |
|
84 |
case None => using_option(store.try_open_database(name))(read) getOrElse default |
|
| 77442 | 85 |
} |
86 |
} |
|
87 |
} |
|
88 |
||
| 77496 | 89 |
sealed case class Session_Context( |
90 |
name: String, |
|
91 |
deps: List[String], |
|
92 |
ancestors: List[String], |
|
|
77610
3b09ae9e40cb
clarified session prefs (or "options" within the database);
wenzelm
parents:
77587
diff
changeset
|
93 |
session_prefs: String, |
| 77496 | 94 |
sources_shasum: SHA1.Shasum, |
95 |
timeout: Time, |
|
96 |
old_time: Time, |
|
97 |
old_command_timings_blob: Bytes, |
|
|
77529
40ccee0fe19a
separate static build_uuid from dynamic worker_uuid, to allow multiple worker processes participate in one build process;
wenzelm
parents:
77521
diff
changeset
|
98 |
build_uuid: String |
| 80270 | 99 |
) extends Name.T |
| 77442 | 100 |
|
| 83259 | 101 |
abstract class Build_Session(progress: Progress) extends Session {
|
| 83262 | 102 |
/* additional process output */ |
103 |
||
104 |
private val process_output_file = Isabelle_System.tmp_file("process_output")
|
|
105 |
private var process_output_writer: Option[BufferedWriter] = None |
|
106 |
||
107 |
def read_process_output(): List[String] = synchronized {
|
|
108 |
require(process_output_writer.isEmpty, "read_process_output") |
|
109 |
using(Files.newBufferedReader(process_output_file.toPath))(File.read_lines(_, _ => ())) |
|
110 |
} |
|
111 |
||
112 |
def write_process_output(str: String): Unit = synchronized {
|
|
113 |
require(process_output_writer.isDefined, "write_process_output") |
|
114 |
process_output_writer.get.write(str) |
|
115 |
process_output_writer.get.write("\n")
|
|
116 |
} |
|
117 |
||
118 |
def start_process_output(): Unit = synchronized {
|
|
119 |
require(process_output_writer.isEmpty, "start_process_output") |
|
120 |
process_output_file.delete |
|
121 |
process_output_writer = Some(File.writer(process_output_file)) |
|
122 |
} |
|
123 |
||
124 |
def stop_process_output(): Unit = synchronized {
|
|
125 |
if (process_output_writer.isDefined) {
|
|
126 |
process_output_writer.get.close() |
|
127 |
process_output_writer = None |
|
128 |
} |
|
129 |
} |
|
130 |
||
131 |
def clean_process_output(): Unit = synchronized {
|
|
132 |
process_output_writer.foreach(_.close()) |
|
133 |
process_output_file.delete |
|
134 |
} |
|
135 |
||
136 |
||
| 83259 | 137 |
/* options */ |
138 |
||
139 |
val build_progress_delay: Time = session_options.seconds("build_progress_delay")
|
|
140 |
val build_timing_threshold: Time = session_options.seconds("build_timing_threshold")
|
|
141 |
val editor_timing_threshold: Time = session_options.seconds("editor_timing_threshold")
|
|
142 |
||
143 |
||
| 83258 | 144 |
/* errors */ |
145 |
||
146 |
private val build_errors: Promise[List[String]] = Future.promise |
|
147 |
||
148 |
def errors_result(): Exn.Result[List[String]] = build_errors.join_result |
|
149 |
def errors_cancel(): Unit = build_errors.cancel() |
|
150 |
def errors(errs: List[String]): Unit = {
|
|
151 |
try { build_errors.fulfill(errs) }
|
|
152 |
catch { case _: IllegalStateException => }
|
|
153 |
} |
|
| 83259 | 154 |
|
155 |
||
156 |
/* document nodes --- session theories */ |
|
157 |
||
158 |
def nodes_domain: List[Document.Node.Name] |
|
159 |
||
160 |
private var nodes_changed = Set.empty[Document_ID.Generic] |
|
161 |
private var nodes_status = Document_Status.Nodes_Status.empty |
|
162 |
||
163 |
private def nodes_status_progress(): Unit = {
|
|
164 |
val state = get_state() |
|
165 |
val result = |
|
166 |
synchronized {
|
|
167 |
val nodes_status1 = |
|
168 |
nodes_changed.foldLeft(nodes_status)({ case (status, state_id) =>
|
|
169 |
state.theory_snapshot(state_id, build_blobs) match {
|
|
170 |
case None => status |
|
171 |
case Some(snapshot) => |
|
172 |
Exn.Interrupt.expose() |
|
173 |
status.update_node(snapshot.state, snapshot.version, snapshot.node_name, |
|
174 |
threshold = editor_timing_threshold) |
|
175 |
} |
|
176 |
}) |
|
177 |
val result = |
|
178 |
if (nodes_changed.isEmpty) None |
|
179 |
else {
|
|
180 |
Some(Progress.Nodes_Status( |
|
181 |
nodes_domain, nodes_status1, |
|
182 |
session = resources.session_background.session_name, |
|
183 |
old = Some(nodes_status))) |
|
184 |
} |
|
185 |
||
186 |
nodes_changed = Set.empty |
|
187 |
nodes_status = nodes_status1 |
|
188 |
||
189 |
result |
|
190 |
} |
|
191 |
result.foreach(progress.nodes_status) |
|
192 |
} |
|
193 |
||
194 |
private val nodes_delay = Delay.first(build_progress_delay) { nodes_status_progress() }
|
|
195 |
||
196 |
def nodes_status_sync(): Unit = {
|
|
197 |
nodes_delay.revoke() |
|
198 |
nodes_status_progress() |
|
199 |
} |
|
200 |
||
| 83262 | 201 |
override def start(start_prover: Prover.Receiver => Prover): Unit = {
|
202 |
start_process_output() |
|
203 |
super.start(start_prover) |
|
204 |
} |
|
205 |
||
| 83259 | 206 |
override def stop(): Process_Result = {
|
207 |
val result = super.stop() |
|
208 |
nodes_status_sync() |
|
| 83262 | 209 |
stop_process_output() |
| 83259 | 210 |
result |
211 |
} |
|
212 |
||
213 |
def command_timing(state_id: Document_ID.Generic, props: Properties.T): Unit = synchronized {
|
|
214 |
val elapsed = Time.seconds(Markup.Elapsed.get(props)) |
|
215 |
if (elapsed.is_notable(build_timing_threshold)) {
|
|
| 83295 | 216 |
write_process_output( |
217 |
Protocol.Command_Timing_Marker(props.filter(Markup.command_timing_property))) |
|
| 83259 | 218 |
} |
219 |
||
220 |
nodes_changed += state_id |
|
221 |
nodes_delay.invoke() |
|
222 |
} |
|
| 83258 | 223 |
} |
224 |
||
| 77474 | 225 |
class Session_Job private[Build_Job]( |
| 78421 | 226 |
build_context: Build.Context, |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
227 |
session_context: Session_Context, |
| 77505 | 228 |
progress: Progress, |
229 |
log: Logger, |
|
| 78372 | 230 |
server: SSH.Server, |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
231 |
session_background: Sessions.Background, |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
232 |
sources_shasum: SHA1.Shasum, |
|
77460
ccca589d7027
tuned signature: support general Build_Job instances;
wenzelm
parents:
77458
diff
changeset
|
233 |
input_shasum: SHA1.Shasum, |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
234 |
node_info: Host.Node_Info, |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
235 |
store_heap: Boolean |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
236 |
) extends Build_Job {
|
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
237 |
def session_name: String = session_background.session_name |
|
77349
5a84de89170d
more operations to support management of jobs, e.g. from external database;
wenzelm
parents:
77298
diff
changeset
|
238 |
|
|
79887
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
239 |
private val future_result: Future[Result] = |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
240 |
Future.thread("build", uninterruptible = true) {
|
|
78359
cb0a90df4871
prefer asynchronous operations: reduce time spent within synchronized_database("Build_Process.start_job");
wenzelm
parents:
78280
diff
changeset
|
241 |
val info = session_background.sessions_structure(session_name) |
|
78842
eb572f7b6689
prefer extensible next_node_info in build process over process_options in build engine (which needs the final node info anyway);
Fabian Huch <huch@in.tum.de>
parents:
78674
diff
changeset
|
242 |
val options = Host.node_options(info.options, node_info) |
|
78359
cb0a90df4871
prefer asynchronous operations: reduce time spent within synchronized_database("Build_Process.start_job");
wenzelm
parents:
78280
diff
changeset
|
243 |
val store = build_context.store |
|
cb0a90df4871
prefer asynchronous operations: reduce time spent within synchronized_database("Build_Process.start_job");
wenzelm
parents:
78280
diff
changeset
|
244 |
|
| 78372 | 245 |
using_optional(store.maybe_open_database_server(server = server)) { database_server =>
|
246 |
store.clean_output(database_server, session_name, session_init = true) |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
247 |
|
| 78372 | 248 |
val session_sources = |
249 |
Store.Sources.load(session_background.base, cache = store.cache.compress) |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
250 |
|
| 78372 | 251 |
val env = |
| 82706 | 252 |
Isabelle_System.Settings.env( |
| 78372 | 253 |
List("ISABELLE_ML_DEBUGGER" -> options.bool("ML_debugger").toString))
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
254 |
|
| 78372 | 255 |
val session_heaps = |
256 |
session_background.info.parent match {
|
|
257 |
case None => Nil |
|
| 82752 | 258 |
case Some(logic) => store.session_heaps(session_background, logic = logic) |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
259 |
} |
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
260 |
|
| 78372 | 261 |
val use_prelude = if (session_heaps.isEmpty) Thy_Header.ml_roots.map(_._1) else Nil |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
262 |
|
| 78372 | 263 |
val eval_store = |
264 |
if (store_heap) {
|
|
265 |
(if (info.theories.nonEmpty) List("ML_Heap.share_common_data ()") else Nil) :::
|
|
266 |
List("ML_Heap.save_child " +
|
|
267 |
ML_Syntax.print_string_bytes(File.platform_path(store.output_heap(session_name)))) |
|
268 |
} |
|
269 |
else Nil |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
270 |
|
| 78372 | 271 |
def session_blobs(node_name: Document.Node.Name): List[(Command.Blob, Document.Blobs.Item)] = |
272 |
session_background.base.theory_load_commands.get(node_name.theory) match {
|
|
273 |
case None => Nil |
|
|
82948
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
274 |
case Some(load_commands) => |
| 78372 | 275 |
val syntax = session_background.base.theory_syntax(node_name) |
276 |
val master_dir = Path.explode(node_name.master_dir) |
|
|
82948
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
277 |
for {
|
|
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
278 |
(command_span, command_offset) <- load_commands |
|
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
279 |
file <- command_span.loaded_files(syntax).files |
|
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
280 |
} yield {
|
| 78372 | 281 |
val src_path = Path.explode(file) |
282 |
val blob_name = Document.Node.Name(File.symbolic_path(master_dir + src_path)) |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
283 |
|
| 78372 | 284 |
val bytes = session_sources(blob_name.node).bytes |
285 |
val text = bytes.text |
|
286 |
val chunk = Symbol.Text_Chunk(text) |
|
|
82948
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
287 |
val content = Some((SHA1.digest(bytes), chunk)) |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
288 |
|
|
82948
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
289 |
Command.Blob(command_offset, blob_name, src_path, content) -> |
|
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
290 |
Document.Blobs.Item(bytes, text, chunk, command_offset = command_offset) |
| 78372 | 291 |
} |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
292 |
} |
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
293 |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
294 |
|
| 78372 | 295 |
/* session */ |
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
296 |
|
|
82744
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
297 |
val session = |
| 83259 | 298 |
new Build_Session(progress) {
|
| 82780 | 299 |
override def session_options: Options = options |
300 |
||
|
82769
7cb5ef6da1f0
proper build_context.store, instead of circular null value (amending 0e36478a1b6a and e891ff63e6db);
wenzelm
parents:
82752
diff
changeset
|
301 |
override val store: Store = build_context.store |
|
82750
0e36478a1b6a
clarified signature: Session always provides Store (with Rich_Text.Cache);
wenzelm
parents:
82744
diff
changeset
|
302 |
|
|
82744
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
303 |
override val resources: Resources = |
|
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
304 |
new Resources(session_background, log = log, |
|
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
305 |
command_timings = |
|
82750
0e36478a1b6a
clarified signature: Session always provides Store (with Rich_Text.Cache);
wenzelm
parents:
82744
diff
changeset
|
306 |
Properties.uncompress(session_context.old_command_timings_blob, cache = cache)) |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
307 |
|
| 78372 | 308 |
override def build_blobs_info(node_name: Document.Node.Name): Command.Blobs_Info = |
309 |
Command.Blobs_Info.make(session_blobs(node_name)) |
|
310 |
||
311 |
override def build_blobs(node_name: Document.Node.Name): Document.Blobs = |
|
312 |
Document.Blobs.make(session_blobs(node_name)) |
|
| 83259 | 313 |
|
314 |
override val nodes_domain: List[Document.Node.Name] = |
|
315 |
session_background.base.used_theories.map(_._1.symbolic_path) |
|
| 78372 | 316 |
} |
317 |
||
318 |
val export_consumer = |
|
319 |
Export.consumer(store.open_database(session_name, output = true, server = server), |
|
320 |
store.cache, progress = progress) |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
321 |
|
| 83204 | 322 |
// mutable state: session.synchronized |
| 78372 | 323 |
val stdout = new StringBuilder(1000) |
324 |
val stderr = new StringBuilder(1000) |
|
| 83249 | 325 |
|
| 78372 | 326 |
def fun( |
327 |
name: String, |
|
| 83262 | 328 |
marker: Protocol_Message.Marker, |
| 78372 | 329 |
unapply: Properties.T => Option[Properties.T] |
330 |
): (String, Session.Protocol_Function) = {
|
|
331 |
name -> ((msg: Prover.Protocol_Output) => |
|
332 |
unapply(msg.properties) match {
|
|
| 83262 | 333 |
case Some(props) => session.write_process_output(marker(props)); true |
| 78372 | 334 |
case _ => false |
335 |
}) |
|
| 77485 | 336 |
} |
337 |
||
| 78372 | 338 |
session.init_protocol_handler(new Session.Protocol_Handler {
|
| 83258 | 339 |
override def exit(): Unit = session.errors_cancel() |
| 78372 | 340 |
|
341 |
private def build_session_finished(msg: Prover.Protocol_Output): Boolean = {
|
|
342 |
val (rc, errors) = |
|
343 |
try {
|
|
344 |
val (rc, errs) = {
|
|
345 |
import XML.Decode._ |
|
| 80463 | 346 |
pair(int, list(self))(Symbol.decode_yxml(msg.text)) |
| 78372 | 347 |
} |
348 |
val errors = |
|
349 |
for (err <- errs) yield {
|
|
| 80872 | 350 |
Pretty.string_of(err, metric = Symbol.Metric, pure = true) |
| 78372 | 351 |
} |
352 |
(rc, errors) |
|
353 |
} |
|
354 |
catch { case ERROR(err) => (Process_Result.RC.failure, List(err)) }
|
|
355 |
||
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
356 |
session.protocol_command("Prover.stop", XML.Encode.int(rc))
|
| 83258 | 357 |
session.errors(errors) |
| 78372 | 358 |
true |
359 |
} |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
360 |
|
| 78372 | 361 |
private def loading_theory(msg: Prover.Protocol_Output): Boolean = |
362 |
msg.properties match {
|
|
363 |
case Markup.Loading_Theory(Markup.Name(name)) => |
|
364 |
progress.theory(Progress.Theory(name, session = session_name)) |
|
365 |
false |
|
366 |
case _ => false |
|
367 |
} |
|
368 |
||
369 |
private def export_(msg: Prover.Protocol_Output): Boolean = |
|
370 |
msg.properties match {
|
|
371 |
case Protocol.Export(args) => |
|
372 |
export_consumer.make_entry(session_name, args, msg.chunk) |
|
373 |
true |
|
374 |
case _ => false |
|
375 |
} |
|
376 |
||
377 |
override val functions: Session.Protocol_Functions = |
|
378 |
List( |
|
379 |
Markup.Build_Session_Finished.name -> build_session_finished, |
|
380 |
Markup.Loading_Theory.name -> loading_theory, |
|
381 |
Markup.EXPORT -> export_, |
|
| 83262 | 382 |
fun(Markup.Session_Timing.name, |
383 |
Protocol.Session_Timing_Marker, Markup.Session_Timing.unapply), |
|
384 |
fun(Markup.Task_Statistics.name, |
|
385 |
Protocol.Task_Statistics_Marker, Markup.Task_Statistics.unapply)) |
|
| 78372 | 386 |
}) |
387 |
||
388 |
session.command_timings += Session.Consumer("command_timings") {
|
|
| 83259 | 389 |
case Session.Command_Timing(state_id, props) => session.command_timing(state_id, props) |
| 78372 | 390 |
} |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
391 |
|
| 78372 | 392 |
session.runtime_statistics += Session.Consumer("ML_statistics") {
|
| 83260 | 393 |
case Session.Runtime_Statistics(props) => |
| 83262 | 394 |
session.write_process_output(Protocol.ML_Statistics_Marker(props)) |
| 78372 | 395 |
} |
396 |
||
397 |
session.finished_theories += Session.Consumer[Document.Snapshot]("finished_theories") {
|
|
398 |
case snapshot => |
|
399 |
if (!progress.stopped) {
|
|
400 |
def export_(name: String, xml: XML.Body, compress: Boolean = true): Unit = {
|
|
401 |
if (!progress.stopped) {
|
|
402 |
val theory_name = snapshot.node_name.theory |
|
403 |
val args = |
|
| 79692 | 404 |
Protocol.Export.Args( |
405 |
theory_name = theory_name, name = name, compress = compress) |
|
|
80437
2c07b9b2f9f4
minor performance tuning: more direct Bytes with Symbol.encode;
wenzelm
parents:
80270
diff
changeset
|
406 |
val body = YXML.bytes_of_body(xml, recode = Symbol.encode) |
| 78372 | 407 |
export_consumer.make_entry(session_name, args, body) |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
408 |
} |
| 78372 | 409 |
} |
410 |
def export_text(name: String, text: String, compress: Boolean = true): Unit = |
|
411 |
export_(name, List(XML.Text(text)), compress = compress) |
|
412 |
||
|
82741
0c83a22d8556
more robust: assertion holds, because session.finished_theories provides Snapshot from Document.State.end_theory;
wenzelm
parents:
82706
diff
changeset
|
413 |
assert(snapshot.snippet_commands.length == 1) |
|
81414
ed4ff84e9b21
Document.Snapshot: support for multiple snippet_commands;
wenzelm
parents:
80872
diff
changeset
|
414 |
for (command <- snapshot.snippet_commands) {
|
| 78372 | 415 |
export_text(Export.DOCUMENT_ID, command.id.toString, compress = false) |
416 |
} |
|
417 |
||
|
82948
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
418 |
export_(Export.FILES, |
|
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
419 |
{
|
|
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
420 |
import XML.Encode._ |
|
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
421 |
list(pair(int, string))(snapshot.node_export_files) |
|
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82780
diff
changeset
|
422 |
}) |
| 78372 | 423 |
|
424 |
for ((blob_name, i) <- snapshot.node_files.tail.zipWithIndex) {
|
|
425 |
val xml = snapshot.switch(blob_name).xml_markup() |
|
426 |
export_(Export.MARKUP + (i + 1), xml) |
|
427 |
} |
|
428 |
export_(Export.MARKUP, snapshot.xml_markup()) |
|
429 |
export_(Export.MESSAGES, snapshot.messages.map(_._1)) |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
430 |
} |
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
431 |
} |
| 78372 | 432 |
|
433 |
session.all_messages += Session.Consumer[Any]("build_session_output") {
|
|
434 |
case msg: Prover.Output => |
|
435 |
val message = msg.message |
|
|
82744
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
436 |
if (msg.is_system) session.resources.log(Protocol.message_text(message)) |
| 78372 | 437 |
|
438 |
if (msg.is_stdout) {
|
|
| 83204 | 439 |
session.synchronized { stdout ++= Symbol.encode(XML.content(message)) }
|
| 78372 | 440 |
} |
441 |
else if (msg.is_stderr) {
|
|
| 83204 | 442 |
session.synchronized { stderr ++= Symbol.encode(XML.content(message)) }
|
| 78372 | 443 |
} |
444 |
else if (msg.is_exit) {
|
|
| 83259 | 445 |
session.nodes_status_sync() |
| 78372 | 446 |
val err = |
447 |
"Prover terminated" + |
|
448 |
(msg.properties match {
|
|
449 |
case Markup.Process_Result(result) => ": " + result.print_rc |
|
450 |
case _ => "" |
|
451 |
}) |
|
| 83258 | 452 |
session.errors(List(err)) |
| 78372 | 453 |
} |
454 |
case _ => |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
455 |
} |
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
456 |
|
| 78372 | 457 |
build_context.session_setup(session_name, session) |
458 |
||
459 |
val eval_main = Command_Line.ML_tool("Isabelle_Process.init_build ()" :: eval_store)
|
|
460 |
||
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
461 |
|
| 78372 | 462 |
/* process */ |
463 |
||
464 |
val process = |
|
465 |
Isabelle_Process.start(options, session, session_background, session_heaps, |
|
|
80224
db92e0b6a11a
clarified signature: prefer symbolic isabelle.Path over physical java.io.File;
wenzelm
parents:
80121
diff
changeset
|
466 |
use_prelude = use_prelude, eval_main = eval_main, cwd = info.dir, env = env) |
| 78372 | 467 |
|
468 |
val timeout_request: Option[Event_Timer.Request] = |
|
469 |
if (info.timeout_ignored) None |
|
470 |
else Some(Event_Timer.request(Time.now() + info.timeout) { process.terminate() })
|
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
471 |
|
| 78372 | 472 |
val build_errors = |
473 |
Isabelle_Thread.interrupt_handler(_ => process.terminate()) {
|
|
474 |
Exn.capture { process.await_startup() } match {
|
|
475 |
case Exn.Res(_) => |
|
|
82744
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
476 |
val resources_xml = session.resources.init_session_xml |
| 78372 | 477 |
val encode_options: XML.Encode.T[Options] = |
478 |
options => session.prover_options(options).encode |
|
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
479 |
val args_xml = |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
480 |
{
|
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
481 |
import XML.Encode._ |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
482 |
pair(string, list(pair(encode_options, list(pair(string, properties)))))( |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
483 |
(session_name, info.theories)) |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
484 |
} |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
485 |
session.protocol_command("build_session", resources_xml, args_xml)
|
| 83258 | 486 |
session.errors_result() |
| 78372 | 487 |
case Exn.Exn(exn) => Exn.Res(List(Exn.message(exn))) |
488 |
} |
|
489 |
} |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
490 |
|
| 78372 | 491 |
val result0 = |
492 |
Isabelle_Thread.interrupt_handler(_ => process.terminate()) { process.await_shutdown() }
|
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
493 |
|
| 78372 | 494 |
val was_timeout = |
495 |
timeout_request match {
|
|
496 |
case None => false |
|
497 |
case Some(request) => !request.cancel() |
|
498 |
} |
|
499 |
||
500 |
session.stop() |
|
|
83209
a39fde2f020a
basic setup for build progress with nodes_status;
wenzelm
parents:
83207
diff
changeset
|
501 |
|
| 78372 | 502 |
val export_errors = |
503 |
export_consumer.shutdown(close = true).map(Output.error_message_text) |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
504 |
|
| 78372 | 505 |
val (document_output, document_errors) = |
506 |
try {
|
|
| 78674 | 507 |
if (Exn.is_res(build_errors) && result0.ok && info.documents.nonEmpty) {
|
| 78379 | 508 |
using(Export.open_database_context(store, server = server)) { database_context =>
|
| 78372 | 509 |
val documents = |
510 |
using(database_context.open_session(session_background)) {
|
|
511 |
session_context => |
|
512 |
Document_Build.build_documents( |
|
513 |
Document_Build.context(session_context, progress = progress), |
|
514 |
output_sources = info.document_output, |
|
515 |
output_pdf = info.document_output) |
|
516 |
} |
|
| 79692 | 517 |
using(database_context.open_database(session_name, output = true))( |
518 |
session_database => |
|
519 |
documents.foreach(_.write(session_database.db, session_name))) |
|
| 78372 | 520 |
(documents.flatMap(_.log_lines), Nil) |
521 |
} |
|
| 77484 | 522 |
} |
| 78372 | 523 |
else (Nil, Nil) |
524 |
} |
|
525 |
catch {
|
|
526 |
case exn: Document_Build.Build_Error => (exn.log_lines, exn.log_errors) |
|
527 |
case Exn.Interrupt.ERROR(msg) => (Nil, List(msg)) |
|
528 |
} |
|
| 77485 | 529 |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
530 |
|
| 78372 | 531 |
/* process result */ |
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
532 |
|
| 78372 | 533 |
val result1 = {
|
534 |
val more_output = |
|
| 83204 | 535 |
session.synchronized {
|
536 |
Library.trim_line(stdout.toString) :: |
|
| 83262 | 537 |
session.read_process_output() ::: |
| 83204 | 538 |
document_output |
539 |
} |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
540 |
|
| 78372 | 541 |
result0.output(more_output) |
542 |
.error(Library.trim_line(stderr.toString)) |
|
543 |
.errors_rc(export_errors ::: document_errors) |
|
544 |
} |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
545 |
|
| 78372 | 546 |
val result2 = |
547 |
build_errors match {
|
|
548 |
case Exn.Res(build_errs) => |
|
549 |
val errs = build_errs ::: document_errors |
|
550 |
if (errs.nonEmpty) {
|
|
551 |
result1.error_rc.output( |
|
552 |
errs.flatMap(s => split_lines(Output.error_message_text(s))) ::: |
|
553 |
errs.map(Protocol.Error_Message_Marker.apply)) |
|
554 |
} |
|
| 79692 | 555 |
else if (progress.stopped && result1.ok) {
|
556 |
result1.copy(rc = Process_Result.RC.interrupt) |
|
557 |
} |
|
| 78372 | 558 |
else result1 |
559 |
case Exn.Exn(Exn.Interrupt()) => |
|
560 |
if (result1.ok) result1.copy(rc = Process_Result.RC.interrupt) |
|
561 |
else result1 |
|
562 |
case Exn.Exn(exn) => throw exn |
|
563 |
} |
|
564 |
||
565 |
val process_result = |
|
566 |
if (result2.ok) result2 |
|
567 |
else if (was_timeout) result2.error(Output.error_message_text("Timeout")).timeout_rc
|
|
568 |
else if (result2.interrupted) result2.error(Output.error_message_text("Interrupt"))
|
|
569 |
else result2 |
|
570 |
||
|
79691
d298c5b65d8e
clarified store_session: heap requires process_result.ok, but log_db is always stored;
wenzelm
parents:
79682
diff
changeset
|
571 |
val store_session = |
|
d298c5b65d8e
clarified store_session: heap requires process_result.ok, but log_db is always stored;
wenzelm
parents:
79682
diff
changeset
|
572 |
store.output_session(session_name, store_heap = process_result.ok && store_heap) |
|
d298c5b65d8e
clarified store_session: heap requires process_result.ok, but log_db is always stored;
wenzelm
parents:
79682
diff
changeset
|
573 |
|
| 83262 | 574 |
session.clean_process_output() |
575 |
||
| 78372 | 576 |
|
577 |
/* output heap */ |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
578 |
|
|
79682
1fa1b32b0379
build local log_db, with store/restore via optional database server;
wenzelm
parents:
79678
diff
changeset
|
579 |
val output_shasum = |
|
1fa1b32b0379
build local log_db, with store/restore via optional database server;
wenzelm
parents:
79678
diff
changeset
|
580 |
store_session.heap match {
|
|
79691
d298c5b65d8e
clarified store_session: heap requires process_result.ok, but log_db is always stored;
wenzelm
parents:
79682
diff
changeset
|
581 |
case Some(path) => SHA1.shasum(ML_Heap.write_file_digest(path), session_name) |
|
d298c5b65d8e
clarified store_session: heap requires process_result.ok, but log_db is always stored;
wenzelm
parents:
79682
diff
changeset
|
582 |
case None => SHA1.no_shasum |
| 78372 | 583 |
} |
584 |
||
585 |
val log_lines = process_result.out_lines.filterNot(Protocol_Message.Marker.test) |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
586 |
|
| 78372 | 587 |
val build_log = |
|
78985
24e686fe043e
clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents:
78842
diff
changeset
|
588 |
Build_Log.Log_File(session_name, process_result.out_lines, cache = store.cache). |
| 78372 | 589 |
parse_session_info( |
590 |
command_timings = true, |
|
591 |
theory_timings = true, |
|
592 |
ml_statistics = true, |
|
593 |
task_statistics = true) |
|
594 |
||
595 |
// write log file |
|
596 |
if (process_result.ok) {
|
|
597 |
File.write_gzip(store.output_log_gz(session_name), terminate_lines(log_lines)) |
|
598 |
} |
|
599 |
else File.write(store.output_log(session_name), terminate_lines(log_lines)) |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
600 |
|
| 78372 | 601 |
// write database |
| 78374 | 602 |
def write_info(db: SQL.Database): Unit = |
| 78372 | 603 |
store.write_session_info(db, session_name, session_sources, |
604 |
build_log = |
|
605 |
if (process_result.timeout) build_log.error("Timeout") else build_log,
|
|
606 |
build = |
|
607 |
Store.Build_Info( |
|
608 |
sources = sources_shasum, |
|
609 |
input_heaps = input_shasum, |
|
610 |
output_heap = output_shasum, |
|
611 |
process_result.rc, |
|
| 78374 | 612 |
build_context.build_uuid)) |
|
78529
0e79fa88cab6
build_worker is stopped independently from master build_process;
wenzelm
parents:
78435
diff
changeset
|
613 |
|
|
79887
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
614 |
database_server match {
|
|
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
615 |
case Some(db) => write_info(db) |
|
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
616 |
case None => using(store.open_database(session_name, output = true))(write_info) |
|
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
617 |
} |
| 78372 | 618 |
|
| 80121 | 619 |
store.in_heaps_database( |
620 |
List(store_session), database_server, server = server, progress = progress) |
|
|
79682
1fa1b32b0379
build local log_db, with store/restore via optional database server;
wenzelm
parents:
79678
diff
changeset
|
621 |
|
| 78372 | 622 |
// messages |
623 |
process_result.err_lines.foreach(progress.echo(_)) |
|
624 |
||
625 |
if (process_result.ok) {
|
|
626 |
val props = build_log.session_timing |
|
627 |
val threads = Markup.Session_Timing.Threads.unapply(props) getOrElse 1 |
|
628 |
val timing = Markup.Timing_Properties.get(props) |
|
629 |
progress.echo( |
|
630 |
"Timing " + session_name + " (" + threads + " threads, " + timing.message_factor + ")",
|
|
631 |
verbose = true) |
|
632 |
progress.echo( |
|
633 |
"Finished " + session_name + " (" + process_result.timing.message_resources + ")")
|
|
634 |
} |
|
635 |
else {
|
|
636 |
progress.echo( |
|
| 79692 | 637 |
session_name + " FAILED (see also \"isabelle build_log -H Error " + |
638 |
session_name + "\")") |
|
| 78372 | 639 |
if (!process_result.interrupted) {
|
640 |
val tail = info.options.int("process_output_tail")
|
|
| 79692 | 641 |
val suffix = |
642 |
if (tail == 0) log_lines else log_lines.drop(log_lines.length - tail max 0) |
|
643 |
val prefix = |
|
644 |
if (log_lines.length == suffix.length) Nil else List("...")
|
|
| 78372 | 645 |
progress.echo(Library.trim_line(cat_lines(prefix ::: suffix))) |
646 |
} |
|
647 |
} |
|
648 |
||
|
79887
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
649 |
Result(process_result.copy(out_lines = log_lines), output_shasum) |
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
650 |
} |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
651 |
} |
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
652 |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
653 |
override def cancel(): Unit = future_result.cancel() |
| 77298 | 654 |
override def is_finished: Boolean = future_result.is_finished |
|
79887
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
655 |
override def join: Result = future_result.join |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
656 |
} |
|
72848
d5d0e36eda16
read theory with PIDE markup from session database;
wenzelm
parents:
72844
diff
changeset
|
657 |
} |