Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core feature] Provide a way to ignore portions of the signature for cache key calculation purposes #3058

Closed
2 tasks done
eapolinario opened this issue Nov 7, 2022 · 3 comments
Labels
enhancement New feature or request flytekit FlyteKit Python related issue

Comments

@eapolinario
Copy link
Contributor

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:

@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:

@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:

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
@eapolinario eapolinario added enhancement New feature or request untriaged This issues has not yet been looked at by the Maintainers flytekit FlyteKit Python related issue labels Nov 7, 2022
@github-actions
Copy link

Hello 👋, This issue has been inactive for over 9 months. To help maintain a clean and focused backlog, we'll be marking this issue as stale and will close the issue if we detect no activity in the next 7 days. Thank you for your contribution and understanding! 🙏

@github-actions github-actions bot added the stale label Aug 24, 2023
@github-actions
Copy link

github-actions bot commented Sep 5, 2023

Hello 👋, This issue has been inactive for over 9 months and hasn't received any updates since it was marked as stale. We'll be closing this issue for now, but if you believe this issue is still relevant, please feel free to reopen it. Thank you for your contribution and understanding! 🙏

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 5, 2023
@eapolinario eapolinario removed the untriaged This issues has not yet been looked at by the Maintainers label Oct 19, 2023
@eapolinario eapolinario reopened this Oct 19, 2023
@github-actions github-actions bot removed the stale label Oct 20, 2023
@troychiu
Copy link
Member

Closing as satisfied by flyteorg/flytekit#2275 and #4618.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request flytekit FlyteKit Python related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants