Skip to content

feat: add create_dashboard() and in-place panel update via upload_panel_zip()#23

Open
dsblank wants to merge 1 commit intomainfrom
panel-and-dashboard-enhancements
Open

feat: add create_dashboard() and in-place panel update via upload_panel_zip()#23
dsblank wants to merge 1 commit intomainfrom
panel-and-dashboard-enhancements

Conversation

@dsblank
Copy link
Copy Markdown
Collaborator

@dsblank dsblank commented Apr 1, 2026

User description

Summary

  • API.create_dashboard(workspace, project_name, template_name, panels=None, template_id=None) — new method that creates a dashboard in a project, looking up the project ID by name automatically. Optionally accepts a list of panel template IDs (panels) or a source dashboard template_id to clone panel associations from.
  • API.upload_panel_zip(workspace, filename, template_id=None) — adds template_id param; when provided, overwrites the existing panel in place rather than creating a new one.
  • API.upload_panel_code() — fix: was missing return, so callers never received the templateId.
  • README-panel-and-dashboard-enhancements.md — documents the new and updated methods with examples and a typical end-to-end workflow.

Note

After updating a panel in place via upload_panel_zip(template_id=...), the Comet UI requires a browser page refresh to show the updated panel code.

Test plan

  • upload_panel_code("workspace", "Name", code) returns {'templateId': ..., 'revisionId': None}
  • upload_panel_zip("workspace", "file.zip", template_id="...") overwrites the existing panel and returns the same templateId
  • create_dashboard(workspace, project_name, template_name) creates an empty dashboard
  • create_dashboard(..., panels=["id1"]) creates a dashboard with the panel attached
  • create_dashboard(..., template_id="...") clones panel associations from an existing dashboard
  • create_dashboard(..., project_name="nonexistent") raises a clear error

🤖 Generated with Claude Code


Generated description

Below is a concise technical summary of the changes proposed in this PR:

graph LR
upload_panel_code_("upload_panel_code"):::modified
upload_panel_zip_("upload_panel_zip"):::modified
FILESYSTEM_("FILESYSTEM"):::modified
BACKEND_API_("BACKEND_API"):::modified
create_dashboard_("create_dashboard"):::added
upload_panel_code_ -- "Now returns upload_panel_zip result to caller" --> upload_panel_zip_
upload_panel_zip_ -- "Still reads zip file from disk before upload" --> FILESYSTEM_
upload_panel_zip_ -- "Adds optional templateId param when sending upload request" --> BACKEND_API_
BACKEND_API_ -- "Backend response returned as JSON to caller" --> upload_panel_zip_
create_dashboard_ -- "New function sends GET to fetch workspace projects" --> BACKEND_API_
BACKEND_API_ -- "Receives projects list JSON for project lookup" --> create_dashboard_
create_dashboard_ -- "Sends POST with project_id, template, and panels" --> BACKEND_API_
BACKEND_API_ -- "Receives created DashboardTemplate JSON response for caller" --> create_dashboard_
classDef added stroke:#15AA7A
classDef removed stroke:#CD5270
classDef modified stroke:#EDAC4C
linkStyle default stroke:#CBD5E1,font-size:13px
Loading

Add create_dashboard to API so callers can look up projects by name, reuse panel lists or clone another dashboard, and document the updated workflow. Update panel upload helpers and the README to return templateIds and optionally overwrite existing panels while detailing the refresh note.

TopicDetails
Dashboard creation Introduce create_dashboard to resolve project IDs, accept optional panels or template_id, and describe its usage alongside the workflow guidance in the new README section.
Modified files (2)
  • README-panel-and-dashboard-enhancements.md
  • cometx/api.py
Latest Contributors(2)
UserCommitDate
doug@comet.comcometx copy datagrid; ...February 04, 2025
doug.blank@gmail.comAdded upload panel by ...January 21, 2025
Panel uploads Enable upload_panel_code to return its templateId, let upload_panel_zip optionally overwrite a panel when template_id is provided, and explain the browser refresh requirement in the README.
Modified files (2)
  • README-panel-and-dashboard-enhancements.md
  • cometx/api.py
Latest Contributors(2)
UserCommitDate
doug@comet.comcometx copy datagrid; ...February 04, 2025
doug.blank@gmail.comAdded upload panel by ...January 21, 2025
This pull request is reviewed by Baz. Review like a pro on (Baz).

…lace update

- Add API.create_dashboard(workspace, project_name, template_name, panels, template_id)
  that looks up the project_id by name and POSTs to /write/dashboard-template/create
- Add template_id param to API.upload_panel_zip() to overwrite an existing panel
  in place via the templateId query param on /write/template/upload
- Fix API.upload_panel_code() to return the result from upload_panel_zip()
- Add README-panel-and-dashboard-enhancements.md documenting the new API

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment on lines 196 to +197
filename = create_panel_zip(panel_name, code)
self.upload_panel_zip(workspace, filename)
return self.upload_panel_zip(workspace, filename)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

upload_panel_code is annotated -> None but returns self.upload_panel_zip(...) which upload_panel_zip(... ) -> Dict[str, str] returns as a dict — should we update upload_panel_code's return annotation to Dict[str, Any]/Dict[str, str] or remove the return, and confirm upload_panel_zip's annotation matches the payload shape?

Finding type: Type Inconsistency | Severity: 🟢 Low


Want Baz to fix this for you? Activate Fixer

Other fix methods

Fix in Cursor

Prompt for AI Agents:

Before applying, verify this suggestion against the current code. In cometx/api.py
around lines 174 to 198, the method upload_panel_code is annotated as -> None but now
returns self.upload_panel_zip(...). Change upload_panel_code's return annotation to ->
Dict[str, Any] (or a more specific dict type) to match the actual return value, and
ensure typing.Dict and Any are imported. Also in cometx/api.py around lines 199 to 201,
confirm upload_panel_zip's signature is -> Dict[str, Any] (not a narrower Dict[str,
str]) to reflect that results.json() can produce arbitrary JSON, and update the
annotation accordingly.

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