Repository navigation
Document cache versioning for container and shell tasks (flyte 2.12.0) - #1773
Draft
unionai-docsy-agent[bot] wants to merge 2 commits into
Draft
unionai-docsy-agent[bot] wants to merge 2 commits into
unionai-docsy-agent[bot] wants to merge 2 commits into
Conversation
Drafted by Docsy for case 487. Signed-off-by: unionai-docsy-agent[bot] <336110417+unionai-docsy-agent[bot]@users.noreply.github.com>
GHA build & deploy previewBuilt by
Updated automatically on every push. |
…e="auto" and builds a ContainerTask with ContainerBodyPolicy, checked on flyte 2.12.0 and 2.13.0); say sandbox code is versioned through its content-hashed _script input; and scope the ContainerTask.override() TypeError to 2.12.0-2.12.2 (fixed in 2.12.3, checked by running each release). Pushed by Docsy at the direction of Peeter Piegaze (ppiegaze). Signed-off-by: unionai-docsy-agent[bot] <336110417+unionai-docsy-agent[bot]@users.noreply.github.com>
Contributor
Author
|
Docsy actions: what Docsy did on this PR, and at whose direction. Docsy adds a line for each.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed in the product
flyteorg/flyte-sdk#1657 shipped in
flytev2.12.0, the earliest tag that contains it. Withcache="auto", aContainerTaskorflyte.extras.shelltask now gets its cache version from what the container runs. Before 2.12.0, every such task got the same version (sha256("")). Editing the command, the script or the image therefore never invalidated the cache.Signals 487, 828 and 1239 asked for this: they are #1657 being opened, closed and merged. The owner (Peeter Piegaze, 2026-10-20) scoped the change to
caching.md.Page changes
All changes are in
content/user-guide/tasks/task-configuration/caching.md."auto"description, one new sentence: for container, shell and code sandbox tasks,flyte2.12.0 or later generates the version from what the container runs. It links to the new subsection."disable"section: "This is the default behavior" now ends with "except for shell tasks and code sandbox tasks", the same fix as the Overview.behavior="auto"andflyte2.12.0 or later, the version hashes the following: the image; the command and arguments (for a shell task, the command holds the rendered script); the data directories; the metadata format; and the file input layout. Changing any of them invalidates the cache.cache="auto". Container tasks don't cache unless you setcache.ContainerTask.override()raises aTypeError, so on those versions setcachewhen you create the task.env_varsare not part of the version."alpine:latest"orflyte.Image.from_base("alpine:latest")) is versioned by the reference string, so the version stays the same when the tag moves.flyteor setcache="disable".Evidence
Version:
git tag --containson the main: bump unionai-docs-infra to main (#327) #1657 merge commit returnsv2.12.0as the earliest tag.Source at
v2.12.0:ContainerBodyPolicy(src/flyte/extras/_container.py) hashes_image_identity(image)with the spec.env_varsare left out and that a mutable tag keeps its version.shell/_runtime.pyhascache: str = "auto"in both_Shellandcreate().ContainerTaskinheritscache: CacheRequest = "disable"fromTaskTemplate.Runs: scratch scripts with
uv run --with flyte==<v>. Each task was serialized throughget_proto_task(...).metadata(discoverable, discovery_version):ContainerTask, nocachesetFalseFalsecachesetTrue,5502fc56…True,e3b0c442…echo binstead ofecho a76012be5…(different)e3b0c442…ubuntu:24.04instead ofalpine:3.20154d2f5e…(different)e3b0c442…env_vars={"X": "1"}5502fc56…(same)e3b0c442…cache="disable"FalseFalseContainerTask,"alpine:latest"vsImage.from_base("alpine:latest")cdcbbc37…e3b0c442…ContainerTask(...).override(cache="disable")raisesTypeError: ContainerTask.__init__() missing 1 required positional argument: 'command'._Shell) has nooverridemethod (AttributeError).ContainerTask'scommand,argumentsoroutput_data_dirchanges, and when a built image's pip packages change.Not run: I didn't push an image or move a real registry tag. The mutable-tag statement rests on the reference-string result above and on the source: nothing in the policy contacts the registry.
Reviewer findings
override()warning: taken. I split the sentence and added "Setcachewhen you create the task, becauseContainerTask.override()raises aTypeErrorinflyte2.12.0." I reproduced theTypeError. I also checked shell tasks:_Shellhas nooverride()at all, so the same advice covers them. I didn't change the general "task.overridelevel" section, because it describes function tasks.flyte.Cachepassed toshell.create(typedstr): I resolved this by removing that workaround. For pre-2.12.0 versions the page now offers only supported values: upgradeflyte, or setcache="disable". A run shows that aflyte.Cacheobject does work. But recommending something the annotation doesn't allow isn't worth it, since upgrading fixes the problem.Notes
content/_static/images/deployment/flyte_wf_timeline.svgchanging mode from 755 to 644. It was there before my edit and isn't part of this change.shell.createannotation could be widened toCacheRequestupstream, but none of the listed owners covers flyte-sdk caching, so I haven't addressed that to anyone.docsy left out changes outside the pages a draft may change:
content/_static/images/deployment/flyte_wf_timeline.svg.Pre-flight review
docsy's reviewer read the first draft before it was opened and made 6 findings. The draft was revised twice in response; its last check still made 4 findings. Its summary of the first draft:
Revised in session (Peeter Piegaze, b86bec0)
Docsy's pre-flight found that code sandbox tasks were left out. Checked and fixed:
flyte.sandbox.create()defaults tocache="auto"(since v2.0.2) and builds aContainerTask. Run on 2.12.0 and 2.13.0: the task is aContainerTaskwith cacheautoand aContainerBodyPolicy. The Overview, the"disable"section and the subsection now name sandbox tasks._scriptinput withhash_method=sha256(script content)(sandbox/_code_sandbox.py). Two sandboxes differing only in code get the same cache version (run on 2.13.0). Because the_scriptinput's hash is its content's SHA-256, an edit still changes the cache key and misses the cache. That last step is read from source, not run against a backend. The subsection says so.ContainerTask.override()is fixed in 2.12.3. Run on each release: it raisesTypeErroron 2.12.0, 2.12.1 and 2.12.2, and works on 2.12.3, 2.12.4, 2.12.5 and 2.13.0. The sentence now names 2.12.0 through 2.12.2.Docsy case 487: https://docsy.apps.demo.hosted.unionai.cloud/cases/487
Drafted by Docsy, Union.ai's documentation agent, from the product changes and requests in this case. Review it like any PR; close it if it's not wanted.