| author | wenzelm |
| Sat, 18 Oct 2025 17:29:39 +0200 | |
| changeset 83310 | d0331badb854 |
| parent 83301 | 88e33d16f2de |
| child 83311 | 0e40bd617b6c |
| 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 {
|
|
| 83310 | 167 |
for (id <- state.progress_theories if !nodes_changed(id)) nodes_changed += id |
| 83259 | 168 |
val nodes_status1 = |
169 |
nodes_changed.foldLeft(nodes_status)({ case (status, state_id) =>
|
|
170 |
state.theory_snapshot(state_id, build_blobs) match {
|
|
171 |
case None => status |
|
172 |
case Some(snapshot) => |
|
173 |
Exn.Interrupt.expose() |
|
174 |
status.update_node(snapshot.state, snapshot.version, snapshot.node_name, |
|
175 |
threshold = editor_timing_threshold) |
|
176 |
} |
|
177 |
}) |
|
178 |
val result = |
|
179 |
if (nodes_changed.isEmpty) None |
|
180 |
else {
|
|
181 |
Some(Progress.Nodes_Status( |
|
182 |
nodes_domain, nodes_status1, |
|
183 |
session = resources.session_background.session_name, |
|
184 |
old = Some(nodes_status))) |
|
185 |
} |
|
186 |
||
187 |
nodes_changed = Set.empty |
|
188 |
nodes_status = nodes_status1 |
|
189 |
||
190 |
result |
|
191 |
} |
|
192 |
result.foreach(progress.nodes_status) |
|
193 |
} |
|
194 |
||
|
83301
88e33d16f2de
more thorough update of nodes_status, while commands are running silently;
wenzelm
parents:
83299
diff
changeset
|
195 |
private lazy val nodes_delay: Delay = |
|
88e33d16f2de
more thorough update of nodes_status, while commands are running silently;
wenzelm
parents:
83299
diff
changeset
|
196 |
Delay.first(build_progress_delay) { nodes_status_progress(); nodes_delay.invoke() }
|
| 83259 | 197 |
|
198 |
def nodes_status_sync(): Unit = {
|
|
199 |
nodes_delay.revoke() |
|
200 |
nodes_status_progress() |
|
201 |
} |
|
202 |
||
| 83262 | 203 |
override def start(start_prover: Prover.Receiver => Prover): Unit = {
|
204 |
start_process_output() |
|
205 |
super.start(start_prover) |
|
206 |
} |
|
207 |
||
| 83259 | 208 |
override def stop(): Process_Result = {
|
209 |
val result = super.stop() |
|
210 |
nodes_status_sync() |
|
| 83262 | 211 |
stop_process_output() |
| 83259 | 212 |
result |
213 |
} |
|
214 |
||
215 |
def command_timing(state_id: Document_ID.Generic, props: Properties.T): Unit = synchronized {
|
|
216 |
val elapsed = Time.seconds(Markup.Elapsed.get(props)) |
|
217 |
if (elapsed.is_notable(build_timing_threshold)) {
|
|
| 83295 | 218 |
write_process_output( |
| 83299 | 219 |
Protocol.Command_Timing_Marker(props.filter(Markup.command_timing_export))) |
| 83259 | 220 |
} |
221 |
||
222 |
nodes_changed += state_id |
|
223 |
nodes_delay.invoke() |
|
224 |
} |
|
| 83258 | 225 |
} |
226 |
||
| 77474 | 227 |
class Session_Job private[Build_Job]( |
| 78421 | 228 |
build_context: Build.Context, |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
229 |
session_context: Session_Context, |
| 77505 | 230 |
progress: Progress, |
231 |
log: Logger, |
|
| 78372 | 232 |
server: SSH.Server, |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
233 |
session_background: Sessions.Background, |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
234 |
sources_shasum: SHA1.Shasum, |
|
77460
ccca589d7027
tuned signature: support general Build_Job instances;
wenzelm
parents:
77458
diff
changeset
|
235 |
input_shasum: SHA1.Shasum, |
|
78237
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
236 |
node_info: Host.Node_Info, |
|
c2c59de57df9
clarified static Build_Process.Context vs. dynamic Build_Process.State;
wenzelm
parents:
78213
diff
changeset
|
237 |
store_heap: Boolean |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
238 |
) extends Build_Job {
|
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
239 |
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
|
240 |
|
|
79887
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
241 |
private val future_result: Future[Result] = |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
242 |
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
|
243 |
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
|
244 |
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
|
245 |
val store = build_context.store |
|
cb0a90df4871
prefer asynchronous operations: reduce time spent within synchronized_database("Build_Process.start_job");
wenzelm
parents:
78280
diff
changeset
|
246 |
|
| 78372 | 247 |
using_optional(store.maybe_open_database_server(server = server)) { database_server =>
|
248 |
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
|
249 |
|
| 78372 | 250 |
val session_sources = |
251 |
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
|
252 |
|
| 78372 | 253 |
val env = |
| 82706 | 254 |
Isabelle_System.Settings.env( |
| 78372 | 255 |
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
|
256 |
|
| 78372 | 257 |
val session_heaps = |
258 |
session_background.info.parent match {
|
|
259 |
case None => Nil |
|
| 82752 | 260 |
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
|
261 |
} |
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
262 |
|
| 78372 | 263 |
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
|
264 |
|
| 78372 | 265 |
val eval_store = |
266 |
if (store_heap) {
|
|
267 |
(if (info.theories.nonEmpty) List("ML_Heap.share_common_data ()") else Nil) :::
|
|
268 |
List("ML_Heap.save_child " +
|
|
269 |
ML_Syntax.print_string_bytes(File.platform_path(store.output_heap(session_name)))) |
|
270 |
} |
|
271 |
else Nil |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
272 |
|
| 78372 | 273 |
def session_blobs(node_name: Document.Node.Name): List[(Command.Blob, Document.Blobs.Item)] = |
274 |
session_background.base.theory_load_commands.get(node_name.theory) match {
|
|
275 |
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
|
276 |
case Some(load_commands) => |
| 78372 | 277 |
val syntax = session_background.base.theory_syntax(node_name) |
278 |
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
|
279 |
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
|
280 |
(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
|
281 |
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
|
282 |
} yield {
|
| 78372 | 283 |
val src_path = Path.explode(file) |
284 |
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
|
285 |
|
| 78372 | 286 |
val bytes = session_sources(blob_name.node).bytes |
287 |
val text = bytes.text |
|
288 |
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
|
289 |
val content = Some((SHA1.digest(bytes), chunk)) |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
290 |
|
|
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
|
291 |
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
|
292 |
Document.Blobs.Item(bytes, text, chunk, command_offset = command_offset) |
| 78372 | 293 |
} |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
294 |
} |
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
295 |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
296 |
|
| 78372 | 297 |
/* session */ |
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
298 |
|
|
82744
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
299 |
val session = |
| 83259 | 300 |
new Build_Session(progress) {
|
| 82780 | 301 |
override def session_options: Options = options |
302 |
||
|
82769
7cb5ef6da1f0
proper build_context.store, instead of circular null value (amending 0e36478a1b6a and e891ff63e6db);
wenzelm
parents:
82752
diff
changeset
|
303 |
override val store: Store = build_context.store |
|
82750
0e36478a1b6a
clarified signature: Session always provides Store (with Rich_Text.Cache);
wenzelm
parents:
82744
diff
changeset
|
304 |
|
|
82744
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
305 |
override val resources: Resources = |
|
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
306 |
new Resources(session_background, log = log, |
|
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
307 |
command_timings = |
|
82750
0e36478a1b6a
clarified signature: Session always provides Store (with Rich_Text.Cache);
wenzelm
parents:
82744
diff
changeset
|
308 |
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
|
309 |
|
| 78372 | 310 |
override def build_blobs_info(node_name: Document.Node.Name): Command.Blobs_Info = |
311 |
Command.Blobs_Info.make(session_blobs(node_name)) |
|
312 |
||
313 |
override def build_blobs(node_name: Document.Node.Name): Document.Blobs = |
|
314 |
Document.Blobs.make(session_blobs(node_name)) |
|
| 83259 | 315 |
|
316 |
override val nodes_domain: List[Document.Node.Name] = |
|
317 |
session_background.base.used_theories.map(_._1.symbolic_path) |
|
| 78372 | 318 |
} |
319 |
||
320 |
val export_consumer = |
|
321 |
Export.consumer(store.open_database(session_name, output = true, server = server), |
|
322 |
store.cache, progress = progress) |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
323 |
|
| 83204 | 324 |
// mutable state: session.synchronized |
| 78372 | 325 |
val stdout = new StringBuilder(1000) |
326 |
val stderr = new StringBuilder(1000) |
|
| 83249 | 327 |
|
| 78372 | 328 |
def fun( |
329 |
name: String, |
|
| 83262 | 330 |
marker: Protocol_Message.Marker, |
| 78372 | 331 |
unapply: Properties.T => Option[Properties.T] |
332 |
): (String, Session.Protocol_Function) = {
|
|
333 |
name -> ((msg: Prover.Protocol_Output) => |
|
334 |
unapply(msg.properties) match {
|
|
| 83262 | 335 |
case Some(props) => session.write_process_output(marker(props)); true |
| 78372 | 336 |
case _ => false |
337 |
}) |
|
| 77485 | 338 |
} |
339 |
||
| 78372 | 340 |
session.init_protocol_handler(new Session.Protocol_Handler {
|
| 83258 | 341 |
override def exit(): Unit = session.errors_cancel() |
| 78372 | 342 |
|
343 |
private def build_session_finished(msg: Prover.Protocol_Output): Boolean = {
|
|
344 |
val (rc, errors) = |
|
345 |
try {
|
|
346 |
val (rc, errs) = {
|
|
347 |
import XML.Decode._ |
|
| 80463 | 348 |
pair(int, list(self))(Symbol.decode_yxml(msg.text)) |
| 78372 | 349 |
} |
350 |
val errors = |
|
351 |
for (err <- errs) yield {
|
|
| 80872 | 352 |
Pretty.string_of(err, metric = Symbol.Metric, pure = true) |
| 78372 | 353 |
} |
354 |
(rc, errors) |
|
355 |
} |
|
356 |
catch { case ERROR(err) => (Process_Result.RC.failure, List(err)) }
|
|
357 |
||
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
358 |
session.protocol_command("Prover.stop", XML.Encode.int(rc))
|
| 83258 | 359 |
session.errors(errors) |
| 78372 | 360 |
true |
361 |
} |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
362 |
|
| 78372 | 363 |
private def loading_theory(msg: Prover.Protocol_Output): Boolean = |
364 |
msg.properties match {
|
|
365 |
case Markup.Loading_Theory(Markup.Name(name)) => |
|
366 |
progress.theory(Progress.Theory(name, session = session_name)) |
|
367 |
false |
|
368 |
case _ => false |
|
369 |
} |
|
370 |
||
371 |
private def export_(msg: Prover.Protocol_Output): Boolean = |
|
372 |
msg.properties match {
|
|
373 |
case Protocol.Export(args) => |
|
374 |
export_consumer.make_entry(session_name, args, msg.chunk) |
|
375 |
true |
|
376 |
case _ => false |
|
377 |
} |
|
378 |
||
379 |
override val functions: Session.Protocol_Functions = |
|
380 |
List( |
|
381 |
Markup.Build_Session_Finished.name -> build_session_finished, |
|
382 |
Markup.Loading_Theory.name -> loading_theory, |
|
383 |
Markup.EXPORT -> export_, |
|
| 83262 | 384 |
fun(Markup.Session_Timing.name, |
385 |
Protocol.Session_Timing_Marker, Markup.Session_Timing.unapply), |
|
386 |
fun(Markup.Task_Statistics.name, |
|
387 |
Protocol.Task_Statistics_Marker, Markup.Task_Statistics.unapply)) |
|
| 78372 | 388 |
}) |
389 |
||
390 |
session.command_timings += Session.Consumer("command_timings") {
|
|
| 83259 | 391 |
case Session.Command_Timing(state_id, props) => session.command_timing(state_id, props) |
| 78372 | 392 |
} |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
393 |
|
| 78372 | 394 |
session.runtime_statistics += Session.Consumer("ML_statistics") {
|
| 83260 | 395 |
case Session.Runtime_Statistics(props) => |
| 83262 | 396 |
session.write_process_output(Protocol.ML_Statistics_Marker(props)) |
| 78372 | 397 |
} |
398 |
||
399 |
session.finished_theories += Session.Consumer[Document.Snapshot]("finished_theories") {
|
|
400 |
case snapshot => |
|
401 |
if (!progress.stopped) {
|
|
402 |
def export_(name: String, xml: XML.Body, compress: Boolean = true): Unit = {
|
|
403 |
if (!progress.stopped) {
|
|
404 |
val theory_name = snapshot.node_name.theory |
|
405 |
val args = |
|
| 79692 | 406 |
Protocol.Export.Args( |
407 |
theory_name = theory_name, name = name, compress = compress) |
|
|
80437
2c07b9b2f9f4
minor performance tuning: more direct Bytes with Symbol.encode;
wenzelm
parents:
80270
diff
changeset
|
408 |
val body = YXML.bytes_of_body(xml, recode = Symbol.encode) |
| 78372 | 409 |
export_consumer.make_entry(session_name, args, body) |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
410 |
} |
| 78372 | 411 |
} |
412 |
def export_text(name: String, text: String, compress: Boolean = true): Unit = |
|
413 |
export_(name, List(XML.Text(text)), compress = compress) |
|
414 |
||
|
82741
0c83a22d8556
more robust: assertion holds, because session.finished_theories provides Snapshot from Document.State.end_theory;
wenzelm
parents:
82706
diff
changeset
|
415 |
assert(snapshot.snippet_commands.length == 1) |
|
81414
ed4ff84e9b21
Document.Snapshot: support for multiple snippet_commands;
wenzelm
parents:
80872
diff
changeset
|
416 |
for (command <- snapshot.snippet_commands) {
|
| 78372 | 417 |
export_text(Export.DOCUMENT_ID, command.id.toString, compress = false) |
418 |
} |
|
419 |
||
|
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
|
420 |
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
|
421 |
{
|
|
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 |
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
|
423 |
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
|
424 |
}) |
| 78372 | 425 |
|
426 |
for ((blob_name, i) <- snapshot.node_files.tail.zipWithIndex) {
|
|
427 |
val xml = snapshot.switch(blob_name).xml_markup() |
|
428 |
export_(Export.MARKUP + (i + 1), xml) |
|
429 |
} |
|
430 |
export_(Export.MARKUP, snapshot.xml_markup()) |
|
431 |
export_(Export.MESSAGES, snapshot.messages.map(_._1)) |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
432 |
} |
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
433 |
} |
| 78372 | 434 |
|
435 |
session.all_messages += Session.Consumer[Any]("build_session_output") {
|
|
436 |
case msg: Prover.Output => |
|
437 |
val message = msg.message |
|
|
82744
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
438 |
if (msg.is_system) session.resources.log(Protocol.message_text(message)) |
| 78372 | 439 |
|
440 |
if (msg.is_stdout) {
|
|
| 83204 | 441 |
session.synchronized { stdout ++= Symbol.encode(XML.content(message)) }
|
| 78372 | 442 |
} |
443 |
else if (msg.is_stderr) {
|
|
| 83204 | 444 |
session.synchronized { stderr ++= Symbol.encode(XML.content(message)) }
|
| 78372 | 445 |
} |
446 |
else if (msg.is_exit) {
|
|
| 83259 | 447 |
session.nodes_status_sync() |
| 78372 | 448 |
val err = |
449 |
"Prover terminated" + |
|
450 |
(msg.properties match {
|
|
451 |
case Markup.Process_Result(result) => ": " + result.print_rc |
|
452 |
case _ => "" |
|
453 |
}) |
|
| 83258 | 454 |
session.errors(List(err)) |
| 78372 | 455 |
} |
456 |
case _ => |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
457 |
} |
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
458 |
|
| 78372 | 459 |
build_context.session_setup(session_name, session) |
460 |
||
461 |
val eval_main = Command_Line.ML_tool("Isabelle_Process.init_build ()" :: eval_store)
|
|
462 |
||
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
463 |
|
| 78372 | 464 |
/* process */ |
465 |
||
466 |
val process = |
|
467 |
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
|
468 |
use_prelude = use_prelude, eval_main = eval_main, cwd = info.dir, env = env) |
| 78372 | 469 |
|
470 |
val timeout_request: Option[Event_Timer.Request] = |
|
471 |
if (info.timeout_ignored) None |
|
472 |
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
|
473 |
|
| 78372 | 474 |
val build_errors = |
475 |
Isabelle_Thread.interrupt_handler(_ => process.terminate()) {
|
|
476 |
Exn.capture { process.await_startup() } match {
|
|
477 |
case Exn.Res(_) => |
|
|
82744
0ca8b1861fa3
clarified signature: more explicit subtypes of Session, with corresponding subtypes of Resources;
wenzelm
parents:
82742
diff
changeset
|
478 |
val resources_xml = session.resources.init_session_xml |
| 78372 | 479 |
val encode_options: XML.Encode.T[Options] = |
480 |
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
|
481 |
val args_xml = |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
482 |
{
|
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
483 |
import XML.Encode._ |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
484 |
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
|
485 |
(session_name, info.theories)) |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
486 |
} |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
80437
diff
changeset
|
487 |
session.protocol_command("build_session", resources_xml, args_xml)
|
| 83258 | 488 |
session.errors_result() |
| 78372 | 489 |
case Exn.Exn(exn) => Exn.Res(List(Exn.message(exn))) |
490 |
} |
|
491 |
} |
|
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
492 |
|
| 78372 | 493 |
val result0 = |
494 |
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
|
495 |
|
| 78372 | 496 |
val was_timeout = |
497 |
timeout_request match {
|
|
498 |
case None => false |
|
499 |
case Some(request) => !request.cancel() |
|
500 |
} |
|
501 |
||
502 |
session.stop() |
|
|
83209
a39fde2f020a
basic setup for build progress with nodes_status;
wenzelm
parents:
83207
diff
changeset
|
503 |
|
| 78372 | 504 |
val export_errors = |
505 |
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
|
506 |
|
| 78372 | 507 |
val (document_output, document_errors) = |
508 |
try {
|
|
| 78674 | 509 |
if (Exn.is_res(build_errors) && result0.ok && info.documents.nonEmpty) {
|
| 78379 | 510 |
using(Export.open_database_context(store, server = server)) { database_context =>
|
| 78372 | 511 |
val documents = |
512 |
using(database_context.open_session(session_background)) {
|
|
513 |
session_context => |
|
514 |
Document_Build.build_documents( |
|
515 |
Document_Build.context(session_context, progress = progress), |
|
516 |
output_sources = info.document_output, |
|
517 |
output_pdf = info.document_output) |
|
518 |
} |
|
| 79692 | 519 |
using(database_context.open_database(session_name, output = true))( |
520 |
session_database => |
|
521 |
documents.foreach(_.write(session_database.db, session_name))) |
|
| 78372 | 522 |
(documents.flatMap(_.log_lines), Nil) |
523 |
} |
|
| 77484 | 524 |
} |
| 78372 | 525 |
else (Nil, Nil) |
526 |
} |
|
527 |
catch {
|
|
528 |
case exn: Document_Build.Build_Error => (exn.log_lines, exn.log_errors) |
|
529 |
case Exn.Interrupt.ERROR(msg) => (Nil, List(msg)) |
|
530 |
} |
|
| 77485 | 531 |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
532 |
|
| 78372 | 533 |
/* process result */ |
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
534 |
|
| 78372 | 535 |
val result1 = {
|
536 |
val more_output = |
|
| 83204 | 537 |
session.synchronized {
|
538 |
Library.trim_line(stdout.toString) :: |
|
| 83262 | 539 |
session.read_process_output() ::: |
| 83204 | 540 |
document_output |
541 |
} |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
542 |
|
| 78372 | 543 |
result0.output(more_output) |
544 |
.error(Library.trim_line(stderr.toString)) |
|
545 |
.errors_rc(export_errors ::: document_errors) |
|
546 |
} |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
547 |
|
| 78372 | 548 |
val result2 = |
549 |
build_errors match {
|
|
550 |
case Exn.Res(build_errs) => |
|
551 |
val errs = build_errs ::: document_errors |
|
552 |
if (errs.nonEmpty) {
|
|
553 |
result1.error_rc.output( |
|
554 |
errs.flatMap(s => split_lines(Output.error_message_text(s))) ::: |
|
555 |
errs.map(Protocol.Error_Message_Marker.apply)) |
|
556 |
} |
|
| 79692 | 557 |
else if (progress.stopped && result1.ok) {
|
558 |
result1.copy(rc = Process_Result.RC.interrupt) |
|
559 |
} |
|
| 78372 | 560 |
else result1 |
561 |
case Exn.Exn(Exn.Interrupt()) => |
|
562 |
if (result1.ok) result1.copy(rc = Process_Result.RC.interrupt) |
|
563 |
else result1 |
|
564 |
case Exn.Exn(exn) => throw exn |
|
565 |
} |
|
566 |
||
567 |
val process_result = |
|
568 |
if (result2.ok) result2 |
|
569 |
else if (was_timeout) result2.error(Output.error_message_text("Timeout")).timeout_rc
|
|
570 |
else if (result2.interrupted) result2.error(Output.error_message_text("Interrupt"))
|
|
571 |
else result2 |
|
572 |
||
|
79691
d298c5b65d8e
clarified store_session: heap requires process_result.ok, but log_db is always stored;
wenzelm
parents:
79682
diff
changeset
|
573 |
val store_session = |
|
d298c5b65d8e
clarified store_session: heap requires process_result.ok, but log_db is always stored;
wenzelm
parents:
79682
diff
changeset
|
574 |
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
|
575 |
|
| 83262 | 576 |
session.clean_process_output() |
577 |
||
| 78372 | 578 |
|
579 |
/* output heap */ |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
580 |
|
|
79682
1fa1b32b0379
build local log_db, with store/restore via optional database server;
wenzelm
parents:
79678
diff
changeset
|
581 |
val output_shasum = |
|
1fa1b32b0379
build local log_db, with store/restore via optional database server;
wenzelm
parents:
79678
diff
changeset
|
582 |
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
|
583 |
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
|
584 |
case None => SHA1.no_shasum |
| 78372 | 585 |
} |
586 |
||
587 |
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
|
588 |
|
| 78372 | 589 |
val build_log = |
|
78985
24e686fe043e
clarified Log_File.cache: reuse existing Store.cache / Build_Log.Store.cache;
wenzelm
parents:
78842
diff
changeset
|
590 |
Build_Log.Log_File(session_name, process_result.out_lines, cache = store.cache). |
| 78372 | 591 |
parse_session_info( |
592 |
command_timings = true, |
|
593 |
theory_timings = true, |
|
594 |
ml_statistics = true, |
|
595 |
task_statistics = true) |
|
596 |
||
597 |
// write log file |
|
598 |
if (process_result.ok) {
|
|
599 |
File.write_gzip(store.output_log_gz(session_name), terminate_lines(log_lines)) |
|
600 |
} |
|
601 |
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
|
602 |
|
| 78372 | 603 |
// write database |
| 78374 | 604 |
def write_info(db: SQL.Database): Unit = |
| 78372 | 605 |
store.write_session_info(db, session_name, session_sources, |
606 |
build_log = |
|
607 |
if (process_result.timeout) build_log.error("Timeout") else build_log,
|
|
608 |
build = |
|
609 |
Store.Build_Info( |
|
610 |
sources = sources_shasum, |
|
611 |
input_heaps = input_shasum, |
|
612 |
output_heap = output_shasum, |
|
613 |
process_result.rc, |
|
| 78374 | 614 |
build_context.build_uuid)) |
|
78529
0e79fa88cab6
build_worker is stopped independently from master build_process;
wenzelm
parents:
78435
diff
changeset
|
615 |
|
|
79887
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
616 |
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
|
617 |
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
|
618 |
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
|
619 |
} |
| 78372 | 620 |
|
| 80121 | 621 |
store.in_heaps_database( |
622 |
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
|
623 |
|
| 78372 | 624 |
// messages |
625 |
process_result.err_lines.foreach(progress.echo(_)) |
|
626 |
||
627 |
if (process_result.ok) {
|
|
628 |
val props = build_log.session_timing |
|
629 |
val threads = Markup.Session_Timing.Threads.unapply(props) getOrElse 1 |
|
630 |
val timing = Markup.Timing_Properties.get(props) |
|
631 |
progress.echo( |
|
632 |
"Timing " + session_name + " (" + threads + " threads, " + timing.message_factor + ")",
|
|
633 |
verbose = true) |
|
634 |
progress.echo( |
|
635 |
"Finished " + session_name + " (" + process_result.timing.message_resources + ")")
|
|
636 |
} |
|
637 |
else {
|
|
638 |
progress.echo( |
|
| 79692 | 639 |
session_name + " FAILED (see also \"isabelle build_log -H Error " + |
640 |
session_name + "\")") |
|
| 78372 | 641 |
if (!process_result.interrupted) {
|
642 |
val tail = info.options.int("process_output_tail")
|
|
| 79692 | 643 |
val suffix = |
644 |
if (tail == 0) log_lines else log_lines.drop(log_lines.length - tail max 0) |
|
645 |
val prefix = |
|
646 |
if (log_lines.length == suffix.length) Nil else List("...")
|
|
| 78372 | 647 |
progress.echo(Library.trim_line(cat_lines(prefix ::: suffix))) |
648 |
} |
|
649 |
} |
|
650 |
||
|
79887
17220dc05991
revert most parts of 0e79fa88cab6: somewhat ambitious attempt to move towards "editing" builds via added/canceled workers;
wenzelm
parents:
79718
diff
changeset
|
651 |
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
|
652 |
} |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
653 |
} |
|
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
654 |
|
|
77486
032c76e04475
clarified execution context: main work happens within Future.thread;
wenzelm
parents:
77485
diff
changeset
|
655 |
override def cancel(): Unit = future_result.cancel() |
| 77298 | 656 |
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
|
657 |
override def join: Result = future_result.join |
|
77297
226a880d0423
clarified types: support a variety of Build_Job instances;
wenzelm
parents:
77294
diff
changeset
|
658 |
} |
|
72848
d5d0e36eda16
read theory with PIDE markup from session database;
wenzelm
parents:
72844
diff
changeset
|
659 |
} |