33
33
def _hexdigestify_python_call (
34
34
func_to_hex : str | Callable [..., Any ],
35
35
* args : Any ,
36
+ cache_kwargs : dict [str , Any ] = {},
36
37
** kwargs : Any ,
37
38
) -> str :
38
- return utils .hexdigestify (dumps_python_call (func_to_hex , * args , ** kwargs ))
39
+ return utils .hexdigestify (
40
+ dumps_python_call (func_to_hex , * args , cache_kwargs = cache_kwargs , ** kwargs )
41
+ )
39
42
40
43
41
44
def inspect_fully_qualified_name (obj : Callable [..., Any ]) -> str :
@@ -63,6 +66,7 @@ def dictify_python_object(obj: str | Callable[..., Any]) -> dict[str, str]:
63
66
def dictify_python_call (
64
67
func_to_dict : str | Callable [..., Any ],
65
68
* args : Any ,
69
+ cache_kwargs : dict [str , Any ] = {},
66
70
** kwargs : Any ,
67
71
) -> dict [str , Any ]:
68
72
callable_fqn = dictify_python_object (func_to_dict )["fully_qualified_name" ]
@@ -89,6 +93,8 @@ def dictify_python_call(
89
93
python_call_simple ["args" ] = args
90
94
if kwargs :
91
95
python_call_simple ["kwargs" ] = {k : kwargs [k ] for k in sorted (kwargs )}
96
+ if cache_kwargs :
97
+ python_call_simple ["cache_kwargs" ] = dict (sorted (cache_kwargs .items ()))
92
98
93
99
return python_call_simple
94
100
@@ -189,6 +195,7 @@ def dumps(
189
195
def dumps_python_call (
190
196
func_to_dump : str | Callable [..., Any ],
191
197
* args : Any ,
198
+ cache_kwargs : dict [str , Any ] = {},
192
199
** kwargs : Any ,
193
200
) -> str :
194
201
"""Serialize python call to JSON formatted string.
@@ -199,12 +206,16 @@ def dumps_python_call(
199
206
Function to serialize
200
207
*args: Any
201
208
Arguments of ``func``
209
+ cache_kwargs: dict
210
+ Additional arguments for hashing only
202
211
**kwargs: Any
203
212
Keyword arguments of ``func``
204
213
205
214
Returns
206
215
-------
207
216
str
208
217
"""
209
- python_call = dictify_python_call (func_to_dump , * args , ** kwargs )
218
+ python_call = dictify_python_call (
219
+ func_to_dump , * args , cache_kwargs = cache_kwargs , ** kwargs
220
+ )
210
221
return dumps (python_call )
0 commit comments