gtristan commented on code in PR #1994:
URL: https://github.com/apache/buildstream/pull/1994#discussion_r2003037269


##########
src/buildstream/_frontend/widget.py:
##########
@@ -437,6 +437,21 @@ def show_pipeline(self, dependencies, format_):
                 runtime_deps = [e._get_full_name() for e in 
element._dependencies(_Scope.RUN, recurse=False)]
                 line = p.fmt_subst(line, "runtime-deps", 
_yaml.roundtrip_dump_string(runtime_deps).rstrip("\n"))
 
+            # Artifact CAS Digest
+            if "%{artifact-cas-digest" in format_:
+                artifact = element._get_artifact()
+                if not artifact.query_cache():
+                    artifact = None
+                if artifact is not None:
+                    artifact_files = artifact.get_files()
+                    # We call the private CasBasedDirectory._get_digest() for
+                    # the moment, we should make it public on Directory.
+                    artifact_digest = artifact_files._get_digest()
+                    formated_artifact_digest = 
"{}/{}".format(artifact_digest.hash, artifact_digest.size_bytes)
+                    line = p.fmt_subst(line, "artifact-cas-digest", 
formated_artifact_digest)
+                else:
+                    line = p.fmt_subst(line, "artifact-cas-digest", "(no 
artifact CAS digest)", fg="yellow")

Review Comment:
   I think that this should output an empty string rather than a user readable 
indicator.
   
   This is expected to be usable as an interface for scripting with, and I 
expect that an empty string is easier to distinguish a non-existent digest 
compared to a human readable output in stderr.
   
   Instead we could consider a user facing log. i.e. we could call 
`Plugin.warn()` here and say `element.warn("Cannot obtain CAS digest because 
artifact is not cached")`, or better yet we could collect all of the elements 
that are not cached and issue a single warning message.
   
   The difference is that warnings and logs are sent to `stderr` and are 
considered "UI" and as such do not interfere with scripting output.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to