Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion runpod/rp_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,22 @@ def _read_code() -> str:
)
set_credentials(api_key, profile=profile, overwrite=True)
except (LoginError, ValueError, OSError) as exc:
_fail(str(exc))
from runpod.rp_cli.update import cached_newer_version

newer = cached_newer_version()
upgrade_hint = (
f"\n\na newer runpod ({newer}) is available; "
"`pip install -U runpod` may fix this."
if newer
else ""
)
_fail(
f"{exc}\n\n"
"if rp login keeps failing, grab a key from "
"https://console.runpod.io/user/settings and run:\n"
" rp login --api-key YOUR_KEY"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the failing run was rp login --profile staging, following this hint as written stores the key under the default profile, so the next rp --profile staging ... still has no credentials. Could the hint include --profile {profile} when it isn't the default?

f"{upgrade_hint}"
)
ui.success("logged in, credentials saved to [dim]~/.runpod/config.toml[/dim]")


Expand Down
13 changes: 13 additions & 0 deletions runpod/rp_cli/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ def run_install(version: str) -> None:
# -- passive background check -------------------------------------------


def cached_newer_version() -> Optional[str]:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The four branches here (no or stale cache, missing latest_version, same or older, newer) aren't covered, and they decide whether a failing login suggests an upgrade. A small parametrized test over a temp CACHE_PATH would pin them, including a pre-release like 2.0.0rc1 vs 2.0.0, which parse_version truncates to (2, 0) and so reads as not newer.

"""fresh cached latest release only if newer than current; None otherwise."""
cache = _read_cache()
if not cache or not _cache_fresh(cache):
return None
latest = cache.get("latest_version")
if not latest:
return None
if compare_versions(parse_version(latest), parse_version(current_version())) > 0:
return latest
return None


def _read_cache() -> Optional[dict]:
try:
return json.loads(CACHE_PATH.read_text(encoding="utf-8"))
Expand Down
Loading