pipeline: unify object exporting
Remove output.export and associated logic in pipeline.assemble. Instead, return output or None, and export only once in pipeline.run.
This commit is contained in:
parent
fc0c75f40e
commit
b1229de56e
1 changed files with 16 additions and 19 deletions
|
|
@ -284,11 +284,11 @@ class Pipeline:
|
||||||
|
|
||||||
return results, build_tree, tree
|
return results, build_tree, tree
|
||||||
|
|
||||||
def assemble(self, object_store, build_tree, tree, monitor, libdir, output_directory):
|
def assemble(self, object_store, build_tree, tree, monitor, libdir):
|
||||||
results = {"success": True}
|
results = {"success": True}
|
||||||
|
|
||||||
if not self.assembler:
|
if not self.assembler:
|
||||||
return results
|
return results, None
|
||||||
|
|
||||||
output = object_store.new()
|
output = object_store.new()
|
||||||
|
|
||||||
|
|
@ -312,19 +312,16 @@ class Pipeline:
|
||||||
if not r.success:
|
if not r.success:
|
||||||
output.cleanup()
|
output.cleanup()
|
||||||
results["success"] = False
|
results["success"] = False
|
||||||
return results
|
return results, None
|
||||||
|
|
||||||
if self.assembler.checkpoint:
|
if self.assembler.checkpoint:
|
||||||
object_store.commit(output, self.assembler.id)
|
object_store.commit(output, self.assembler.id)
|
||||||
if output_directory:
|
|
||||||
output.export(output_directory)
|
|
||||||
output.cleanup()
|
|
||||||
|
|
||||||
return results
|
return results, output
|
||||||
|
|
||||||
def run(self, store, monitor, libdir, output_directory):
|
def run(self, store, monitor, libdir, output_directory):
|
||||||
os.makedirs("/run/osbuild", exist_ok=True)
|
os.makedirs("/run/osbuild", exist_ok=True)
|
||||||
results = {}
|
results = {"success": True}
|
||||||
|
|
||||||
monitor.begin(self)
|
monitor.begin(self)
|
||||||
|
|
||||||
|
|
@ -336,11 +333,7 @@ class Pipeline:
|
||||||
# usually be needless overhead.
|
# usually be needless overhead.
|
||||||
obj = object_store.get(self.output_id)
|
obj = object_store.get(self.output_id)
|
||||||
|
|
||||||
if obj:
|
if not obj:
|
||||||
results = {"success": True}
|
|
||||||
obj.export(output_directory)
|
|
||||||
|
|
||||||
else:
|
|
||||||
results, build_tree, tree = self.build_stages(object_store,
|
results, build_tree, tree = self.build_stages(object_store,
|
||||||
monitor,
|
monitor,
|
||||||
libdir)
|
libdir)
|
||||||
|
|
@ -348,15 +341,19 @@ class Pipeline:
|
||||||
if not results["success"]:
|
if not results["success"]:
|
||||||
return results
|
return results
|
||||||
|
|
||||||
r = self.assemble(object_store,
|
r, obj = self.assemble(object_store,
|
||||||
build_tree,
|
build_tree,
|
||||||
tree,
|
tree,
|
||||||
monitor,
|
monitor,
|
||||||
libdir,
|
libdir)
|
||||||
output_directory)
|
|
||||||
|
|
||||||
results.update(r) # This will also update 'success'
|
results.update(r) # This will also update 'success'
|
||||||
|
|
||||||
|
if obj:
|
||||||
|
if output_directory:
|
||||||
|
obj.export(output_directory)
|
||||||
|
obj.cleanup()
|
||||||
|
|
||||||
monitor.finish(results)
|
monitor.finish(results)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue