Open
Description
It seems that there is no way to determine if the package cache was used to resolve packages from. Repro:
[16:32:26][dkwiek] ~/scratch $> rez-env rez
You are now in a rez-configured environment.
resolved by [email protected], on Fri Apr 07 16:32:28 2023, using Rez v2.88.4
requested packages:
rez
~platform==linux (implicit)
~arch==x86_64 (implicit)
~os==CentOS-7.9 (implicit)
resolved packages:
arch-x86_64 /tmp/rez/cache/rez-pkg-cache/arch/x86_64/761a/a (cached)
os-CentOS-7.9 /tmp/rez/cache/rez-pkg-cache/os/CentOS-7.9/3875/a (cached)
platform-linux /tmp/rez/cache/rez-pkg-cache/platform/linux/36e8/a (cached)
python-3.7.7 /tmp/rez/cache/rez-pkg-cache/python/3.7.7/c2b8/a (cached)
rez-2.88.4 /tmp/rez/cache/rez-pkg-cache/rez/2.88.4/4c68/a (cached)
> [16:32:29][dkwiek] ~/scratch $> python -c "from rez.resolved_context import ResolvedContext; ctx = ResolvedContext.get_current(); print(ctx.resolved_packages)"
[Variant(FileSystemVariantResource({'index': None, 'location': '/software/rez/packages', 'name': 'platform', 'repository_type': 'filesystem', 'version': 'linux'})),
Variant(FileSystemVariantResource({'index': None, 'location': '/software/rez/packages', 'name': 'arch', 'repository_type': 'filesystem', 'version': 'x86_64'})),
Variant(FileSystemVariantResource({'index': None, 'location': '/software/rez/packages', 'name': 'os', 'repository_type': 'filesystem', 'version': 'CentOS-7.9'})),
Variant(FileSystemVariantResource({'index': 0, 'location': '/software/rez/packages', 'name': 'python', 'repository_type': 'filesystem', 'version': '3.7.7'})),
Variant(FileSystemVariantResource({'index': 0, 'location': '/software/rez/packages', 'name': 'rez', 'repository_type': 'filesystem', 'version': '2.88.4'}))]
The ResolvedContext is obfuscating the fact it is being loaded from the cache and there appears to be no method available on the ResolvedContext in order to determine the cache was used. The package_cache_present
seems to return True if the caching directory exists (even if it is empty). It seems the only way is to inspect the environment for the context for the existence of _ORIG_ROOT
env vars. Is there any other way to determine this?