Skip to content

feat: add wait command with non-zero exit on failure#28

Open
183amir wants to merge 4 commits intofeat/json-outputfrom
feat/wait-command
Open

feat: add wait command with non-zero exit on failure#28
183amir wants to merge 4 commits intofeat/json-outputfrom
feat/wait-command

Conversation

@183amir
Copy link
Collaborator

@183amir 183amir commented Mar 16, 2026

Summary

  • Add gridtk wait command that polls jobs until all reach a terminal state
  • Exits with code 1 if any job ended in a failed state (FAILED, CANCELLED, TIMEOUT, etc.)
  • Supports --interval option and all standard job filters
  • Document wait command in README

Examples

$ gridtk wait
Waiting for 3 job(s)... (checking every 10s)
Job 1: COMPLETED (0)
Job 2: COMPLETED (0)
Job 3: FAILED (1)

$ echo $?
1

$ gridtk wait -j 1 --interval 30
Job 1: COMPLETED (0)

$ echo $?
0

🤖 Generated with Claude Code


📚 Documentation preview 📚: https://gridtk--28.org.readthedocs.build/en/28/

@github-actions
Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/gridtk
  cli.py 609-610, 623-624, 627
Project Total  

This report was generated by python-coverage-comment-action

@183amir 183amir requested a review from Yannick-Dayer March 16, 2026 16:56
Amir Mohammadi and others added 4 commits March 16, 2026 18:01
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace ctx.exit(1) with raise SystemExit(1) to ensure click.echo
output is flushed before the process exits. ctx.exit(1) can suppress
output in some Python/Click versions (e.g. Python 3.9).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Ensures the DB session is properly committed before raising SystemExit
to avoid leaving the database in a bad state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@183amir 183amir changed the base branch from main to feat/json-output March 16, 2026 17:02
@183amir 183amir force-pushed the feat/wait-command branch from bfb8ffc to d0c3beb Compare March 16, 2026 17:02
@183amir 183amir mentioned this pull request Mar 16, 2026

# Show progress
pending = sum(1 for j in jobs if j.state not in terminal_states)
click.echo(f"Waiting for {pending} job(s)... (checking every {interval}s)")
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to have a more detailed view with counts of jobs in "PENDING" state and jobs in "RUNNING" state?
We could know if we are waiting for jobs to be started or for running jobs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants