ASP Studio for Python
ASP Studio shows the answer sets of an Answer Set Programming program, draws them as a graph, and steps through how a recursive program reaches its result. It works in Jupyter, in VS Code notebooks and from the command line. It uses the clingo Python API and shares its visualizer with the ASP Studio VS Code extension.
Website and live demo: https://yakupbulbul.github.io/asp-vscode/
pip install "asp-studio[notebook]" # Python 3.9 or newer
The notebook extra adds IPython for the %%asp magic. Without it you still get solve() and the command line.
In a notebook
%load_ext asp_studio
%%asp
parent(anna,bob). parent(bob,carl). parent(carl,eve).
ancestor(X,Y) :- parent(X,Y).
ancestor(X,Z) :- parent(X,Y), ancestor(Y,Z).
The output has four tabs. Animator steps through the rounds and shows which rule fired with which variable bindings. Answer Sets lists every model. Graph draws the atoms. Console shows clingo's messages and the position of any error.
Cell options:
| Option | Meaning |
|---|---|
-n 5, --models 5 |
At most 5 answer sets (0 means all). |
-o "--opt-mode=optN -c n=6" |
Extra clingo options. |
-t 20 |
Timeout in seconds. The default is 10. |
--tab answers |
First tab to show: animator, answers, graph or console. |
--theme dark |
auto (default), light or dark. Inside VS Code the editor theme is used. |
--height 500 |
Starting height in pixels. The output grows with its content. |
--out res |
Keep the result in a variable called res. |
From Python
import asp_studio as asp
res = asp.solve("a :- not b. b :- not a.", models=0, timeout=10)
res.result # 'SATISFIABLE'
list(res) # [['b'], ['a']]
res.diagnostics # positions of errors and warnings from clingo
res # as the last line of a cell: shows the visualizer
asp.show(res, tab="graph")
solve takes ASP text, a pathlib.Path, or a list of those, which are joined in order. A broken program does not raise: check res.ok and res.error. With #minimize or #maximize and a finished search, only the optimal models are kept, and their costs are in res.costs.
Command line
asp-studio program.lp --open # writes program.html and opens it
asp-studio instance.lp encoding.lp -n 3 # several files are joined in order
python -m asp_studio program.lp # the same, without the script on PATH
The exit code is 0 when the program ran, 1 when it has an error (positions print as file:line:col) and 2 for bad arguments or unreadable input.
Notes
- The animator follows positive programs only: no
not, choice rules, constraints or ranges. For other programs it names the unsupported line, and the other three tabs still work. - The visualizer runs in an isolated
<iframe>. Jupyter shows such output only in trusted notebooks. - Outside notebooks and VS Code, the color theme follows the operating system.
Development
pip install -e ".[test]"
pytest
python sync_static.py # copy ../media/{engine.js,webview.js,webview.css,themes.css} into the package
The visualizer files live in ../media and are copied into src/asp_studio/static. A test fails when the copies drift apart.
MIT license. Not affiliated with the Potassco team.
Metadata
Release files for asp-studio 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| asp_studio-0.2.2.tar.gz | 32.4 kB | With provenance | Details for asp_studio-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asp_studio-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for asp_studio-0.2.2-py3-none-any.whl |
Total release size: 63.3 kB
Release files / asp_studio-0.2.2.tar.gz
| Download URL | asp_studio-0.2.2.tar.gz |
|---|---|
| Size | 32.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba6742d4c329deb9ca31c374b088b686cb757705a90f92c4d8096df37c0d4746
|
|
BLAKE2b-256 checksum How to use checksums |
88dcf09d04b21e1e348701b99ad4b62ff07e1411cd3e5d65631099233ac9c143
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / asp_studio-0.2.2-py3-none-any.whl
| Download URL | asp_studio-0.2.2-py3-none-any.whl |
|---|---|
| Size | 30.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26c7ba1dc693ea6f0815a32e7f79acef316f68f413c979250a9bf024f3899717
|
|
BLAKE2b-256 checksum How to use checksums |
a0d9cd4394fa40ff4acca41d560db6814ec861620ad999e6ae6b28482da315bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for asp-studio 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for asp_studio-0.2.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.