PyESAPI
Python interface to Eclipse Scripting API
Install / Use
/learn @VarianAPIs/PyESAPIREADME
PyESAPI
"Pi-e-Sappy" for research use only.
A passion project to help accelerate breakthroughs in medical physics research by bringing the power of Python into the Varian API ecosystem. PyESAPI combined with Jupyter Notebook gives you a "command line to Eclipse" allowing you to rapidly prototype your ESAPI scripts or research ideas.
Quick Start (updated July 17th 2024)
- Access your Eclipse 15.5 (or later) TBOX desktop or Varian Innovation Center environment
- Install Python 3.10 or later from: https://www.python.org/downloads/
- Be sure to check the option to "add python.exe to PATH" (unless you are already managing multiple versions of Python)
- Note: If you use an older version of Python, your milage may vary.
- Launch "Command Prompt" by searching in Windows menu
- Navigate to a directory where you would like to store your first PyESAPI project using the
cdcommand - In the prompt, execute the commands:
pip install pyesapipip install jupyter
- Then execute the command
jupyter notebook - Create a new notebook and see below for examples (if you are using a python virtual environment, be sure not to select "root" kernel).
Examples
Jupyter Notebooks (from Developer Workshop 2018)
- Getting Started
- Data Mining
- 10xResearch
- Stand-alone python script: standalone.py
Additional Resources
PyESAPI wraps the official ESAPI interface, so a majority of the guidance on ESAPI caries over.
-
"Online" Help documentation in Eclipse External Beam (under question mark menu in upper right-hand side of the window)
-
Varian API Book - contributions from the usual suspects
-
ESAPI Code Samples - full ESAPI projects from previous workshops
-
ESAPI Subreddit - active ESAPI community
Known issues
- PyESAPI is not compatible with vscode-jupyter plugin which uses multithreading. ESAPI only allows for single-thread access to objects.
- Python 3.12 may require Microsoft Visual C++ 14.0 or greater. If you are using a VIC environment, you can get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
- Note: anaconda provieds pre-built binaries for popular packages.
Upgrading
pip install --upgrade pysapi- This will check and upgrade PyESAPI if a newer version is available
Recommended tooling:
Now that you've had a chance to explore the capabilities of PyESAPI, it's time to get more organized. Below are some recommendations on platforms and software to develop with.
- Varian Innovation Center Eclipse environment (or local TBOX)
- VisualStudio Code (lightweight IDE)
- Google Chrome or Microsoft Edge set as default browser (for better Jupyter Notebook experience)
- Git or GitHub Desktop (code repository and open source collaboration)
Development Notes
For those wishing to contribute to PyESAPI or use PyESAPI with pre-released local builds of Eclipse.
Custom ESAPI DLL path
Set custom ESAPI_PATH (to DLLs) before import (bypasses production directory path search)
import os
os.environ['ESAPI_PATH'] = r'C:\Users\CoolKid\Source\Magic\Bin\Debug64'
import pyesapi
# ...
Stub Gen (experimental/under construction)
To create lintable code and enable code completion (in Visual Studio Code at least) we can generate python stubs for ESAPI libs using IronPython...
- Download and install IronPython (2.7.9 tested to work) in default location (C:\Program Files\IronPython 2.7\ipy.exe).
- Load ironpython-stubs submodule
git submodule update --init(ironstubs) - Move to stubgen folder
cd stubgen - Execute script
stubgen.ps1(if you hit a Pdb prompt, type continue) - Commit updates to stubs folder
Related Skills
claude-opus-4-5-migration
83.9kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
model-usage
339.3kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
TrendRadar
49.9k⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。
mcp-for-beginners
15.7kThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
