Skip to content

feat: add STARROCKS_CHART_DEFAULT_FORMAT env var for query_and_plotly_chart#44

Open
DanRoscigno wants to merge 1 commit into
StarRocks:mainfrom
DanRoscigno:feat/chart-default-format
Open

feat: add STARROCKS_CHART_DEFAULT_FORMAT env var for query_and_plotly_chart#44
DanRoscigno wants to merge 1 commit into
StarRocks:mainfrom
DanRoscigno:feat/chart-default-format

Conversation

@DanRoscigno

Copy link
Copy Markdown
Contributor

Summary

query_and_plotly_chart's format argument is hardcoded to default to jpeg (an inline image; no file is written). Callers that want a saved interactive HTML chart must therefore pass format="html" on every call — there is currently no way to change the default.

This PR adds a STARROCKS_CHART_DEFAULT_FORMAT environment variable that controls the default format used when format is omitted. This mirrors the existing STARROCKS_CHART_OUTPUT_DIR / STARROCKS_CHART_INCLUDE_PLOTLYJS chart configuration vars.

Behavior

  • Reads STARROCKS_CHART_DEFAULT_FORMAT; valid values are json | png | jpeg | jpg | html.
  • jpg is normalized to jpeg.
  • Invalid values fall back to jpeg with a logged warning (server still starts).
  • Unset → jpeg, so existing behavior is fully preserved.
  • An explicit format argument on the tool call still takes precedence over the env var.

Example — always produce a saved interactive chart:

export STARROCKS_CHART_DEFAULT_FORMAT=html
export STARROCKS_CHART_OUTPUT_DIR=/path/to/charts

Docs

Documents the new variable in the README, plus the two existing-but-undocumented chart variables (STARROCKS_CHART_OUTPUT_DIR, STARROCKS_CHART_INCLUDE_PLOTLYJS).

Testing

  • python -m ast parse check on server.py passes.
  • Unit-tested the resolver: html, jpeg, JPGjpeg, png, json, whitespace trimming (" HTML "html), and invalid (svgjpeg + warning) all behave as expected.

🤖 Generated with Claude Code

…_chart

The `format` argument of `query_and_plotly_chart` was hardcoded to default
to "jpeg", so callers that want a saved interactive HTML chart had to pass
`format="html"` on every call. There was no way to change the default.

Add a `STARROCKS_CHART_DEFAULT_FORMAT` environment variable that sets the
default format used when `format` is omitted. Values are validated against
json|png|jpeg|jpg|html, `jpg` is normalized to `jpeg`, and invalid values
fall back to `jpeg` with a logged warning. Behavior is unchanged when the
variable is unset (still `jpeg`), and an explicit `format` argument still
takes precedence.

Also document the new variable in the README along with the two existing
but previously undocumented chart variables, STARROCKS_CHART_OUTPUT_DIR and
STARROCKS_CHART_INCLUDE_PLOTLYJS.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant