Matt Fysh
10/08/2023, 2:20 AMtask_input_hash
uses fn.__<http://code__.co|code__.co>_code.hex()
but this value seems to remain the same if I update constants inside the function, e.g. return 1+2
and return 1+3
both return the same hex value, so changing constants in a function doesn't appear to bust the cache like it should. is this the expected behaviour?Chris White
co_code
doesn't contain byte information about constants (ref: https://stackoverflow.com/questions/64534943/determine-if-a-python-function-has-changed).
This seems easy enough to fix although it will have unexpected cache-busting behavior across an upgrade; as a workaround you can use your own cache key function that includes constants like so:
def my_cache_fn(context, arguments):
return hash_objects(
context.task.task_key, context.task.fn.__code__.co_code.hex(),
context.task.fn.__code__.co_consts.hex(),
arguments,
)
Deceivious
10/12/2023, 12:41 PM