-
Notifications
You must be signed in to change notification settings - Fork 58
Add CLI options for backend args (like headers and verify) #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for the contribution. For backend specific arguments, please nest them under --backend_args
and handle any parsing within the backend's __init__
. Please also replace all occurrences of ssl
with cert
or some other protocol neutral term.
Ok thanks for feedback, will look into those changes |
Adds command-line options to the "guidellm benchmark" command to support custom authentication headers and skipping SSL verification when communicating with the target system. New options: --target-header: Allows specifying a custom header(s) for the target. --target-skip-ssl-verify: A flag to disable SSL certificate verification for the target. These options provide more flexibility for benchmarking targets in various environments, such as those with self-signed certificates or custom authentication mechanisms. The names were chosen to align with the existing --target argument to make it clear these apply to requests made to the target. The implementation now follows the following precedence for setting request headers: 1. Headers from the `--target-header` CLI option (highest priority). 2. Headers defined in a `.env` file or as environment variables. 3. Default headers derived from other parameters like `api_key`, `organization`, or `project` (lowest priority). This commit also adds documentation and tests for these new features, covering both CLI usage and configuration via environment variables or a `.env` file.
Created new guides for configuration options (environment variables, .env files) and supported data formats. It also updates the main CLI reference and links to the new guides.
Refactors the CLI arguments to move backend-specific options under the `--backend-args` flag. - Removes `--target-header` and `--target-skip-ssl-verify` from the CLI. - Updates the `OpenAIHTTPBackend` to parse `headers` and `verify` from the `backend_args` dictionary. - Renames `verify_ssl` to the protocol-neutral term `verify`. - Updates documentation and tests to reflect the new argument structure.
037cd42
to
e816a81
Compare
@sjmonson pushed some updates, looks like workflow needs approval |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks pretty good, just a few design nits. To fix markdown linting run python -m mdformat <files>
@@ -94,6 +94,7 @@ def __init__( | |||
extra_query: Optional[dict] = None, | |||
extra_body: Optional[dict] = None, | |||
remove_from_body: Optional[list[str]] = None, | |||
**kwargs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow same pattern as other optionals
**kwargs, | |
headers: Optional[dict] = None, | |
verify: Optional[bool] = None, |
user_headers = kwargs.pop("headers", settings.openai.headers or {}) | ||
default_headers.update(user_headers) | ||
self.headers = default_headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to layer this per-key and support removing headers. Something like this:
user_headers = kwargs.pop("headers", settings.openai.headers or {}) | |
default_headers.update(user_headers) | |
self.headers = default_headers | |
default_headers.update(settings.openai.headers or {}) | |
default_headers.update(headers) | |
self.headers = {k: v for k, v in default_headers.items() if v is not None} |
This would also allow you to simplify the default_headers
construction to something like:
default_headers = {
"Authorization": f"Bearer {api_key}" if api_key else settings.openai.bearer_token,
"OpenAI-Organization": self.organization,
"OpenAI-Project": project or settings.openai.project,
}
self.timeout = timeout if timeout is not None else settings.request_timeout | ||
self.http2 = http2 if http2 is not None else settings.request_http2 | ||
self.follow_redirects = ( | ||
follow_redirects | ||
if follow_redirects is not None | ||
else settings.request_follow_redirects | ||
) | ||
self.verify = kwargs.pop("verify", settings.openai.verify) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to above suggestion:
self.verify = kwargs.pop("verify", settings.openai.verify) | |
self.verify = verify or settings.openai.verify |
Adds command-line options to the "guidellm benchmark" command to support
custom authentication headers and skipping SSL verification when
communicating with the target system.
New options:
--target-header: Allows specifying a custom header(s) for the target.
--target-skip-ssl-verify: A flag to disable SSL certificate verification for the target.
These options provide more flexibility for benchmarking targets in
various environments, such as those with self-signed certificates or
custom authentication mechanisms. The names were chosen to align with
the existing --target argument to make it clear these apply to requests
made to the target.
The implementation now follows the following precedence for setting request headers:
--target-header
CLI option (highest priority)..env
file or as environment variables.api_key
,organization
, orproject
(lowestpriority).
This commit also adds documentation and tests for these new features,
covering both CLI usage and configuration via environment variables or a
.env
file.