(self, node, deep=False)
| 769 | class CheckKeyDuplicatesYamlLoader(SafeLoader): |
| 770 | |
| 771 | def construct_mapping(self, node, deep=False): |
| 772 | mapping = set() |
| 773 | for key_node, _ in node.value: |
| 774 | key = self.construct_object(key_node, deep=deep) |
| 775 | if key in mapping: |
| 776 | if os.environ.get("MONAI_FAIL_ON_DUPLICATE_CONFIG", "0") == "1": |
| 777 | raise ValueError(f"Duplicate key: `{key}`") |
| 778 | else: |
| 779 | warnings.warn(f"Duplicate key: `{key}`") |
| 780 | mapping.add(key) |
| 781 | return super().construct_mapping(node, deep) |
| 782 | |
| 783 | |
| 784 | class ConvertUnits: |