pipeline: replace tree_id with id

Now that `Pipelines` have no assemblers anymore and thus only one
identifier, i.e. the one corresponding to the tree (`tree_id`),
the `id` and `tree_id` are now the same. Therefore replace the
usage of `tree_id` with `id` and drop the former. Add some extra
documentation including some caveats about the uniquness of `id`.
This commit is contained in:
Christian Kellner 2021-01-22 10:35:46 +00:00
parent 53e9ec850b
commit c6432d0adb
2 changed files with 16 additions and 9 deletions

View file

@ -49,7 +49,7 @@ def describe(manifest: Manifest, *, with_id=False) -> Dict:
def load_assembler(description: Dict, index: Index, manifest: Manifest):
pipeline = manifest["tree"]
build, base, runner = pipeline.build, pipeline.tree_id, pipeline.runner
build, base, runner = pipeline.build, pipeline.id, pipeline.runner
name, options = description["name"], description.get("options", {})
# Add a pipeline with one stage for our assembler
@ -93,7 +93,7 @@ def load_pipeline(description: Dict, index: Index, manifest: Manifest, n: int =
else:
name = "-".join(["build"] * n)
build_id = build_pipeline and build_pipeline.tree_id
build_id = build_pipeline and build_pipeline.id
pipeline = manifest.add_pipeline(name, runner, build_id)
for s in description.get("stages", []):
@ -128,7 +128,7 @@ def load(description: Dict, index: Index) -> Manifest:
def get_ids(manifest: Manifest) -> Tuple[Optional[str], Optional[str]]:
pipeline = manifest["tree"]
assembler = manifest.get("assembler")
return pipeline.tree_id, assembler and assembler.tree_id
return pipeline.id, assembler and assembler.id
def output(manifest: Manifest, res: Dict) -> Dict:

View file

@ -122,14 +122,21 @@ class Pipeline:
@property
def id(self):
return self.tree_id
"""
Pipeline id: corresponds to the `id` of the last stage
@property
def tree_id(self):
In contrast to `name` this identifies the pipeline via
the tree, i.e. the content, it produces. Therefore two
pipelines that produce the same `tree`, i.e. have the
same exact stages and build pipeline, will have the
same `id`; thus the `id`, in contrast to `name` does
not uniquely identify a pipeline.
In case a Pipeline has no stages, its `id` is `None`.
"""
return self.stages[-1].id if self.stages else None
def add_stage(self, info, options, sources_options=None):
stage = Stage(info, sources_options, self.build, self.tree_id, options or {})
stage = Stage(info, sources_options, self.build, self.id, options or {})
self.stages.append(stage)
if self.assembler:
self.assembler.base = stage.id
@ -160,7 +167,7 @@ class Pipeline:
# Check if the tree that we are supposed to build does
# already exist. If so, short-circuit here
tree = object_store.get(self.tree_id)
tree = object_store.get(self.id)
if tree:
return results, build_tree, tree
@ -222,7 +229,7 @@ class Pipeline:
# tree exists, we return it as well, but we do not care if it is
# missing, since it is not a mandatory part of the result and would
# usually be needless overhead.
obj = store.get(self.tree_id)
obj = store.get(self.id)
if not obj:
results, _, obj = self.build_stages(store, monitor, libdir)