feat(cli): add lightning job logs#40
Merged
Merged
Conversation
`deployment` and `sandbox` have a `logs` command but `job` did not, so the lightning-jobs skill (and users) had to drop to the raw `lightning api /v1/projects/<id>/jobs/<id>/download-logs` endpoint just to read job logs. This adds `lightning job logs [NAME] [--teamspace owner/teamspace]`, mirroring `job inspect`: it resolves the job and prints `Job.logs`. `Job.logs` raises a RuntimeError while the job is pending/running, so the command guards on status and prints a friendly "logs are only available once it reaches a terminal state" message (via ClickException) instead of a raw traceback. Live-verified against prod lightning.ai: prints the log text after completion, and the friendly status message while Pending. Tests cover the help text, the `jobs` alias, and both the terminal and non-terminal branches. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
justusschock
approved these changes
Jul 24, 2026
k223kim
approved these changes
Jul 24, 2026
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.
Problem
deploymentandsandboxhave alogsCLI command, butjobdoesn't. So to read a job's logs from the CLI you have to drop to the raw REST endpoint (lightning api /v1/projects/<id>/jobs/<job_id>/download-logs, then fetch the signed URL). Thelightning-jobsskill documents exactly this workaround. Surfaced by an agentic audit of the platform's agent-facing surface.Change
Adds
lightning job logs [NAME] [--teamspace owner/teamspace], mirroringjob inspect: it resolves the job via_JobAndMMTAction().job(...)and printsJob.logs.Job.logsraises aRuntimeErrorwhile the job is pending/running, so the command guards onjob.statusand prints a friendly "logs are only available once it reaches a terminal state (Completed/Failed/Stopped)" message (aClickException) instead of a raw traceback.Verification
Live-verified against prod lightning.ai on a real
CPU_SMALLjob:Unit tests (
tests/cli/job/test_logs.py) cover the help text, thejobsalias, and both the terminal (prints logs) and non-terminal (clean error, no rawRuntimeError) branches. Fulltests/cli/job/suite passes (42).Follow-up
Once this ships, the
lightning-jobsskill's "Raw API fallback" can pointjob logsat this command instead of thedownload-logsendpoint.🤖 Generated with Claude Code