mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
Skip value key in delete_none only during updates (#2264)
* Skip value only during update * Update tests
This commit is contained in:
parent
422de63663
commit
101bc7e287
@ -707,7 +707,9 @@ class Blocks(BlockContext):
|
||||
== components._Keywords.NO_VALUE
|
||||
):
|
||||
prediction_value.pop("value")
|
||||
prediction_value = delete_none(prediction_value)
|
||||
prediction_value = delete_none(
|
||||
prediction_value, skip_value=True
|
||||
)
|
||||
if "value" in prediction_value:
|
||||
prediction_value["value"] = block.postprocess(
|
||||
prediction_value["value"]
|
||||
|
@ -51,7 +51,6 @@ XRAY_CONFIG = {
|
||||
"show_label": True,
|
||||
"name": "image",
|
||||
"visible": True,
|
||||
"value": None,
|
||||
"style": {},
|
||||
},
|
||||
},
|
||||
@ -62,7 +61,6 @@ XRAY_CONFIG = {
|
||||
"show_label": True,
|
||||
"name": "json",
|
||||
"visible": True,
|
||||
"value": None,
|
||||
"style": {},
|
||||
},
|
||||
},
|
||||
@ -100,7 +98,6 @@ XRAY_CONFIG = {
|
||||
"name": "image",
|
||||
"visible": True,
|
||||
"style": {},
|
||||
"value": None,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -111,7 +108,6 @@ XRAY_CONFIG = {
|
||||
"name": "json",
|
||||
"visible": True,
|
||||
"style": {},
|
||||
"value": None,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -279,7 +275,6 @@ XRAY_CONFIG_DIFF_IDS = {
|
||||
"type": "image",
|
||||
"props": {
|
||||
"image_mode": "RGB",
|
||||
"value": None,
|
||||
"source": "upload",
|
||||
"tool": "editor",
|
||||
"streaming": False,
|
||||
@ -295,7 +290,6 @@ XRAY_CONFIG_DIFF_IDS = {
|
||||
"type": "json",
|
||||
"props": {
|
||||
"show_label": True,
|
||||
"value": None,
|
||||
"name": "json",
|
||||
"visible": True,
|
||||
"style": {},
|
||||
@ -339,7 +333,6 @@ XRAY_CONFIG_DIFF_IDS = {
|
||||
"name": "image",
|
||||
"visible": True,
|
||||
"style": {},
|
||||
"value": None,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -350,7 +343,6 @@ XRAY_CONFIG_DIFF_IDS = {
|
||||
"name": "json",
|
||||
"visible": True,
|
||||
"style": {},
|
||||
"value": None,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -281,14 +281,14 @@ def format_ner_list(input_string: str, ner_groups: Dict[str : str | int]):
|
||||
return output
|
||||
|
||||
|
||||
def delete_none(_dict):
|
||||
def delete_none(_dict, skip_value=False):
|
||||
"""
|
||||
Delete None values recursively from all of the dictionaries, tuples, lists, sets.
|
||||
Credit: https://stackoverflow.com/a/66127889/5209347
|
||||
"""
|
||||
if isinstance(_dict, dict):
|
||||
for key, value in list(_dict.items()):
|
||||
if key == "value":
|
||||
if skip_value and key == "value":
|
||||
continue
|
||||
if isinstance(value, (list, dict, tuple, set)):
|
||||
_dict[key] = delete_none(value)
|
||||
|
Loading…
x
Reference in New Issue
Block a user