Skip to content

Add --timeout flag to configure API request timeout#5

Open
nandanadileep wants to merge 1 commit intojina-ai:mainfrom
nandanadileep:feat/timeout-flag
Open

Add --timeout flag to configure API request timeout#5
nandanadileep wants to merge 1 commit intojina-ai:mainfrom
nandanadileep:feat/timeout-flag

Conversation

@nandanadileep
Copy link
Copy Markdown

Fixes #4

Summary

  • Adds a global --timeout flag to the jina CLI group (applies to all subcommands)
  • Adds a per-command --timeout option to every subcommand for fine-grained control
  • Threads the timeout value through all api.py HTTP client calls
  • Default behavior is fully unchanged: 30.0s for most commands, 60.0s for screenshot and pdf which already used higher defaults

Usage

# Global flag — applies to the subcommand
jina --timeout 60 read https://large-pdf-url.com
jina --timeout 45 search "complex query"

# Per-command flag
jina read https://large-pdf-url.com --timeout 60
jina search "complex query" --timeout 45

Changes

  • jina_cli/api.py: Added timeout parameter (defaulting to DEFAULT_TIMEOUT) to all public API functions; each passes it to _client(timeout=timeout)
  • jina_cli/main.py: Added --timeout option to the root cli group and to every subcommand; each command resolves timeout with precedence: local flag → global flag → built-in default
  • tests/test_local.py: Added TestTimeoutFlag with 5 unit tests covering help text exposure, API passthrough via mock, default value, and global context propagation

Test plan

  • All existing unit tests pass (pytest tests/test_local.py)
  • --timeout appears in --help for the root command and all subcommands
  • api.read_url(..., timeout=60.0) passes timeout=60.0 to _client()
  • DEFAULT_TIMEOUT remains 30.0
  • Global --timeout value is stored in ctx.obj and accessible to subcommands

Closes jina-ai#4

- Add global --timeout option to the CLI group
- Add per-command --timeout option to all subcommands
- Thread timeout value through to all api.py HTTP calls
- Default behavior unchanged (30s for most, 60s for screenshot/pdf)
- Add unit tests covering: help text, API passthrough, default value, context propagation
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.

Add --timeout flag to configure API request timeout

1 participant