<#3058 [Core feature] Provide a way to ignore port...
# flytekit
a
#3058 [Core feature] Provide a way to ignore portions of the signature for cache key calculation purposes Issue created by eapolinario Motivation: Why do you think this is important? It's useful to skip some inputs for cache key calculation purposes For example, let's say we have this task:
Copy code
@task(cache=True, cache_version="v1")
def t(log_level: int, a: str) -> str:
  ...
According to the docs, one of the inputs to cache key calculation is the task signature, but in the case of this example, it'd be great if we could ignore
log_level
as part of the cache key calculation. Goal: What should the final outcome look like, ideally? We should be able to do something along the lines of:
Copy code
@task(cache=True, cache_version="v1", ignore_input_vars=["log_level"])
def t(log_level: int, a: str) -> str:
    ...
This would essentially skip some of the parameters for cache key calculation purposes. Describe alternatives you've considered We have the ability to override the hashing mechanism used to translate python types into Flyte types, as described in https://docs.flyte.org/projects/cookbook/en/latest/auto/core/flyte_basics/task_cache.html#caching-of-non-flyte-offloaded-objects. One could use this idea and provide constant hashes for the arguments they want to ignore, for example:
Copy code
def constant_function(x: int) -> str:
    return "const"

@task 
def t_produce_annotated_literals() -> Annotated[int, HashMethod(constant_function)]:
   log_level = ...
   return log_level

@task(cache=True, cache_version="v1")
def t(log_level: int, a: str) -> str:
   ...

@workflow
def wf() -> str:
  log_level = t_produce_annotated_literals()
  return t(log_level=log_level, a="some string")
Propose: Link/Inline OR Additional context Expose
ignore_input_vars
in the
@task
decorator and ensure the new interface is used during cache key calculation in both local and remote executions. Are you sure this issue hasn't been raised already? ☑︎ Yes Have you read the Code of Conduct? ☑︎ Yes flyteorg/flyte