forked from fudan-generative-vision/hallo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: merge config with cli args (fudan-generative-vision#89)
Co-authored-by: leeway.zlw <[email protected]>
- Loading branch information
Showing
3 changed files
with
42 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
This module provides utility functions for configuration manipulation. | ||
""" | ||
|
||
from typing import Dict | ||
|
||
|
||
def filter_non_none(dict_obj: Dict): | ||
""" | ||
Filters out key-value pairs from the given dictionary where the value is None. | ||
Args: | ||
dict_obj (Dict): The dictionary to be filtered. | ||
Returns: | ||
Dict: The dictionary with key-value pairs removed where the value was None. | ||
This function creates a new dictionary containing only the key-value pairs from | ||
the original dictionary where the value is not None. It then clears the original | ||
dictionary and updates it with the filtered key-value pairs. | ||
""" | ||
non_none_filter = { k: v for k, v in dict_obj.items() if v is not None } | ||
dict_obj.clear() | ||
dict_obj.update(non_none_filter) | ||
return dict_obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters