You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:32:57 UTC

[buildstream] 07/22: WIP: bst-job-replay

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch aevri/win32_minimal_seemstowork_20190829
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 77268116883f49937318388ee846beb292a236d6
Author: Angelos Evripiotis <je...@bloomberg.net>
AuthorDate: Tue Jul 9 11:38:48 2019 +0100

    WIP: bst-job-replay
---
 setup.py                                      |  3 ++-
 src/buildstream/_jobreplay.py                 | 15 +++++++++++++++
 src/buildstream/_scheduler/jobs/jobpickler.py |  4 ++++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index ab3c6f3..af81886 100755
--- a/setup.py
+++ b/setup.py
@@ -152,7 +152,8 @@ bst_install_entry_points = {
 if not os.environ.get('BST_ARTIFACTS_ONLY', ''):
     check_for_bwrap()
     bst_install_entry_points['console_scripts'] += [
-        'bst = buildstream._frontend:cli'
+        'bst = buildstream._frontend:cli',
+        'bst-job-replay = buildstream._jobreplay:cli',
     ]
 
 #####################################################
diff --git a/src/buildstream/_jobreplay.py b/src/buildstream/_jobreplay.py
new file mode 100644
index 0000000..1c05324
--- /dev/null
+++ b/src/buildstream/_jobreplay.py
@@ -0,0 +1,15 @@
+import multiprocessing
+
+import click
+
+from ._scheduler.jobs.job import _unpickle_child_job
+
+
+@click.command(name='bst-job-replay', short_help="Replay a bst job")
+@click.argument('replayfile', type=click.File("rb"))
+def cli(replayfile):
+    job = _unpickle_child_job(replayfile)
+    queue = multiprocessing.Queue()
+    job._queue = queue
+    job._scheduler_context.set_message_handler(job._child_message_handler)
+    job.child_process()
diff --git a/src/buildstream/_scheduler/jobs/jobpickler.py b/src/buildstream/_scheduler/jobs/jobpickler.py
index 5c1742f..3ce2806 100644
--- a/src/buildstream/_scheduler/jobs/jobpickler.py
+++ b/src/buildstream/_scheduler/jobs/jobpickler.py
@@ -143,6 +143,10 @@ def pickle_child_job(child_job, context):
     pickler.dump(child_job)
     data.seek(0)
 
+    path = f"{child_job.action_name}_{child_job._task_id}"
+    with open(path, "wb") as f:
+        f.write(data.getvalue())
+
     return data