[kepler-dev] Modifying MoML files

Edward A. Lee eal at eecs.berkeley.edu
Tue Apr 10 18:20:29 PDT 2012


It occurs to me that if transforming models is what you are
after, you might want to take a look at this thesis on
model-based model transformation:

http://www.eecs.berkeley.edu/Pubs/TechRpts/2009/EECS-2009-77.html

All of the work described in that thesis is in the tree.
The basic idea is that Ptolemy models transform Ptolemy
models into other Ptolemy models...

Edward


On 4/10/12 5:08 PM, Derik Barseghian wrote:
> I wouldn't take the approach of writing a script to unzip, process MoML, and zip your KARs. I don't have much experience with the filters, but Kepler utilizes them; I'd look into how it does. I think a better approach would be to make your changes to your actor(s), addFilters to Kepler's list(s) as you deem fit in your module's Intialize class, and distribute a new version of your module. Users get the updated module, open their old KARs, and the filters will be applied to the MoML (if the user simply opens the KAR and makes no changes, they will be prompted to save when closing since these changes have been automatically applied). I believe this way you'll avoid issues to do with proper versioning/identification of objects. Kepler maintains LSIDs and derived from LSID lists for components, workflows and KARs. E.g. when you modify an actor, its LSID revision is incremented, the workflow's LSID is incremented, and when you save this workflow, the KAR gets a new LSID, and its
  m
>   anifest is updated appropriately.
>
> Derik
>
> On Apr 10, 2012, at 4:05 PM, Christopher Brooks wrote:
>
>> You've found the ptolemy/moml/filter classes which is how we handle
>> sorts of changes at Berkeley.
>>
>> My comments are interspersed with your message below.
>>
>> On 4/10/12 10:02 AM, Hogan, D. (GE Energy) wrote:
>>> What's the best way to modify MoML inside of kar files?  Should I use
>>> ptolemy.moml.MoMLParser, some other class in Kepler, standard tools
>>> (XSLT/DOM) or something else?
>> Unfortunately, MoML is not well structured xml.  This is because
>> of the<configure>  tag.  There is something in either the kepler email
>> archives or the ptolemy-hackers archives about this.
>>
>> I have a test at ptolemy/configs/test/validDemos.tcl
>> that strips out the<configure>  tags and runs a validating parser on the results.
>> However, the problem is that you need those configure tags for plotters etc.
>> So, using a validating parser will not be much help.
>>
>> You could use other XSLT tools as long as the tool does not require valid xml.
>>
>>>
>>> I'm trying to do two types of operations with MoML.  After I update
>>> source code for actors, I want to have a way to update all of the
>>> affected kar files.  This could be adding, removing or renaming ports
>>> and parameters or changing types and class names across all local kar
>>> files.  All of these operations appear to be supported as filters in the
>>> MoML parser.
>> Right, the ptolemy/moml/filter classes are the way to go here.
>> Let me know if the filters need any changes like accessor or reset methods.
>> You would need to write a script that unjars (I think) the .kar files, updates
>> the moml file and recreates the kar file.
>>
>>>    The second task is doing a diff on MoML files without GUI
>>> or documentation related elements.  The automated layout in the GUI is
>>> great, but small changes in the workflow can result in big changes in
>>> the layout.   If I give a kar to someone and they update it, I want to
>>> be able to see what changes they made besides GUI placement or
>>> documentation.  This also appears to be supported by MoMLParser since
>>> there are filters to remove parts of the file.
>> Right, ptolemy/moml/filter/RemoveGraphicalClasses.java will remove
>> the gui xml.  That class has a main() method so that it can be run from
>> the command line.
>>
>> To see if there are any changes, you could get part way there by
>> using RemoveGraphicalClasses, then, if necessary removing the
>> <configure>  tags and then using tool to do a diff
>>> When I tried ptolemy.moml.MoMLParser with
>>> org.kepler.moml.filter.BackwardCompatibility.initialize(), I get a lot
>>> of unnecessary changes.  It would cause problems if I checked in the
>>> MoML files and ran 'svn blame'.  I noticed there is a file
>>> ptolemy-kepler-2.3/src/adm/bin/updatemoml which calls
>>> ptolemy-kepler-2.3/src/adm/bin/updateMoMLFile.tcl and runs diff to see
>>> if there were any differences.  I don't think that would work properly
>>> on a MoML from Kepler because there would be many changes.
>>
>> I had forgotten about org.kepler.moml.filter.BackwardCompatibility, which
>> is found at ./core/src/org/kepler/moml/filter/BackwardCompatibility.java
>>
>> I'm not sure I totally understand your question, but are you saying that the
>> MoML files included in the Kepler .kar files change when the Kepler-specific
>> BackwardCompatibility filter is run on them?
>>
>> In Ptolemy II, we don't run the BackwardCompatibility filter on all the files
>> before a release.  In other words - the ptII tree includes files that would be
>> different if the BackwardCompatibility filter was run on them.  We partly
>> do this so that we can test the filters.  Another reason is so that we don't
>> have arbitrary changes in the change log.  Running the BackwardCompatibility
>> filter would make a number of changes which would make using 'svn blame'
>> less useful.
>>
>> You could either run the BackwardCompatibility filters on all the moml files in the kar
>> files and provide an updated release to your users or you could try running
>> the BackwardCompatibility filter after the fact and comparing the output.
>> In other words, for any given model, you would need to run the filter on the
>> moml file from the Kepler distribution and on the updated version.
>>
>> Kar files probably have a versioning system associated with them.
>> Ptolemy II updates the VersionAttribute in each file with the version of the PtolemyII
>> that is used.
>> There is also ptolemy/vergil/kernel/attributes/IDAttribute.java, which is not used
>> very much, but could be used to store version information.
>>
>> In general, library management is a big issue.  Ptolemy II uses Actor Oriented Classes,
>> where a model is declared to be a class definition and there are derived instances
>> that are what is actually run.  There are rules about what can be updated or deleted.
>>
>> _Christopher
>>>
>>> _______________________________________________
>>> Kepler-dev mailing list
>>> Kepler-dev at kepler-project.org
>>> http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-dev
>>
>> --
>> 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
>>
>> _______________________________________________
>> Kepler-dev mailing list
>> Kepler-dev at kepler-project.org
>> http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-dev
>
> _______________________________________________
> Kepler-dev mailing list
> Kepler-dev at kepler-project.org
> http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eal.vcf
Type: text/x-vcard
Size: 330 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-dev/attachments/20120410/eb55628c/attachment.vcf>


More information about the Kepler-dev mailing list