Skip to content

Commit

Permalink
ci: print colored specs in concretization progress (spack#40711)
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie authored Oct 30, 2023
1 parent 060a1ff commit b1b8500
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 32 deletions.
44 changes: 18 additions & 26 deletions lib/spack/spack/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -2258,13 +2250,13 @@ def build_name(self):
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
Expand All @@ -2278,11 +2270,11 @@ def build_stamp(self):
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
Expand Down
5 changes: 4 additions & 1 deletion lib/spack/spack/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,10 @@ def _concretize_separately(self, tests=False):
):
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
Expand Down
12 changes: 9 additions & 3 deletions lib/spack/spack/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -4491,10 +4491,16 @@ def format_path(

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."""
Expand Down
4 changes: 2 additions & 2 deletions share/spack/gitlab/cloud_pipelines/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit b1b8500

Please sign in to comment.