Visualization of CSP processes

34 views
Skip to first unread message

mumford

unread,
Oct 16, 2010, 10:43:05 AM10/16/10
to pycsp
I'm looking to develop an app that will allow me to visualize CSP
processes for the purpose of informal reasoning. I'm very new to the
topic of CSP (only a semester of graduate work on CSP for a security
class), I have a semester of computation theory, and about a year of
Python. I am thinking of using PyCSP along with a visualization
library such as PIL or VTK. Any thought or suggestions?

Rune Møllegaard Friborg

unread,
Oct 16, 2010, 3:46:04 PM10/16/10
to py...@googlegroups.com
Sounds interesting. For inspiration, you should try the trace tool
available in PyCSP. It uses Graphviz to generate snapshots of an
earlier trace.

It has just recently been moved to trunk.

If you check out the TracePyCSP branch instead, you will have examples
of how to produce a trace for visualization. See:
http://code.google.com/p/pycsp/source/browse/branches/TracePyCSP/examples/Sieve.py

# Import traceable copies of PyCSP constructs
from pycsp.common.trace import *

# Create necessary trace process
TraceInit("output.trace", stdout=True)

# Shutdown trace process
TraceQuit()


the output.trace file can then be visualized with the PlayTrace.py
tool in tools.
> python tools/PlayTrace.py examples/Sieve.trace

Suggested improvements for visualizing traces in PyCSP:
* Record time spent blocking / executing. Use this in the
visualization (a colorscheme perhaps?)
* Support for moving backwards in time.
* Show the actions on a channel. Does the process block on multiple
channels using AltSelect?
* Large process networks are hard to visualize with Graphviz, perhaps
a 3D layout could be applied with success.


Cheers,
Rune

Alonza Mumford

unread,
Oct 16, 2010, 10:48:19 PM10/16/10
to py...@googlegroups.com
Thanks Rune. Let me take a look at this and hit you back.

2010/10/16 Rune Møllegaard Friborg <ru...@diku.dk>

mumford

unread,
Dec 3, 2010, 6:01:46 PM12/3/10
to pycsp
I'm generating the following error when attempting to run the the
PlayTrace.py tool:

root-be-careful> python /usr/bin/pycsp-0.7.1/tools/PlayTrace.py
pycsp_trace.log
File "/usr/bin/pycsp-0.7.1/tools/PlayTrace.py", line 506
class TracedChannel():
^
SyntaxError: invalid syntax
root-be-careful>

I'm running Python 2.4. Any ideas?

On Oct 16, 9:48 pm, Alonza Mumford <amumf...@gmail.com> wrote:
> Thanks Rune. Let me take a look at this and hit you back.
>
> 2010/10/16 Rune Møllegaard Friborg <ru...@diku.dk>
>
> > Sounds interesting. For inspiration, you should try the trace tool
> > available in PyCSP. It uses Graphviz to generate snapshots of an
> > earlier trace.
>
> > It has just recently been moved to trunk.
>
> > If you check out the TracePyCSP branch instead, you will have examples
> > of how to produce a trace for visualization. See:
>
> >http://code.google.com/p/pycsp/source/browse/branches/TracePyCSP/exam...
>
> > # Import traceable copies of PyCSP constructs
> > from pycsp.common.trace import *
>
> > # Create necessary trace process
> > TraceInit("output.trace", stdout=True)
>
> > # Shutdown trace process
> > TraceQuit()
>
> > the output.trace file can then be visualized with the PlayTrace.py
> > tool in tools.
> > > python tools/PlayTrace.py examples/Sieve.trace
>
> > Suggested improvements for visualizing traces in PyCSP:
> > * Record time spent blocking / executing. Use this in the
> > visualization (a colorscheme perhaps?)
> > * Support for moving backwards in time.
> > * Show the actions on a channel. Does the process block on multiple
> > channels using AltSelect?
> > * Large process networks are hard to visualize with Graphviz, perhaps
> > a 3D layout could be applied with success.
>
> > Cheers,
> > Rune
>

Rune Møllegaard Friborg

unread,
Dec 4, 2010, 6:13:55 AM12/4/10
to py...@googlegroups.com
I guess we have a small issue with Python 2.4.

Try changing
class TracedChannel():
to
class TracedChannel:


Did that fix the problem?

- Rune

Alonza Mumford

unread,
Dec 4, 2010, 8:25:37 AM12/4/10
to py...@googlegroups.com
I began to make that change but thought I should first inquire about what minimum or maximum version of Python I should be running? Also, which version of Python?

-Alonza

2010/12/4 Rune Møllegaard Friborg <ru...@diku.dk>

mumford

unread,
Dec 6, 2010, 1:20:13 PM12/6/10
to pycsp
Rune,

I switched to Python 2.6 running on a windows vista platform, and was
able to get everything installed; however, I'm generating the
following error upon invoking the PlayTrace.py tool:

C:\pycsp-0.7.1\tools>python PlayTrace.py
Traceback (most recent call last):
File "PlayTrace.py", line 48, in <module>
DOT = toolkit.which('dot')
File "C:\Python26\lib\site-packages\pycsp-0.7.1-py2.6.egg\pycsp
\common\toolkit
.py", line 35, in which
P = subprocess.Popen(args=('which', cmd), stdin=None,
stdout=subprocess.PIPE
)
File "C:\Python26\lib\subprocess.py", line 623, in __init__
errread, errwrite)
File "C:\Python26\lib\subprocess.py", line 833, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

C:\pycsp-0.7.1\tools>

Any ideas?

Thanks,
Alonza Mumford

On Dec 4, 9:25 am, Alonza Mumford <amumf...@gmail.com> wrote:
> I began to make that change but thought I should first inquire about what
> minimum or maximum version of Python I should be running? Also, which
> version of Python?
>
> -Alonza
>
> 2010/12/4 Rune Møllegaard Friborg <ru...@diku.dk>
>
> > I guess we have a small issue with Python 2.4.
>
> > Try changing
> > class TracedChannel():
> > to
> > class TracedChannel:
>
> > Did that fix the problem?
>
> > - Rune
>

Rune Møllegaard Friborg

unread,
Dec 6, 2010, 4:05:17 PM12/6/10
to py...@googlegroups.com
Hi Alonza,

>    P = subprocess.Popen(args=('which', cmd), stdin=None,

Support for calling the external commands to invoke graphviz have not
been implemented for windows.
It should be easy to fix and you are most welcome to produce a patch. :-)

Also, the same goes for running the playtrace tool with Python 2.4.

Our goal is that we want everything to work for Python 2.4+ and Linux,
Mac and Windows. Later Python 3.x will be added to the list.

Sorry for the inconvenience.

- Rune

Alonza Mumford

unread,
Dec 7, 2010, 12:04:10 PM12/7/10
to py...@googlegroups.com
Thanks Rune,

For now, I have taken the road of least resistance. Running Ubuntu v10 in VMware Player, I have installed all required libraries (with the exception of PyCSP) using Ubuntu's Synaptic Manager.

Thanks,
Alonza

2010/12/6 Rune Møllegaard Friborg <ru...@diku.dk>

Alonza Mumford

unread,
Dec 8, 2010, 11:06:27 AM12/8/10
to py...@googlegroups.com
Rune,

I believe there were some changes made to the Channel construct, but I'm generating the following error from the site's 'FairSelect' example @ http://code.google.com/p/pycsp/wiki/Getting_Started_With_PyCSP_2 :

 user@ubuntu1010desktop:~/Code/PyCSP$ python fairselect_example.py

Traceback (most recent call last):
  File "fairselect_example.py", line 30, in <module>
    C = Channel('C') * 4
TypeError: unsupported operand type(s) for *: 'instance' and 'int'
user@ubuntu1010desktop:~/Code/PyCSP$ vi fair*

Any ideas? I'm importing everything: processes, threads, greenlets, etc.

-Alonza
Reply all
Reply to author
Forward
0 new messages