add long_spec property to get fully enumerated spec string (#48389)

This commit is contained in:
Cody Balos 2025-01-13 16:43:39 -08:00 committed by GitHub
parent 3932299768
commit 66e8523e14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2052,6 +2052,20 @@ def traverse_edges(
visited=visited,
)
@property
def long_spec(self):
"""Returns a string of the spec with the dependencies completely
enumerated."""
root_str = [self.format()]
sorted_dependencies = sorted(
self.traverse(root=False), key=lambda x: (x.name, x.abstract_hash)
)
sorted_dependencies = [
d.format("{edge_attributes} " + DEFAULT_FORMAT) for d in sorted_dependencies
]
spec_str = " ^".join(root_str + sorted_dependencies)
return spec_str.strip()
@property
def short_spec(self):
"""Returns a version of the spec with the dependencies hashed
@ -4165,15 +4179,7 @@ def __str__(self):
if not self._dependencies:
return self.format()
root_str = [self.format()]
sorted_dependencies = sorted(
self.traverse(root=False), key=lambda x: (x.name, x.abstract_hash)
)
sorted_dependencies = [
d.format("{edge_attributes} " + DEFAULT_FORMAT) for d in sorted_dependencies
]
spec_str = " ^".join(root_str + sorted_dependencies)
return spec_str.strip()
return self.long_spec
@property
def colored_str(self):