MCPcopy Index your code
hub / github.com/ray-project/ray / parse_node_labels_string

Function parse_node_labels_string

python/ray/_private/label_utils.py:59–84  ·  view source on GitHub ↗
(labels_str: str)

Source from the content-addressed store, hash-verified

57
58
59def parse_node_labels_string(labels_str: str) -> Dict[str, str]:
60 labels = {}
61
62 # Remove surrounding quotes if they exist
63 if len(labels_str) > 1 and labels_str.startswith('"') and labels_str.endswith('"'):
64 labels_str = labels_str[1:-1]
65
66 if labels_str == "":
67 return labels
68
69 # Labels argument should consist of a string of key=value pairs
70 # separated by commas. Labels follow Kubernetes label syntax.
71 label_pairs = labels_str.split(",")
72 for pair in label_pairs:
73 # Split each pair by `=`
74 key_value = pair.split("=")
75 if len(key_value) != 2:
76 raise ValueError("Label string is not a key-value pair.")
77 key = key_value[0].strip()
78 value = key_value[1].strip()
79 labels[key] = value
80
81 # Validate parsed node labels follow expected Kubernetes label syntax
82 validate_node_label_syntax(labels)
83
84 return labels
85
86
87def parse_node_labels_from_yaml_file(path: str) -> Dict[str, str]:

Callers 2

startFunction · 0.90

Calls 3

stripMethod · 0.80
splitMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…