<#7035 [V2] Add Cache service> Pull request opened...
# flyte-github
a
#7035 [V2] Add Cache service Pull request opened by machichima Tracking issue Why are the changes needed? Add cache service What changes were proposed in this pull request? Add cache service and reservation to: • Directly fetch output from object store URI if cache enabled • Add reservation to prevent two requests trying to write to cache at the same time How was this patch tested? • Run
flyte-sdk
script below twice to trigger cache import random import flyte from flyte import Cache env = flyte.TaskEnvironment(name="use_cache_simple") @env.task(cache=Cache(behavior="override", version_override="v1")) def main(x_list: list[int]) -> str: token = random.randint(1, 1_000_000) print(f"cache miss: generated token={token}") return f"sum={sum(x_list)}, token={token}" if name == "__main__": flyte.init_from_config() # establish remote connection from within your script. run = flyte.run(main, x_list=list(range(10))) # run remotely inline and pass data. print(run.name) print(run.url) run.wait() ❯ python examples/use_cache_simple.py > Building 1 image... > Building image flyte for environment use_cache_simple i Image ghcr.io/flyteorg/flyte:16b2b307f1864d4a76e0224b38da6444 already exists, skipping build ✓ Built image for environment use_cache_simple: ghcr.io/flyteorg/flyte:16b2b307f1864d4a76e0224b38da6444 > Bundling code... ✓ Code bundle: 1 files, 0.009765625 MB (compressed 0.0006875991821289062 MB) > Uploading code bundle... rgk8t2gb7ksw6cpq8llp http://localhost:8080/v2/domain/development/project/testproject/runs/rgk8t2gb7ksw6cpq8llp Run 'rgk8t2gb7ksw6cpq8llp' completed successfully. ~/workData/open-source/flyte-sdk main *22 !1 ?4 13s  flyte-sdk ❯ python examples/use_cache_simple.py > Building 1 image... > Building image flyte for environment use_cache_simple i Image ghcr.io/flyteorg/flyte:16b2b307f1864d4a76e0224b38da6444 already exists, skipping build ✓ Built image for environment use_cache_simple: ghcr.io/flyteorg/flyte:16b2b307f1864d4a76e0224b38da6444 > Bundling code... ✓ Code bundle: 1 files, 0.009765625 MB (compressed 0.0006875991821289062 MB) > Uploading code bundle... rm42shl58npfxzccmjts http://localhost:8080/v2/domain/development/project/testproject/runs/rm42shl58npfxzccmjts Run 'rm42shl58npfxzccmjts' completed successfully. There's only one pod created for the first execution `rgk8t2gb7ksw6cpq8llp`: ❯ k get pods -n testproject-development NAME READY STATUS RESTARTS AGE rgk8t2gb7ksw6cpq8llp-a0-0 0/1 Completed 0 108s Labels Please add one or more of the following labels to categorize your PR: • added: For new features. • changed: For changes in existing functionality. • deprecated: For soon-to-be-removed features. • removed: For features being removed. • fixed: For any bug fixed. • security: In case of vulnerabilities This is important to improve the readability of release notes. 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 •
main
• #6583 • [V2] Add Cache service 👈 flyteorg/flyte