<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFCC" text="#000000">
Alan:<br>
<br>
Do you see any issues in the way that Christopher is replacing the
use of PyJavaInstance with PyJavaType.wrapJavaObject?<br>
<br>
All of his Ptolemy tests passed, we're just looking for your
thoughts on closure here.<br>
<br>
Thanks, Marc<br>
<div class="moz-signature">
<meta http-equiv="CONTENT-TYPE" content="text/html;
charset=ISO-8859-1">
<title></title>
<meta name="GENERATOR" content="LibreOffice 3.3 (Unix)">
<meta name="CREATED" content="0;0">
<meta name="CHANGEDBY" content="J. Edwards">
<meta name="CHANGED" content="20110727;17373400">
<meta name="CHANGEDBY" content="J. Edwards">
<style type="text/css">
<!--
P { color: #000000 }
-->
</style>
<p><font color="#800080"><font face="Comic Sans MS, cursive"><font
style="font-size: 13pt" size="3"><span style="font-weight:
normal">J.
Marc Edwards</span></font></font></font><font
face="Comic Sans MS, cursive"><br>
Lead
Architect - Semiconductor Design Portals</font><br>
<font color="#3333ff"><font face="Nimbus Sans L, sans-serif"><font
size="4">Nimbis
Services, Inc.</font></font></font><br>
<font face="Courier New">Skype:
(919) 747-3775<br>
Cell: (919) 345-1021<br>
Fax:
(919) 882-8602</font><br>
<font face="Ubuntu"><a class="moz-txt-link-abbreviated" href="mailto:marc.edwards@nimbisservices.com">marc.edwards@nimbisservices.com</a><br>
<a class="moz-txt-link-abbreviated" href="http://www.nimbisservices.com">www.nimbisservices.com</a></font></p>
</div>
<br>
On 11/07/2011 12:07 PM, Christopher Brooks wrote:
<blockquote cite="mid:4EB81053.6090805@eecs.berkeley.edu"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=ISO-8859-1">
Hi Marc,<br>
About updating from Jython 2.2 to 2.5.1, there is <a
moz-do-not-send="true" href="http://bugs.jython.org/issue1814">http://bugs.jython.org/issue1814</a>.
My comment to that bug was:<br>
<blockquote type="cite">BTW - For Kepler/Ptolemy, I changed calls
like:<br>
<br>
new PyJavaInstance(attribute)<br>
to<br>
PyJavaType.wrapJavaObject(attribute)<br>
<br>
I have no idea if this is correct, but the Ptolemy tests passed.<br>
Adding something to the Jython Wiki would be great.</blockquote>
<br>
As it stands, the PythonScript actor can import Jython code from a
separate file by having the user edit the text widget in the
actor. It would not be that hard to get that import from a
PortParameter. I would not have time to implement anything like
that though, I have deadlines at the end of November. So, it
would be fairly easy to write actors in Jython. <br>
<br>
To me, it sounds like you are proposing porting more of the
PythonActor into Jython. This sees fairly straightforward, but a
bit of a mind bender. Ptolemy II has an execution semantics that
expects that actors implement the Executable interface. Much of
the code expects that TypedCompositeActors contain Actors and the
Actors have methods like preinitialize(), initialize(), fire(),
postfire(), wrapup(). These are all Java interfaces, classes and
methods. So, for your actors to be called, the Java execution
engine needs to have a way to call Java code that then in turn
calls the Jython code that you have written. Thus, I'm not sure
if porting more of the PythonActor into Jython would have a pay
off.<br>
<br>
Writing Jython that is read by an actor similar to the
PythonScript actor would seem to be fairly straightforward. The
Jython user writes methods in Jython, Ptolemy runs the
PythonScript actor that reads those methods.<br>
<br>
An alternative would be to embed the Ptolemy II execution engine
in Jython and make calls from Jython to execute a model. Writing
Jython actors would still need something like PythonScript.<br>
<br>
I updated <a moz-do-not-send="true"
href="https://kepler-project.org/developers/reference/python-and-kepler">https://kepler-project.org/developers/reference/python-and-kepler</a>
with a couple of links in the External Resources section that
point to third parties that I believe have interfaced to the C
version of Python using external actors. This is yet another way
of doing the job. I'm resistant to shipping releases with
interfaces to C code because of the complexity in getting JNI or
JNA to work on multiple platforms and 32 or 64 bits. However,
interfacing to C code does have value sometimes.<br>
<br>
Scala looks pretty interesting to me, I've been meaning to look
further into Scala. One side idea I've been thinking of is to
generate Scala from Ptolemy models, but I'm not sure if that is
practical.<br>
<br>
_Christopher<br>
<br>
<br>
<br>
<br>
On 11/5/11 1:54 PM, J. Marc Edwards wrote:
<blockquote
cite="mid:022401cc9bfd$29195920$7b4c0b60$@nimbisservices.com"
type="cite">
<div>
<p><span>Christopher, Alan, Josh: </span></p>
<p><span> </span></p>
<p><span>OK…this is important enough to me that I wanted to
include Alan Kennedy and Josh Juneau into your response.
Christopher, many thanks for your effort to upgrade Kepler
2.2 to Jython 2.5.2. However, I’d like to have a little
more <b> due diligence discussion </b> before putting it
to rest. </span></p>
<p><span> </span></p>
<p><span>I’m also pasting below Alan Kennedy’s response to my
earlier query to address the Jython 2.2 to 2.5.2
incompatibilities. </span></p>
<p><span> </span></p>
<p><span>My interpretation of Alan’s response containing the
term <b> “documentation” </b> seems to imply less of a
problem and more of an explanation. <b> Alan? </b> </span></p>
<p><span> </span></p>
<p><span>From this perspective, as a Kepler w/Jython 2.5.2
user, I certainly need to understand what seemed to be
deemed an issue in being able to upgrade to Jython 2.5.2
due to the backward incompatibility (particularly as it
related to <b>PyJavaInstance</b>), to you being able to
fairly easily upgrade after all. Why did you not run into
an issue with <b>PyJavaInstance</b> in Jython 2.5.2? <b>
Are we missing some functionality that users need to be
aware of? </b> </span></p>
<p><span> </span></p>
<p> <span>Back to my original intent of Eclipse IDE-based
development of actors in Kepler/Ptolemy using Jython.</span>
<span> In a purely technical context, I am more comfortable
using Jython than I am Java. Based upon my questions to
the Jython User’s Group, I suspect that Alan and Josh are
rolling their eyes at this comment! </span><span>J</span><span>
This is my primary motivation behind wanting to
standardize on developing Python actors in Jython for
Kepler. My company, Nimbis Services, is also
standardizing on the Jython Django web framework, and
we’re thinking very hard about when we will begin a full
evaluation of Scala (a JVM functional programming
language). </span></p>
<p><span> </span></p>
<p><span>I am thinking that all I need to do is to take the
Ptolemy PythonActor source code and take a look at the
Java code for that actor and recode the actor in Jython
(Let’s call this new actor JythonActor) from within
Eclipse. I’d like a suggestion from Josh or Alan
regarding architecturally how they would address the
following issue: </span></p>
<p><span> </span></p>
<p><span>Using a Jython package, or function call, or
interface (probably not applicable in Jython), have the
newly coded JythonActor call the externally developed
“functional core” of the Python script that would
effectively “customize” the PythonActor according to the
Jython script’s behavior. This way I would only develop
my Jython script packages and then integrate these into
the newly coded JythonActor through say a port parameter.
Better yet, how about some sort of XML import solution
that would identify the Jython code that “decorates” the
JythonActor’s functionality. I need a good suggestion on
how to do this elegantly such that it looks like someone
with serious programming skills thought it through and not
kluge code from a chip designer. </span></p>
<p><span> </span></p>
<p><span>At present, the PythonActor solution is not
integrated into the full functional Eclipse-based JVM flow
due to the Java implementation. I have become far too
reliant upon debugging my Jython code through the Eclipse
IDE and the interpretive nature of Jython to not have this
working flawlessly. </span></p>
<p><span> </span></p>
<p><span>Please let me know what each you think of my
JythonActor approach. </span></p>
<p><span> </span></p>
<p><span>Alan, Josh…Christopher is particularly interested in
addressing Jython licensing issues. I get the gist of
what he is after here, but I have simply not been part of
any of this, so I have to defer to kind attention on this
subject. </span></p>
<p><span> </span></p>
<p><span>Kind regards, Marc </span></p>
<div><span> </span></div>
<p><b><span>[J. Marc] </span></b></p>
<p><b><span>> OK…please connect me with one of the Jython
2.2 to 2.5 developers. I </span></b></p>
<p><b><span>> will then work with them to determine how we
could most effectively </span></b></p>
<p><b><span>> migrate Kepler 2.2 from Jython 2.2 to Jython
2.5.2. </span></b></p>
<p><b><span>> </span></b></p>
<p><b><span>> I will be working with one of the
Kepler/Ptolemy II developers on this </span></b></p>
<p><b><span>> migration. </span></b></p>
<p><b><span> </span></b></p>
<p><b><span>This issue with PyJavaInstance when upgrading from
2.2 to 2.5 seems to be a common enough issue that it
requires documentation. </span></b></p>
<p><b><span> </span></b></p>
<p><b><span>I'm not going to get to it immediately myself, so
I've created an issue on the issue tracker for it, if
anyone feels like taking that up. </span></b></p>
<p><b><span> </span></b></p>
<p><b><span><a moz-do-not-send="true"
href="http://bugs.jython.org/issue1814">http://bugs.jython.org/issue1814</a>
</span></b></p>
<p><b><span> </span></b></p>
<p><b><span>Regards, </span></b></p>
<p><b><span> </span></b></p>
<p><b><span>Alan. </span></b></p>
<div><span> </span></div>
<div>
<p> <span>J. Marc Edwards, Lead Architect</span> <span> </span></p>
<p><i><span>Semiconductor Design Portals </span></i></p>
<p><b><span>Nimbis Services, Inc. </span></b></p>
<p><span>Cell - (919) 345-1021 </span></p>
<p><span>Fax - (919) 882-8602 </span></p>
<p><span>Skype - (919) 747-3775 </span></p>
<p><span><a moz-do-not-send="true"
href="mailto:jmarcedwards@gmail.com">jmarcedwards@gmail.com</a>
</span></p>
<p><span><a moz-do-not-send="true"
href="mailto:marc.edwards@nimbisservices.com">marc.edwards@nimbisservices.com</a>
</span></p>
</div>
<p><span> </span></p>
<div>
<div>
<p><b><span>From:</span></b><span> Christopher Brooks [<a
moz-do-not-send="true"
href="mailto:cxh@eecs.berkeley.edu">mailto:cxh@eecs.berkeley.edu</a>]
<br>
<b>Sent:</b> Saturday, November 05, 2011 2:59 PM<br>
<b>To:</b> <a moz-do-not-send="true"
href="mailto:marc.edwards@nimbisservices.com">marc.edwards@nimbisservices.com</a><br>
<b>Cc:</b> J. Marc Edwards; <a moz-do-not-send="true"
href="mailto:kepler-users@kepler-project.org">kepler-users@kepler-project.org</a><br>
<b>Subject:</b> Re: [kepler-users] Python execution
within the Kepler Python actor... </span></p>
</div>
</div>
<p> </p>
<p>Hi Marc,<br>
I updated Jython to 2.5.2, it was not that hard, updating
the license files took the most time.<br>
<br>
I have a few of misgivings about Jython that might be good
lessons for Ptolemy and Kepler:<br>
<br>
* Sadly, ptII/lib/jython.jar went from about 1Mb to 10Mb.
Does this mean that Jython-2.5.2 is 10 times better than
Jython-2.2.1?<br>
If jython is supposed to be a scripting language, then why
is it so large?<br>
This seems to be a common trend where nice small languages
get more and more features.<br>
As an aside about Perl, see <br>
Is Perl Better Than a Randomly Generated Programming
Language? at<br>
<a moz-do-not-send="true"
href="http://developers.slashdot.org/story/11/10/27/213231/is-perl-better-than-a-randomly-generated-programming-language">http://developers.slashdot.org/story/11/10/27/213231/is-perl-better-than-a-randomly-generated-programming-language</a><br>
<br>
For comparison purposes, Ptolemy's ptsupport.jar is 3.5Mb
and a standalone Ptolemy demo including the GUI is 6.5Mb in
jars.<br>
<br>
Lesson: we need to keep an eye on code bloat and be able to
deploy small run times.<br>
<br>
* Another issue with Jython-2.5.2 is that because they
removed org.python.core.PyJavaInstance some time after
Jython-2.2.1, they should have released Jython-2.5.2 as
Jython-3.x. Most projects bump up the major version number
when there are incompatibilities.<br>
<br>
Lesson: Ptolemy bumps up the major version number with each
~yearly release. Ptolemy has backward compatibility
filters. We do sometimes remove old code, but only with
major versions.<br>
<br>
* The Jython license situation is a mess.<br>
<a moz-do-not-send="true"
href="http://www.jython.org/license.html">http://www.jython.org/license.html</a>
lists these licenses<br>
- The Python Software Foundation License Version 2, which
according to Wikipedia is a BSD-style license<br>
- The Jython-2.0 and 2.1 license, which is similar to a
BSD-style license<br>
- The JPython 1.1.x license, which is similar to BSD-style
license<br>
<br>
The software ships with these licenses in the LICENSE.txt
file.<br>
<br>
However, LICENSE_CPython.txt and LICENSE_Apache.txt are
included. There is no mention as to what code actually uses
those licenses.<br>
LICENSE_CPython.txt includes four copyrights: <br>
- Python Software Foundation License Version 2<br>
- BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0<br>
- CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1<br>
- CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2<br>
The last three look similar to BSD, but have various
requirements.<br>
<br>
I'll submit a bug report to Jython to get them to update
their site.<br>
<br>
Lesson: I'm not sure how Ptolemy and Kepler can avoid a
similar complexity issue. I've been working on updating our
license file and<br>
we have a way to determine what licenses are used by a
particular configuration.<br>
<a moz-do-not-send="true"
href="http://ptolemy.eecs.berkeley.edu/ptolemyII/ptII8.0/copyright.htm">http://ptolemy.eecs.berkeley.edu/ptolemyII/ptII8.0/copyright.htm</a>
<br>
lists 7 licenses used by Ptiny, a small configuration of
Ptolemy II. One of those 7 is the Jython-2.2.1 license,
which is similar to the Jython-2.5.2 license.<br>
The Kepler configuration of Ptolemy II uses 15 licenses in
the Ptolemy II code.<br>
<br>
_Christopher<br>
<br>
On 11/5/11 9:15 AM, J. Marc Edwards wrote: </p>
<p><span>Christopher:</span> </p>
<p><span> </span> </p>
<p><span>I suspect that I can simply code an entire actor
extending the respective classes directly in Jython.</span>
</p>
<p><span> </span> </p>
<p><span>That is what I am thinking. Please let me know what
you think of this strategy.</span> </p>
<p><span> </span> </p>
<p><span>Of course, while I do this, I want to migrate a
Kepler development tree to use Jython 2.5.2, which I will
need your assistance in completing.</span> </p>
<p><span> </span> </p>
<p><span>Let’s talk on the phone on Monday.</span> </p>
<p><span> </span> </p>
<p><span>Regards, Marc</span> </p>
<div>
<p> <span>J. Marc Edwards, Lead Architect</span> </p>
<p><i><span>Semiconductor Design Portals</span></i> </p>
<p><b><span>Nimbis Services, Inc.</span></b> </p>
<p><span>Cell - (919) 345-1021</span> </p>
<p><span>Fax - (919) 882-8602</span> </p>
<p><span>Skype - (919) 747-3775</span> </p>
<p><span><a moz-do-not-send="true"
href="mailto:jmarcedwards@gmail.com">jmarcedwards@gmail.com</a></span>
</p>
<p><span><a moz-do-not-send="true"
href="mailto:marc.edwards@nimbisservices.com">marc.edwards@nimbisservices.com</a></span>
</p>
</div>
<p><span> </span> </p>
<div>
<div>
<p><b><span>From:</span></b><span> Christopher Brooks [<a
moz-do-not-send="true"
href="mailto:cxh@eecs.berkeley.edu">mailto:cxh@eecs.berkeley.edu</a>]
<br>
<b>Sent:</b> Friday, November 04, 2011 9:00 PM<br>
<b>To:</b> <a moz-do-not-send="true"
href="mailto:marc.edwards@nimbisservices.com">marc.edwards@nimbisservices.com</a><br>
<b>Cc:</b> <a moz-do-not-send="true"
href="mailto:kepler-users@kepler-project.org">kepler-users@kepler-project.org</a><br>
<b>Subject:</b> Re: [kepler-users] Python execution
within the Kepler Python actor...</span> </p>
</div>
</div>
<p> </p>
<p>Hi Marc,<br>
<br>
On 11/4/11 2:09 PM, J. Marc Edwards wrote: </p>
<p>I need a little help in integrating my Jython/Python code
into the Python actor.<br>
<br>
When I double-click on the Python actor in the
PythonDialogExample, a window with the Python code appears.
I can of course edit the code from within this window.
However, I want to perform my code development and editing
from within my Eclipse environment from my Kepler
development build. </p>
<p>I don't know that much about Python, but I believe that you
could use the Python import facility to find imports.<br>
I just added text to the Kepler Jython page about this, see:<br>
<a moz-do-not-send="true"
href="https://kepler-project.org/developers/reference/python-and-kepler#how-jython-finds-imports">https://kepler-project.org/developers/reference/python-and-kepler#how-jython-finds-imports</a><br>
<br>
Note that I found a few other references on the web,
included what appears to be people who are using the full
version of Python (not Jython) with Kepler.<br>
<br>
<br>
</p>
<p>When I "open the actor", the beginning of the file has some
Javadoc as well as what appear to be some unmatched XML
elements (<p>), along with some matching XML element
tags (</pre>) (does this correspond to some pre-fire
method?). </p>
<p>When you open the actor, you are seeing the Java code that
implements the PythonActor. The <p> tags are html
tags used in the javadoc comments of the Java file. All of
the instances of the PythonActor share the same Java code,
but may have different Python code.<br>
<br>
<br>
</p>
<p>After this all of the Java code for the actor follows with
the standard initialize(), stop(), stopFire(),
preinitialize(), terminate(), etc, methods.<br>
<br>
I do see in the Java code where there is a PythonScript
method that accepts a CompositeEntity where a script
template is provided where I am supposing a long Python
string in the script.setExpression is defined.<br>
<br>
However, what I would like to do is simply include my Jython
module within my Kepler build and debug my Jython code in
connection with my overall workflow.<br>
<br>
Can someone tell me how to go about achieving this
objective? </p>
<p>It looks like Jython uses sys.path to find imports. I
included a Ptolemy II model that opens in the devel version
of Kepler that lists the contents of sys.path. For further
information about sys.path, see<br>
<br>
<a moz-do-not-send="true"
href="http://jythonpodcast.hostjava.net/jythonbook/en/1.0/ModulesPackages.html">http://jythonpodcast.hostjava.net/jythonbook/en/1.0/ModulesPackages.html</a><br>
<br>
_Christopher<br>
<br>
<br>
</p>
<p><br>
Thanks, Marc </p>
<div>
<p>-- <br>
<br>
<br>
</p>
<p><span>J. Marc Edwards</span><span><br>
Lead Architect - Semiconductor Design Portals</span><br>
<span>Nimbis Services, Inc.</span><br>
<span>Skype: (919) 747-3775<br>
Cell: (919) 345-1021<br>
Fax: (919) 882-8602</span><br>
<span><a moz-do-not-send="true"
href="mailto:marc.edwards@nimbisservices.com">marc.edwards@nimbisservices.com</a><br>
<a moz-do-not-send="true"
href="http://www.nimbisservices.com">www.nimbisservices.com</a></span>
</p>
</div>
<p><br>
<br>
<br>
<br>
</p>
<pre>_______________________________________________ </pre>
<pre>Kepler-users mailing list </pre>
<pre><a moz-do-not-send="true" href="mailto:Kepler-users@kepler-project.org">Kepler-users@kepler-project.org</a> </pre>
<pre><a moz-do-not-send="true" href="http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users">http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users</a> </pre>
<p><br>
<br>
<br>
</p>
<pre>-- </pre>
<pre>Christopher Brooks, PMP University of California </pre>
<pre>CHESS Executive Director US Mail: 337 Cory Hall </pre>
<pre>Programmer/Analyst CHESS/Ptolemy/Trust Berkeley, CA 94720-1774 </pre>
<pre>ph: 510.643.9841 (Office: 545Q Cory) </pre>
<pre>home: (F-Tu) 707.665.0131 cell: 707.332.0670 </pre>
<p><br>
<br>
</p>
<pre>-- </pre>
<pre>Christopher Brooks, PMP University of California </pre>
<pre>CHESS Executive Director US Mail: 337 Cory Hall </pre>
<pre>Programmer/Analyst CHESS/Ptolemy/Trust Berkeley, CA 94720-1774 </pre>
<pre>ph: 510.643.9841 (Office: 545Q Cory) </pre>
<pre>home: (F-Tu) 707.665.0131 cell: 707.332.0670 </pre>
</div>
</blockquote>
<br>
<pre>--
Christopher Brooks, PMP University of California
CHESS Executive Director US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust Berkeley, CA 94720-1774
ph: 510.643.9841 (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670 </pre>
</blockquote>
</body>
</html>