Skip to content

Panel studio: follow a file; panel-preview, panel-upload, panel-download - #31

Merged
dsblank merged 2 commits into
mainfrom
dsb/panel-files
Oct 28, 2026
Merged

dsblank merged 2 commits into
mainfrom
dsb/panel-files

Conversation

@dsblank

@dsblank dsblank commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

What

For people who write Comet Python panels in their own editor (VS Code, vim, ...), building on cometx panel-studio (#30):

  1. Follow file in panel-studio: open a file, turn on Follow file, and each save in your own editor reloads the code and runs the panel again (within about a second). While following, the studio's code is read-only and Save is off, so it never overwrites the file.
  2. cometx panel-preview FILE --project P: just the panel, in your browser, run again on every save. No studio UI.
    • --experiments: a count (25 by default, like a dashboard's first page), all, or names/keys/key prefixes separated by commas; --sort updated|name orders them first.
  3. cometx panel-upload / cometx panel-download: the studio's upload from the command line (scriptable, e.g. for CI), and fetching a panel's code to edit.
    cometx panel-upload FILE --project P --dashboard NAME [--name PANEL]
    cometx panel-upload FILE --library [--name PANEL]
    cometx panel-download --project P --dashboard NAME [--name PANEL] [-o FILE]
    cometx panel-download --library --name PANEL [-o FILE]
    
    Same rules as the studio: a same-named panel is replaced, otherwise it goes in the dashboard's "Panel Studio" section. Download lists the panel names when a dashboard has several, explains when a panel was made in Comet's own editor (its code isn't readable with an API key), and won't overwrite -o without --force.

PANEL-STUDIO.md has a new "Using your own editor" section, and the README lists the commands.

Details

  • A changed file is read only once it stops changing (same size and modification time before and after reading), since editors often save by emptying a file and then writing it.
  • panel-preview stops on SIGTERM as on Ctrl-C, so the panel server stops and its temp folder (which holds the API key) is removed.
  • Shared CLI pieces (--api-key/--url-override, the temp folder) moved into helpers in cli/panel_studio.py.

Testing

  • 481 unit tests pass with both released comet_ml 3.58.8 and the dev branch; new tests/unit/test_panel_files.py covers experiment choosing, settled reads (including a file changing mid-read), dashboard and library lookups, workspace resolution, and the upload/download commands.
  • Live on comet.com:
    • upload to a new dashboard, re-upload (replaced in place), download without --name; library upload and download; the multi-panel and overwrite errors. Also with released comet_ml 3.58.8.
    • panel-preview in headless Chrome: the open page went from v1 to v2 after the file was saved, with the requested 3 experiments; SIGTERM stopped it and removed its temp folder.
    • Follow file in headless Chrome: turning it on ran the panel with the code read-only and Save off; saving the file reloaded the code and ran the panel again with it.

🤖 Generated with Claude Code

For people who write panels in their own editor:

- Follow file (panel-studio): reloads the panel file each time it's saved
  and runs the panel again; while following, the studio's code is
  read-only so it never overwrites the file.
- cometx panel-preview FILE --project P: just the panel, in the browser,
  run again on every save. --experiments takes a count (25 by default,
  like a dashboard), "all", or names/keys; --sort orders them first.
- cometx panel-upload FILE (--dashboard NAME --project P | --library):
  the studio's upload, from the command line, so it can also run in CI.
- cometx panel-download (--dashboard NAME --project P | --library)
  [--name PANEL] [-o FILE]: fetch a panel's code to edit.

A changed file is read only once it has stopped changing, since editors
often save by emptying a file and then writing it. panel-preview stops on
SIGTERM as on Ctrl-C, so its temp folder (holding the API key) is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@baz-reviewer

baz-reviewer Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review this PR on Baz

Baz Summary

Add file-based panel workflows through panel-studio follow mode and the panel-preview, panel-upload, and panel-download CLI commands. Update shared panel helpers and documentation to safely settle file reads, choose experiments, resolve dashboards and libraries, manage credentials and temporary servers, and support round-trip editing.

graph LR
main_cometx_cli_init_py_("main (cometx/cli/__init__.py)"):::modified
panel_upload_("panel_upload"):::added
panel_download_("panel_download"):::added
panel_preview_("panel_preview"):::added
COMET_API_cometx_cli_panel_upload_py_("COMET_API (cometx/cli/panel_upload.py)"):::added
COMET_API_cometx_cli_panel_download_py_("COMET_API (cometx/cli/panel_download.py)"):::added
COMET_API_cometx_cli_panel_preview_py_("COMET_API (cometx/cli/panel_preview.py)"):::added
panel_studio_("panel_studio"):::modified
PANEL_SERVER_("PANEL_SERVER"):::modified
main_cometx_cli_panel_studio_app_py_("main (cometx/cli/panel_studio_app.py)"):::modified
watch_followed_file_("watch_followed_file"):::added
STREAMLIT_("STREAMLIT"):::modified
main_cometx_cli_init_py_ -- "Adds panel-upload command dispatch for dashboard or library uploads." --> panel_upload_
main_cometx_cli_init_py_ -- "Adds panel-download command dispatch for retrieving panel code." --> panel_download_
main_cometx_cli_init_py_ -- "Adds panel-preview command dispatch for live local panel execution." --> panel_preview_
panel_upload_ -- "Sends workspace, destination, panel name, and Python code for upload." --> COMET_API_cometx_cli_panel_upload_py_
panel_download_ -- "Requests workspace, dashboard or library panel name, and receives Python code." --> COMET_API_cometx_cli_panel_download_py_
panel_preview_ -- "Queries workspace project experiments, then selects keys for preview configuration." --> COMET_API_cometx_cli_panel_preview_py_
panel_studio_ -- "Centralizes credential handling and temporary workspace creation for panel server startup." --> PANEL_SERVER_
main_cometx_cli_panel_studio_app_py_ -- "Main now watches followed files and reruns panels after settled edits." --> watch_followed_file_
watch_followed_file_ -- "Detects stable file signatures and triggers Streamlit reruns with updated code." --> STREAMLIT_
classDef added stroke:#15AA7A
classDef removed stroke:#CD5270
classDef modified stroke:#EDAC4C
linkStyle default stroke:#CBD5E1,font-size:13px
Loading

Topics

TopicDetails
Panel CLI transfer Provide scriptable commands to upload Python panels to dashboards or the library and download panel code with selection, overwrite protection, workspace resolution, and helpful errors.
Modified files (7)
  • PANEL-STUDIO.md
  • README.md
  • cometx/cli/__init__.py
  • cometx/cli/panel_download.py
  • cometx/cli/panel_upload.py
  • cometx/panel_studio.py
  • tests/unit/test_panel_files.py
Latest Contributors(2)
UserCommitDate
doug@comet.comPanel studio: follow a...October 28, 2026
doug.blank@gmail.comAdd cometx panel-studi...October 28, 2026
Live panel editing Enable editors to follow and preview panel files, reloading settled changes and rerunning panels while keeping followed studio code read-only and handling clean shutdown.
Modified files (5)
  • cometx/cli/panel_preview.py
  • cometx/cli/panel_studio.py
  • cometx/cli/panel_studio_app.py
  • cometx/panel_studio.py
  • tests/unit/test_panel_files.py
Latest Contributors(2)
UserCommitDate
doug@comet.comAddress review: conten...October 28, 2026
doug.blank@gmail.comAdd cometx panel-studi...October 28, 2026


Merger  Activate to get a short verdict whether this PR is good to go or not

Skills  Activate Skill Maintainer to keep your skills up to date

Planner  This PR would have been improved with Baz Planner - Try it now

Comment thread cometx/panel_studio.py Resolved
Comment thread cometx/cli/panel_preview.py Resolved
Comment thread cometx/cli/panel_preview.py Resolved
Comment thread cometx/cli/panel_studio.py Resolved
…entials

- A file's signature now includes a hash of its contents, so a save that
  keeps the same size within one timestamp tick isn't missed.
- --port and --panel-port only take 1-65535, with a clear error.
- panel-preview exits with "Could not read the file" for a folder or a
  missing file, and reads the file only once it isn't mid-save.
- --api-key and --url-override given before the command
  (cometx --api-key KEY panel-preview ...) are no longer replaced by the
  subcommand's empty defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dsblank
dsblank merged commit 0041bec into main Oct 28, 2026
2 checks passed
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