diff options
author | Harmen Stoppels <me@harmenstoppels.nl> | 2023-10-30 15:29:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-30 15:29:27 +0100 |
commit | b1b8500ebaf1387913220925f129f635fa9c1f66 (patch) | |
tree | cf662a542a2c1f996d1fdd685b228bb6ce3f8c97 | |
parent | 060a1ff2f3261f94e3137e43ac8c50534983b63b (diff) | |
download | spack-b1b8500ebaf1387913220925f129f635fa9c1f66.tar.gz spack-b1b8500ebaf1387913220925f129f635fa9c1f66.tar.bz2 spack-b1b8500ebaf1387913220925f129f635fa9c1f66.tar.xz spack-b1b8500ebaf1387913220925f129f635fa9c1f66.zip |
ci: print colored specs in concretization progress (#40711)
-rw-r--r-- | lib/spack/spack/ci.py | 44 | ||||
-rw-r--r-- | lib/spack/spack/environment/environment.py | 5 | ||||
-rw-r--r-- | lib/spack/spack/spec.py | 12 | ||||
-rw-r--r-- | share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml | 4 |
4 files changed, 33 insertions, 32 deletions
diff --git a/lib/spack/spack/ci.py b/lib/spack/spack/ci.py index cda7a622d6..afad3b7a45 100644 --- a/lib/spack/spack/ci.py +++ b/lib/spack/spack/ci.py @@ -25,6 +25,7 @@ from urllib.request import HTTPHandler, Request, build_opener import llnl.util.filesystem as fs import llnl.util.tty as tty from llnl.util.lang import memoized +from llnl.util.tty.color import cescape, colorize import spack import spack.binary_distribution as bindist @@ -97,15 +98,6 @@ def _remove_reserved_tags(tags): return [tag for tag in tags if tag not in SPACK_RESERVED_TAGS] -def _get_spec_string(spec): - format_elements = ["{name}{@version}", "{%compiler}"] - - if spec.architecture: - format_elements.append(" {arch=architecture}") - - return spec.format("".join(format_elements)) - - def _spec_deps_key(s): return "{0}/{1}".format(s.name, s.dag_hash(7)) @@ -210,22 +202,22 @@ def _print_staging_summary(spec_labels, stages, mirrors_to_check, rebuild_decisi tty.msg("Staging summary ([x] means a job needs rebuilding):") for stage_index, stage in enumerate(stages): - tty.msg(" stage {0} ({1} jobs):".format(stage_index, len(stage))) + tty.msg(f" stage {stage_index} ({len(stage)} jobs):") - for job in sorted(stage): + for job in sorted(stage, key=lambda j: (not rebuild_decisions[j].rebuild, j)): s = spec_labels[job] - rebuild = rebuild_decisions[job].rebuild reason = rebuild_decisions[job].reason - reason_msg = " ({0})".format(reason) if reason else "" - tty.msg( - " [{1}] {0} -> {2}{3}".format( - job, "x" if rebuild else " ", _get_spec_string(s), reason_msg - ) - ) - if rebuild_decisions[job].mirrors: - tty.msg(" found on the following mirrors:") - for murl in rebuild_decisions[job].mirrors: - tty.msg(" {0}".format(murl)) + reason_msg = f" ({reason})" if reason else "" + spec_fmt = "{name}{@version}{%compiler}{/hash:7}" + if rebuild_decisions[job].rebuild: + status = colorize("@*g{[x]} ") + msg = f" {status}{s.cformat(spec_fmt)}{reason_msg}" + else: + msg = f"{s.format(spec_fmt)}{reason_msg}" + if rebuild_decisions[job].mirrors: + msg += f" [{', '.join(rebuild_decisions[job].mirrors)}]" + msg = colorize(f" @K - {cescape(msg)}@.") + tty.msg(msg) def _compute_spec_deps(spec_list): @@ -2258,13 +2250,13 @@ class CDashHandler: spec.architecture, self.build_group, ) - tty.verbose( + tty.debug( "Generated CDash build name ({0}) from the {1}".format(build_name, spec.name) ) return build_name build_name = os.environ.get("SPACK_CDASH_BUILD_NAME") - tty.verbose("Using CDash build name ({0}) from the environment".format(build_name)) + tty.debug("Using CDash build name ({0}) from the environment".format(build_name)) return build_name @property # type: ignore @@ -2278,11 +2270,11 @@ class CDashHandler: Returns: (str) current CDash build stamp""" build_stamp = os.environ.get("SPACK_CDASH_BUILD_STAMP") if build_stamp: - tty.verbose("Using build stamp ({0}) from the environment".format(build_stamp)) + tty.debug("Using build stamp ({0}) from the environment".format(build_stamp)) return build_stamp build_stamp = cdash_build_stamp(self.build_group, time.time()) - tty.verbose("Generated new build stamp ({0})".format(build_stamp)) + tty.debug("Generated new build stamp ({0})".format(build_stamp)) return build_stamp @property # type: ignore diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index 0b36351d4e..9998161df2 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -1525,7 +1525,10 @@ class Environment: ): batch.append((i, concrete)) percentage = (j + 1) / len(args) * 100 - tty.verbose(f"{duration:6.1f}s [{percentage:3.0f}%] {root_specs[i]}") + tty.verbose( + f"{duration:6.1f}s [{percentage:3.0f}%] {concrete.cformat('{hash:7}')} " + f"{root_specs[i].colored_str}" + ) sys.stdout.flush() # Add specs in original order diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 3f3056d0fa..6030ff2681 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -4491,10 +4491,16 @@ class Spec: def __str__(self): sorted_nodes = [self] + sorted( - self.traverse(root=False), key=lambda x: x.name or x.abstract_hash + self.traverse(root=False), key=lambda x: (x.name, x.abstract_hash) ) - spec_str = " ^".join(d.format() for d in sorted_nodes) - return spec_str.strip() + return " ^".join(d.format() for d in sorted_nodes).strip() + + @property + def colored_str(self): + sorted_nodes = [self] + sorted( + self.traverse(root=False), key=lambda x: (x.name, x.abstract_hash) + ) + return " ^".join(d.cformat() for d in sorted_nodes).strip() def install_status(self): """Helper for tree to print DB install status.""" diff --git a/share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml b/share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml index e5475a7bdc..196037585f 100644 --- a/share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml +++ b/share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml @@ -150,7 +150,7 @@ default: - spack python -c "import os,sys; print(os.path.expandvars(sys.stdin.read()))" < "${SPACK_CI_CONFIG_ROOT}/${PIPELINE_MIRROR_TEMPLATE}" > "${SPACK_CI_CONFIG_ROOT}/mirrors.yaml" - spack config add -f "${SPACK_CI_CONFIG_ROOT}/mirrors.yaml" - - spack -v + - spack -v --color=always --config-scope "${SPACK_CI_CONFIG_ROOT}" --config-scope "${SPACK_CI_CONFIG_ROOT}/${SPACK_TARGET_PLATFORM}" --config-scope "${SPACK_CI_CONFIG_ROOT}/${SPACK_TARGET_PLATFORM}/${SPACK_TARGET_ARCH}" @@ -203,7 +203,7 @@ default: - spack --version - cd share/spack/gitlab/cloud_pipelines/stacks/${SPACK_CI_STACK_NAME} - spack env activate --without-view . - - spack -v + - spack -v --color=always ci generate --check-index-only --buildcache-destination "${PUSH_BUILDCACHE_DEPRECATED}" --artifacts-root "${CI_PROJECT_DIR}/jobs_scratch_dir" |