Skip to content

Session-based remote API, notebook testing, and usability improvements#37

Merged
jcschaff merged 10 commits intomainfrom
simpler-apis
Mar 29, 2026
Merged

Session-based remote API, notebook testing, and usability improvements#37
jcschaff merged 10 commits intomainfrom
simpler-apis

Conversation

@jcschaff
Copy link
Copy Markdown
Member

@jcschaff jcschaff commented Mar 26, 2026

Summary

Session-based remote API

  • Add vc.connect() as single entry point — anonymous by default, vc.connect(login=True) for authenticated access
  • VCellSession with run_sim(), start_sim(), save_biomodel(), load_biomodel(), list_biomodels()
  • SimulationJob (from start_sim()) with .status, .wait(), .export(), .result() for non-blocking control
  • Remove module-level remote functions from vc.* — all remote ops go through a session
  • Split export_n5 internally into _submit_export / _await_export for future non-blocking export

Notebook testing infrastructure

  • Lint (mypy) all example notebooks automatically
  • Tiered execution tests: default, --run-interactive (trame), --run-remote (VCell auth)
  • Fix broken notebooks: fielddata_trame, _internal_data_demo, _internal_vcell_publications
  • Guide notebook tests now respect --run-remote flag

API usability improvements

  • Field.expression property — generates vcField() strings, composable in formulas
  • Field.__init__ with defaults — direct construction without circular create_fields() pattern
  • Application.get_species_mapping(name) — convenience accessor
  • SegmentedImageGeometry.get_mask(name) — boolean mask by subvolume name
  • Fix to_segmented_image() to use subvolume names for image-based geometries

Trame widget

  • Fix time slider bug (get_data expects time value, not index)
  • Refactor state management: preserve valid selections across re-runs
  • Add status bar, error handling, configurable iframe height

New examples

  • image_field_data_demo notebook and script — synthetic microscopy image as simulation initial conditions
  • docs/project-overview.md — project summary for presentations

Breaking changes

  • vc.login(), vc.run_remote(), vc.save_and_start(), vc.wait_for_simulation(), vc.export_n5(), vc.load_biomodel(), vc.list_biomodels() removed from public API
  • All remote operations now require a session: session = vc.connect() or session = vc.connect(login=True)

Usage

import pyvcell.vcml as vc

# Anonymous — public data
session = vc.connect()
biomodel = session.load_biomodel("279851639")

# Authenticated — full access
session = vc.connect(login=True)
store = session.run_sim(biomodel, "sim1")

# Non-blocking start, then explicit blocking calls
job = session.start_sim(biomodel, "sim1")
print(job.status)                            # polls once, non-blocking
job.wait()                                   # blocks until sim completes
store = job.export()                         # blocks until export completes
# alternatively: store = job.result()        # blocks for both (wait + export)

# Image data as initial conditions
field = vc.Field(data_name="microscopy", data_nD=image_data)
app.get_species_mapping("s0").init_conc = field.expression
result = vc.simulate(biomodel, sim.name, fields=[field])

Test plan

  • make check (lint, mypy, deptry) passes
  • poetry run pytest tests -v — all tests pass
  • poetry run pytest tests -v --run-remote — authenticated remote tests
  • poetry run pytest tests -v --run-interactive — trame/display tests
  • Manual: run image_field_data_demo.ipynb in Jupyter, verify Trame widget

🤖 Generated with Claude Code

… functions

Simplifies the authentication flow so users no longer need to import
login_interactive() from internal paths or thread api_client through
every call. Breaking change: api_client moves from first positional
arg to last optional kwarg in save_and_start, wait_for_simulation,
export_n5, and run_remote.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jcschaff jcschaff self-assigned this Mar 26, 2026
jcschaff and others added 3 commits March 27, 2026 16:58
Introduces session-based API for all remote operations:
- vc.connect() for anonymous access, vc.connect(login=True) for auth
- VCellSession with run_sim(), start_sim(), save_biomodel(),
  load_biomodel(), list_biomodels()
- SimulationJob with status, wait(), export(), result() for
  non-blocking simulation control
- Remove module-level remote functions (run_remote, save_and_start,
  etc.) and load_biomodel/list_biomodels from top-level vc.* API
- Add integration tests with --run-remote flag for authenticated tests
- Rewrite remote-simulations guide and notebook around session API

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Separates the export request submission from the polling loop,
making it possible to expose non-blocking export in the future
without changing the current blocking public API.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jcschaff jcschaff changed the title Simplify remote API usability Add session-based API for remote operations Mar 27, 2026
jcschaff and others added 3 commits March 27, 2026 22:34
- Add tests/examples/test_example_notebooks.py with mypy lint checks
  for all example notebooks and tiered execution tests (default,
  --run-interactive for trame, --run-remote for VCell auth)
- Update tests/guides/test_notebooks.py to use --run-remote flag
  instead of hardcoded skip for remote-simulations notebook
- Fix fielddata_trame.ipynb: rename shadowed `app` variable to `viewer`
- Fix _internal_data_demo.ipynb: rename shadowed `y` variable
- Fix _internal_vcell_publications.ipynb: import Publication directly
- Add copasi-basico as dev dependency for sysbio notebooks
- Reduce remote-simulations notebook/guide model size for faster tests
- Fix DeprecationWarning for Path context manager in vtk_test and
  test_result
- Add --run-interactive pytest flag
- Add docs/project-overview.md for presentations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jcschaff and others added 2 commits March 29, 2026 16:30
- Field.expression property generates vcField() string for use in
  initial condition formulas
- Field.__init__ with defaults for var_name and time for direct
  construction without create_fields()
- Application.get_species_mapping() convenience method
- SegmentedImageGeometry.get_mask() returns boolean mask by subvolume name
- Fix to_segmented_image() to use subvolume names instead of pixel class
  names for image-based geometries
- Add scipy mypy override

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Widget fixes:
- Fix time_index bug: get_data expects time value, not index
- Refactor into _init_state/_bind_state_changes/_render_current/_render
- Preserve valid state (variable, time, clip) across re-runs
- Add status bar footer showing current render info
- Add error handling in state change callbacks
- Set iframe height to 1000px for better display in notebooks

New examples:
- examples/notebooks/image_field_data_demo.ipynb — synthetic microscopy
  image as initial conditions with Trame visualization
- examples/scripts/image_field_data_demo.py — same workflow as script
- Update project-overview.md with image field data example

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jcschaff jcschaff changed the title Add session-based API for remote operations Session-based remote API, notebook testing, and usability improvements Mar 29, 2026
Breaking changes in this release warrant a minor version bump.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jcschaff jcschaff merged commit bb49d6d into main Mar 29, 2026
6 checks passed
@jcschaff jcschaff deleted the simpler-apis branch March 29, 2026 21:04
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