MCPcopy
hub / github.com/EleutherAI/gpt-neox / update_value

Method update_value

megatron/neox_arguments/template.py:28–44  ·  view source on GitHub ↗

updates a property value if the key already exists Problem: a previously non-existing property can be added to the class instance without error.

(self, key: str, value)

Source from the content-addressed store, hash-verified

26 yield key, field_def.default
27
28 def update_value(self, key: str, value):
29 """
30 updates a property value if the key already exists
31
32 Problem: a previously non-existing property can be added to the class instance without error.
33 """
34 if hasattr(self, key):
35 setattr(self, key, value)
36 else:
37 error_message = (
38 self.__class__.__name__
39 + ".update_value() to be updated property "
40 + str(key)
41 + " does not exist"
42 )
43 logging.error(error_message)
44 raise ValueError(error_message)
45
46 def update_values(self, d):
47 """

Calls

no outgoing calls