This file provides guidance to WARP (warp.dev) when working with code in this repository.
DEVSimPy is a wxPython-based GUI environment for modeling and simulating DEVS (Discrete Event System Specification) models. The codebase provides:
- A desktop GUI application for interactive DEVS modeling and simulation.
- A non-GUI/batch mode for running simulations from
.dspmodel files. - Multiple DEVS simulation kernels (PyDEVS, PyPDEVS, KafkaDEVS) and domain-specific model libraries.
- A plugin and AI-assisted system for extending the environment and interacting with models.
Key user-facing entrypoints (from the repo):
- GUI:
python devsimpy/devsimpy.py - No-GUI:
python devsimpy/devsimpy-nogui.py - Installed CLI (from PyPI):
devsimpy(configurable to run with or without GUI).
From the README:
- Install from PyPI (system-wide or in a virtualenv):
pip install devsimpy- Then launch:
devsimpy
- Develop from this repo (typical workflow):
git clone --recurse-submodules -b version-5.1 --depth=1 https://github.com/capocchi/DEVSimPy.gitgit fetch --unshallow(optional, for full history)pip install -r requirements.txt- Run the GUI from the repo root:
python devsimpy/devsimpy.py- On macOS, wxPython may require:
pythonw devsimpy/devsimpy.py
The project targets Python 3.9+ (with CI and README focusing on Python 3.10+ and wxPython ≥ 4.2.2).
From the repository root:
- Launch the main GUI (dev mode):
python devsimpy/devsimpy.py
- Launch the main GUI using the installed console script (after
pip install devsimpy):devsimpy
The GUI can also be started with model and runtime arguments (used in CI on Linux):
xvfb-run -a python devsimpy/devsimpy.py examples/model0/model0.dsp 10 autostart autoclose
From the README and SimulationNoGUI:
- Use the no-GUI entrypoint script:
python devsimpy/devsimpy-nogui.py path/to/model.dsp -sim 10 -kernel pdevs
- Using the GUI script with
--nogui(equivalent behavior):python devsimpy/devsimpy.py --nogui path/to/model.dsp -sim 10 -kernel pdevs
- For PyDEVS kernel:
python devsimpy/devsimpy-nogui.py path/to/model.dsp -kernel PyDEVS 10
- Inspect CLI options:
python devsimpy/devsimpy-nogui.py -h
On Windows CI, the installed CLI is exercised in no-GUI mode as:
devsimpy --nogui examples/model0/model0.dsp 10
Tests are GUI-heavy and live in tests/. They are designed to be run as plain Python scripts (often with --autoclose to avoid hanging windows), and CI runs them under a virtual X server on Linux and directly on Windows.
From the repo root:
python tests/all.py
This script:
- Discovers all
tests/test_*.pyfiles. - Invokes each test file as
python test_*.py --autocloseby default (you can pass your own extra args).
From the repo root:
cd tests- Example (Linux/macOS, with a real display):
python test_checkergui.py --autoclose
- Example (Linux without a display, following CI style):
xvfb-run -a python test_checkergui.py --autoclose
- Example (Windows, similar to CI):
python test_checkergui.py --autoclose --nogui
Most tests exercise wxPython dialogs/frames; they require wxPython and related GUI dependencies installed (see requirements.txt and CI workflows).
From .github/workflows/lint.yml:
- Install tools:
python -m pip install --upgrade pippip install flake8 mypy
- Run Flake8 on the whole repo:
flake8 .
- Run mypy static type checking:
mypy .
These are the commands used in CI and should be preferred for local quality checks.
Packaging is configured via pyproject.toml with setuptools as the build backend and a console script entrypoint:
- Build backend:
[build-system]usessetuptools.build_metawithsetuptoolsandwheel.
- Console script:
[project.scripts]declaresdevsimpy = "devsimpy.devsimpy:main".
Typical packaging workflow (if you need wheels/sdist from this repo):
- Install the standard PEP 517 build tool:
pip install build
- Build distributions from the repo root:
python -m build
This will use the pyproject.toml configuration to produce artifacts under dist/.
Relevant top-level elements:
devsimpy/– main application package (GUI, simulation logic, domain libraries, kernels, utilities).tests/– GUI-focused test suite (individualtest_*.pyscripts andall.pyaggregator).examples/– sample models (e.g.examples/model0/model0.dsp) used by CI.pyproject.toml– project metadata, dependencies, and console script configuration.
The primary entrypoint is devsimpy/devsimpy.py, which:
- Initializes wxPython and config/builtins via
config.py(UpdateBuiltins, global DEVS settings, kernel paths, etc.). - Creates the main wxPython
MainApplicationframe:- Manages the overall window layout with
wx.aui.AuiManager. - Hosts:
ControlNotebook– left-side pane containing the library tree and search tree (LibraryTree,LibPanel,PropPanel).DiagramNotebook– central pane managing diagram tabs (each tab hosts a DEVS block diagram viaContainer/ShapeCanvas).- A simulation panel and an embedded
wx.pyshell for interactive scripting.
- Manages the overall window layout with
- Integrates with many subsystems:
PluginManager– discovers and loads plugins, exposed throughPluginsGUI.PreferencesGUI– user settings.YAMLExportGUI– export diagrams to YAML for external tools (e.g. DEVSimPy-mob).Reporter– exception handling (ExceptionHook).- Utility functions in
Utilitiesfor updating from git, package installation, notifications, etc.
pyproject.toml points the console script devsimpy at devsimpy.devsimpy:main, so installed usage and direct script usage share the same main entrypoint.
DEVSimPy separates domain-independent DEVS semantics from domain-specific models:
-
DEVSKernel/– DEVS simulation backends:PyDEVS/DEVS.py– PyDEVS-based kernel.PyPDEVS/– PyPDEVS-based kernel.KafkaDEVS/– DEVS-on-Kafka kernel for distributed simulations.Strategies.py– strategy objects for different simulation modes.__init__.py– exposes available kernels (PyDEVS,PyPDEVS,KafkaDEVS).
-
DomainInterface/– bridge between the GUI and kernels:DomainStructure.py– abstract base for domain structures:- Dynamically imports the appropriate
DEVSKernel.*.DEVSmodule based on global configuration (DEFAULT_DEVS_DIRNAME,DEVS_DIR_PATH_DICTinconfig.py). - Derives from
BaseDEVS.CoupledDEVSand standardizes accessors for component sets (getComponentSet,setComponentSet,addToComponentSet,delToComponentSet).
- Dynamically imports the appropriate
DomainBehavior.py,MasterModel.py,Object.py– define the behavior and structure interface that domain-specific models implement to be manipulated from the GUI and simulated by the chosen kernel.
-
Domain/– domain-specific model libraries:Basic/– foundational building blocks (Atomic,Coupled,IPort,OPort,Object).Generator/– input generators (file-based, random, XML, etc.).Collector/– output sinks (to disk, stdout, plotly, pusher, etc.).FSM/– finite state machine models.Web/– web-related generators/collectors.
These domain libraries are loaded into the GUI library tree and can be used to build hierarchical DEVS diagrams.
The GUI is built from many composable components:
-
Diagram canvas and nodes:
Container– central diagram canvas and diagram-specific logic.Components– block representations on the canvas.atomic_model_scheme.py– schematic representation of atomic models.
-
Mixins and patterns:
Mixins/– cross-cutting behaviors for diagram objects (e.g.Connectable,Attributable,Savable,Iconizable,Selectable,Structurable).Patterns/– implementation of common design patterns (Factory,Strategy,Observer,Singleton,Memoize) used across simulation and GUI code.
-
Supporting GUI modules:
- Dialogs and frames:
CheckerGUI,ConnectDialog,DetachedFrame,DiagramConstantsDialog,FindGUI,WizardGUI,PluginsGUI,PreferencesGUI, etc. - Panels and trees:
LibPanel,LibraryTree,PropPanel,ControlNotebook,DiagramNotebook. - Tools:
Editor(code editor),PlotGUI,SpreadSheet,YAMLExportGUI,ZipManager,StandaloneGUI, etc.
- Dialogs and frames:
The tests/ directory mirrors many of these components with targeted GUI tests (test_*.py files) that instantiate dialogs/frames, interact with them, and rely on --autoclose flags for unattended runs.
For headless workloads and integration with web/remote clients:
-
SimulationNoGUI.py:- Provides
makeSimulationandrunSimulationclasses for running simulations without a GUI. - Accepts a
masterDEVS model and a simulation horizonT, manages:- Creation of a simulator via
Patterns.simulator_factory(using kernel strategy and flags such asNTL,DEFAULT_SIM_STRATEGY,DYNAMIC_STRUCTURE,REAL_TIME). - Optional progress reporting on stdout and (commented) hooks for streaming status/outputs via pusher or sockets.
- Integration with
InteractionSocket.InteractionManagerfor remote control of simulations.
- Creation of a simulator via
- Handles logging of simulation reports under
logs/whensimu_nameis provided.
- Provides
-
devsimpy/devsimpy-nogui.pyanddevsimpy/devsimpy.py --nogui:- Provide CLI entrypoints that parse command-line arguments (
-sim,-kernel, etc.), instantiate the DEVS model from.dspfiles, and invoke the no-GUI simulation flow.
- Provide CLI entrypoints that parse command-line arguments (
-
Integration/serialization helpers:
InteractionSocket.py/InteractionYAML.py– communication and YAML-based interaction with simulations.YAMLExportGUI.py– export diagrams to YAML for external tools (e.g. mobile or web versions of DEVSimPy).
The codebase contains explicit support for plugins and AI-assisted workflows:
-
PluginManager.pyandPluginsGUI.py:- Discover, enable/disable, and configure plugins.
- Integrate plugins into the GUI (menus, panels, actions).
-
AI/directory and AI modules:AI/DEVS_Explanation.txtand prompt templates underAI/functions_prompt/define text prompts and explanations for DEVS concepts and model functions.AIAdapter.pyandAIPrompterDialog.pyintegrate AI/LLM capabilities into the GUI, leveraging these prompts to assist users in understanding or generating DEVS models.
When editing or extending AI-related features, prefer to reuse the existing prompt files under AI/ and the AIAdapter/AIPrompterDialog integration points instead of hardcoding new prompts in unrelated modules.
CI workflows under .github/workflows/ are the source of truth for how this project is exercised in automation:
-
ci-build-ubuntu.yml(Ubuntu):- Sets up a conda environment with wxPython, installs Python dependencies via pip.
- Runs a basic GUI smoke test via
xvfb-run -a python devsimpy/devsimpy.py examples/model0/model0.dsp 10 autostart autoclose. - Iterates over a curated list of GUI tests under
tests/, running each viaxvfb-run -a python <test_file> --autoclose.
-
ci-build-windows.yml(Windows):- Creates a venv and installs DEVSimPy from PyPI (
python -m pip install devsimpy). - Runs a no-GUI simulation using the installed CLI (
devsimpy --nogui examples/model0/model0.dsp 10). - Installs GUI dependencies (wxPython, PyPubSub, psutil) and runs the same curated list of GUI tests using
python <test_file> --autoclose --nogui.
- Creates a venv and installs DEVSimPy from PyPI (
-
lint.yml(lint job):- Runs
flake8 .andmypy .against the repository with Python 3.13.
- Runs
When modifying test behavior or adding new tests, align with these workflows so they continue to pass without additional CI changes.