Ensure that configuration data is processed consistently and correctly throughout the codebase. This includes: 1. **Use proper serialization methods** for configuration dictionaries. Prefer `json.dumps()` over `str()` when converting dictionaries to strings:
Ensure that configuration data is processed consistently and correctly throughout the codebase. This includes:
json.dumps()
over str()
when converting dictionaries to strings:# Wrong: Using str() produces invalid JSON
if isinstance(self.ep_config, dict):
self.ep_config = EPConfig.from_cli(str(self.ep_config))
# Correct: Use json.dumps() for proper serialization
if isinstance(self.ep_config, dict):
self.ep_config = EPConfig.from_cli(json.dumps(self.ep_config))
# Wrong: Only calling adapt_config_dict in one branch
if max_position_embeddings is None:
max_position_embeddings = _maybe_retrieve_max_pos_from_hf()
config_dict["max_position_embeddings"] = max_position_embeddings
config = adapt_config_dict(config_dict)
# Correct: Call processing function in all cases
if max_position_embeddings is None:
max_position_embeddings = _maybe_retrieve_max_pos_from_hf()
config_dict["max_position_embeddings"] = max_position_embeddings
config = adapt_config_dict(config_dict)
# Process nested dictionaries recursively
def _recursive_remap(elem: Any) -> Any:
if not isinstance(elem, dict):
return elem
new_dict = {}
for key, value in elem.items():
new_key = config_mapping.get(key, key)
new_dict[new_key] = _recursive_remap(value)
return new_dict
Verify that default values are sensible and documented correctly in docstrings, ensuring the implementation matches the documentation.
Avoid changing default configurations that can break backward compatibility. When defaults must change, document the change and provide a migration path.
Enter the URL of a public GitHub repository