Skip to content

Commit

Permalink
Cache reports variant.qualified_name and removed _print_with_spinner()
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Andersen <ben@isohedron.com.au>
  • Loading branch information
isohedronpipeline committed May 9, 2024
1 parent 2253d76 commit 1c6c94b
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/rez/package_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from rez.config import config
from rez.exceptions import PackageCacheError
from rez.vendor.lockfile import LockFile, NotLocked
from rez.vendor.progress.spinner import PixelSpinner
from rez.utils.filesystem import safe_listdir, safe_makedirs, safe_remove, \
forceful_rmtree
from rez.utils.colorize import ColorizedStreamHandler
Expand Down Expand Up @@ -241,31 +242,28 @@ def add_variant(self, variant, force=False, wait_for_copying=False, logger=None)
status, rootpath = self._get_cached_root(variant)
if status in no_op_statuses:
if logger:
logger.warning(f"Not caching {variant.name}-{variant.version}. "
logger.warning(f"Not caching {variant.qualified_name}. "
f"Variant {self.STATUS_DESCRIPTIONS[status]}")
return (rootpath, status)

if wait_for_copying and status == self.VARIANT_COPYING:
ticks = 0
spinner = PixelSpinner(f"Waiting for {variant.qualified_name} to finish copying. ")
while status == self.VARIANT_COPYING:
self._print_with_spinner(
f"Waiting for {variant.name}-{variant.version} to finish copying.", ticks)
ticks += 1

spinner.next()
time.sleep(self._COPYING_TIME_INC)
status, rootpath = self._get_cached_root(variant)
else:
# Status has changed, so report the change and return
if logger:
if status in no_op_statuses:
logger.warning(f"{variant.name}-{variant.version} "
logger.warning(f"{variant.qualified_name} "
f"{self.STATUS_DESCRIPTIONS[status]}")
elif status == self.VARIANT_FOUND:
# We have resolved into a satisfactory state
logger.info(f"{variant.name}-{variant.version} "
logger.info(f"{variant.qualified_name} "
f"{self.STATUS_DESCRIPTIONS[status]}")
else:
logger.warning(f"{variant.name}-{variant.version} "
logger.warning(f"{variant.qualified_name} "
f"{self.STATUS_DESCRIPTIONS[status]}")
return (rootpath, status)

Expand Down Expand Up @@ -957,13 +955,3 @@ def _get_hash_path(self, variant):
dirs.append(hash_dirname)

return os.path.join(*dirs)

@staticmethod
def _print_with_spinner(message, ticks):
"""
Report a message with a spinner wheel to indicate progress.
"""
wheel = "⣾⣽⣻⢿⡿⣟⣯⣷"
ticks = ticks % len(wheel)
spinner = wheel[ticks:1 + ticks]
print(f" {spinner} {message}", end="\r")

0 comments on commit 1c6c94b

Please sign in to comment.