in model_card_toolkit/utils/tfx_util.py [0:0]
def _property_value(
node: Union[metadata_store_pb2.Artifact, metadata_store_pb2.Execution,
metadata_store_pb2.Context],
name: str,
is_custom_property: bool = False) -> Optional[Union[int, float, str]]:
"""Given a MLMD node and a (custom) property name, returns its value if any.
Args:
node: A node in MLMD lineage graph. It is one of MLMD Artifact, Execution,
or Context.
name: The key of the properties or custom properties.
is_custom_property: Indicates whether the name is a custom property.
Returns:
The value of the property if found in the node; If not, returns None.
"""
properties = node.custom_properties if is_custom_property else node.properties
if name not in properties:
return None
if properties[name].WhichOneof('value') == 'int_value':
return properties[name].int_value
if properties[name].WhichOneof('value') == 'float_value':
return properties[name].double_value
return properties[name].string_value