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