feat: add create_dashboard() and in-place panel update via upload_panel_zip()#23
Open
feat: add create_dashboard() and in-place panel update via upload_panel_zip()#23
Conversation
…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) |
There was a problem hiding this comment.
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 dashboardtemplate_idto clone panel associations from.API.upload_panel_zip(workspace, filename, template_id=None)— addstemplate_idparam; when provided, overwrites the existing panel in place rather than creating a new one.API.upload_panel_code()— fix: was missingreturn, so callers never received thetemplateId.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 sametemplateIdcreate_dashboard(workspace, project_name, template_name)creates an empty dashboardcreate_dashboard(..., panels=["id1"])creates a dashboard with the panel attachedcreate_dashboard(..., template_id="...")clones panel associations from an existing dashboardcreate_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:13pxAdd
create_dashboardtoAPIso 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 returntemplateIds and optionally overwrite existing panels while detailing the refresh note.create_dashboardto resolve project IDs, accept optionalpanelsortemplate_id, and describe its usage alongside the workflow guidance in the new README section.Modified files (2)
Latest Contributors(2)
upload_panel_codeto return itstemplateId, letupload_panel_zipoptionally overwrite a panel whentemplate_idis provided, and explain the browser refresh requirement in the README.Modified files (2)
Latest Contributors(2)