fix(trainer): memoize GitHub runtime loading, remove dead cache layer - #784
Open
brightyorcerf wants to merge 1 commit into
Open
fix(trainer): memoize GitHub runtime loading, remove dead cache layer#784brightyorcerf wants to merge 1 commit into
brightyorcerf wants to merge 1 commit into
Conversation
…ayer `runtime_loader` documented a 24-hour cache for runtimes fetched from GitHub, but nothing was ever cached: `_get_github_runtime_files` and `_load_runtime_from_github_with_cache` had no callers, and the live path `_load_from_github_url` called `_discover_github_runtime_files` / `_fetch_runtime_from_github` directly. Both the wrappers and the loader that bypasses them were introduced together in kubeflow#119, so the layer was never wired up. This matters because `runtime_source.sources` defaults to `github://kubeflow/trainer` and `__get_trainjob_from_containers` resolves a runtime per job, so `list_jobs()` over N jobs cost N directory scrapes plus N YAML downloads against unauthenticated GitHub. Fetch failures are swallowed and fall through to `_create_default_runtimes()`, which emits the same runtime name with a different image, so a rate-limited user could silently train on an image other than the one the runtime pins. Memoize `_load_from_github_url` per process instead of reinstating the disk cache: the disk cache keyed on bare filename while `sources` accepts arbitrary `owner/repo/path`, and a 24-hour TTL against an unpinned branch reintroduces the stale-image problem. Returns a tuple so the memoized value is not mutable by callers. Also removes the now-unreachable cache helpers and the unused `TRAINING_RUNTIMES_DIR`, `GITHUB_RUNTIMES_BASE_URL` and `GITHUB_RUNTIMES_TREE_URL` constants, and corrects the module docstring, which additionally promised a fallback to `kubeflow/trainer/config/training_runtimes/` — a directory that does not exist. Signed-off-by: brightyorcerf <thetejaansh@gmail.com>
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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.
runtime_loaderdocumented a 24-hour cache for runtimes fetched from GitHub, but nothing was ever cached, the two cache-aware wrappers had no callers, and the live path fetched directly. See #783 for the full analysis.(per-job amplification via
list_jobs(), and a silent-image-divergence consequence on the fallback path)Fix:
@functools.cacheon_load_from_github_url(process-lifetime, returns a tuple) instead of reinstating the disk cache, the disk cache keyed on bare filename whilesourcesaccepts arbitraryowner/repo/path, and a 24h TTL against an unpinned branch reintroduces the same staleness problem. This does mean a long-lived process (a notebook kernel, a long-running service) won't see upstream runtime changes until restart, an explicit tradeoff given the alternative's own staleness problem.Also deletes the now-unreachable cache helpers, the unused
TRAINING_RUNTIMES_DIR,GITHUB_RUNTIMES_BASE_URLandGITHUB_RUNTIMES_TREE_URLconstants, and corrects the module docstring, which additionally promised a fallback tokubeflow/trainer/config/training_runtimes/, a directory that does not exist.Which issue(s) this PR fixes :
Fixes #783
Checklist:
uv run pytest kubeflow/ -q— 696 passed.ruff check .clean.ruff format --check .has 4 pre-existing failures in README files,confirmed identical on clean
main, untouched here.ty checkclean.pre-commit runclean on the staged diff. (Ran pytest directly rather thanmake test-python, that target is broken on macOS, unrelated to this change.)