flytekit icon indicating copy to clipboard operation
flytekit copied to clipboard

Deduce cache version iff `cache_version` is not set

Open eapolinario opened this issue 1 year ago • 0 comments

Tracking issue

https://github.com/flyteorg/flyte/issues/770

Why are the changes needed?

We should decrease the burden to use a cache in the case of python tasks.

What changes were proposed in this pull request?

This PR calls inspect.getsource passing the task function as an argument, which loads the actual source code of the function and use that to use generate a string to represent the cache version.

Notice that any change to the function (including adding/removing a parameter, changing the docstring, rearranging/reindenting some code) is going to produce a new value. In other words, the function can be moved around in a file, but its contents cannot change, otherwise a new value is going to be generated.

How was this patch tested?

Unit tests and local executions.

Setup process

Screenshots

Check all the applicable boxes

  • [ ] I updated the documentation accordingly.
  • [ ] All new and existing tests passed.
  • [ ] All commits are signed-off.

Related PRs

Docs link

eapolinario avatar Sep 07 '24 00:09 eapolinario