Re: [Pharo-users] Voyage: Circular references

2013-07-20 Thread Stéphane Ducasse
this is a nice case for the tutorial :)

Stef

On Jul 19, 2013, at 12:56 PM, Sabine Knöfel  wrote:

> Hi Esteban, 
> 
> thanks! 
> 
> I think the solution of Bernat will not be enough for me. 
> I added the class methods isVoyageRoot to the root objects (like trip, 
> country and so on). 
> 
> But I have instances which should never be persistent, e.g. the 
> country I mentioned. The Country has currencies and expense rates and 
> this is a lot of stuff...this should be only transient in the image. 
> 
> The transient country is referenced by persistent instances of trip. 
> (countrie does naturally not point to trips) 
> 
> Trip (persistant) -> Country (transient) 
> 
> If I try to save a trip, voyage at some point enters 
> >>rawReference: description: 
> and there, it looks whether anObject (a country) isNew: 
> isNew means the other object, the country has an _id (mongo id). 
> 
> The country does not have an id and for this reason, voyage tries to 
> make it persistent although its class has isVogageRoot false. 
> And than the system enters a point where it tries to make so many 
> objects persistent that the image does not respond anymore. 
> 
> So, my question is: is it possible to define 
> "In class trip, there is an inst var country -> voyage please save 
> only a symbol here" 
> and 
> "voyage, if loading a trip, for inst var country, do shting" 
> 
> Sure, I could save symbols within the trips country inst var all the time 
> and get the country it if needed, but it would be nicer if voyage coud 
> do that for me .-) 
> 
> Sabine 
> 
> 
> 
> 
> 
> On Fri, Jul 19, 2013 at 11:52 AM, EstebanLM [via Smalltalk] 
> <[hidden email]> wrote:
> 
> > Hi Sabine, 
> > 
> > If Bernat help is not enough, I would like to have some more insight on 
> > your 
> > problem, so If you can put here a better description of your model and the 
> > problem you are having, I will have a look :) 
> > 
> > Esteban 
> > 
> > On Jul 19, 2013, at 10:42 AM, Bernat Romagosa <[hidden email]> wrote: 
> > 
> > Hi Sabine! 
> > 
> > If you want an object to be referenced by another, and not embedded in it, 
> > you need to give that object root entity. As a root, the object will have a 
> > collection of its own, and will be referenced by other objects by id. If 
> > the 
> > object is not root, it will be embedded inside the referring object as a 
> > property. 
> > 
> > So, to be safe, always set #isVoyageRoot to return true at class side of 
> > all 
> > objects you don't want to have embedded. In general, "big enough" objects 
> > who are referenced by different objects should be root. 
> > 
> > In my case, I had a centre which had users which had centres. Users also 
> > had 
> > projects, and projects also had users. Big mess, I know. Besides that, all 
> > users, centres and projects had profiles. My solution was to make centres, 
> > projects and users be roots, and let only the profiles be embedded. 
> > 
> > I hope this helped! 
> > 
> > Bernat. 
> > 
> > 
> > 2013/7/19 Sabine Knöfel <[hidden email]> 
> >> 
> >> Hi Esteban, 
> >> 
> >> yes, now the Rectangle Example works after doing the reset. 
> >> 
> >> But saving my model still leads to a non responding image because 
> >> Voyage is trying to write json for all model stuf deep deep deep and 
> >> circular. Perhaps same like: 
> >> http://forum.world.st/Voyage-Circular-references-td4691940.html#a4699436
> >> 
> >> I dont know anything about Magritte (yet) and I need a hint what to 
> >> define in my model so that it stops creating json at certain points 
> >> and creates only e.g. a Symbol. 
> >> 
> >> Example: My model instance  of trip has a connection to an instance of 
> >> country. The country should not be written in json with all its 
> >> definitions. Voyage should only write e.g. #germany in the json and 
> >> later, when getting the instance back from the database, I want to 
> >> reassign the trip to the country. 
> >> 
> >> I already implemented this stuff when working witk Mongotalk the last 
> >> months and it worked fine. But my question yesterday: 
> >> 
> >> http://forum.world.st/MongoDB-open-close-in-production-singleton-or-not-td4699322.html
> >> lead to my impression that I should use voyage. 
> >> 
> >> So, how can I define the "borders"? 
> >> 
> >> Sabine 
> >> 
> >> On Thu, Jul 18, 2013 at 7:45 PM, EstebanLM [via Smalltalk] 
> >> <[hidden email]> wrote: 
> >> 
> >> > Hi Sabine, 
> >> > 
> >> > Probably you do not missed anything. 
> >> > Probably I missed to update the voyage configuration :) 
> >> > 
> >> > can you try doing 
> >> > 
> >> > VOMongoRepository allInstancesDo: #reset. 
> >> > 
> >> > before trying again? 
> >> > 
> >> > Cheers, 
> >> > Esteban 
> >> > 
> >> > On Jul 18, 2013, at 6:31 PM, Sabine Knöfel <[hidden email]> wrote: 
> >> 
> >> > 
> >> >> I found this: 
> >> >> http://smallworks.eu/web/blog/2013-06-14-voyage-the-adventure
> >> >> 
> >> >> Chapter "Enhancing storage" 
> >> >> But if I add the 3+1 methods to Rectangle, and 

Re: [Pharo-users] [ANN] BioSmalltalk published in Bioinformatics Journal

2013-07-20 Thread Marcus Denker

On Jul 19, 2013, at 6:09 PM, Alain Busser  wrote:

> That's great, even faster than bioPython, and thanks to Petit Parser. That's 
> great!
> 
> I hope it will be on good place on Pharo's web site...
> 
I will add it to the publication lists and make a news entry...


> 
> On Wed, Jul 17, 2013 at 11:14 PM, Hernán Morales Durand 
>  wrote:
> Hi Marcus,
> 
> Thank you for the comments, I have been checking the link distribution 
> conditions and they say people can access the article only from the Oxford 
> Journals website for academic purposes, so here it is:
> 
> http://bioinformatics.oxfordjournals.org/content/early/2013/07/09/bioinformatics.btt398.full.pdf?keytype=ref&ijkey=Y2j8jNeEKVNl0rD
> 
> Sorry for the inconvenience.
> Cheers,
> 
> Hernán
> 
> 
> 
> 2013/7/17 Marcus Denker 
> 
> On Jul 16, 2013, at 9:31 PM, Hernán Morales Durand  
> wrote:
> 
> > Doru, I can access the article through the "Full Text (PDF)" link at the 
> > right box titled "This Article". Maybe you have the right columns 
> > collapsed? There is an arrow button "Show all columns" if you cannot see 
> > the link.
> > Let me know.
> >
> 
> Publishing is the act of making Paper in-accessible to the Public (that's 
> where the name comes from).
> 
> So what all serious publishers allow you to do is to make the version that 
> you send them (not their version) available from your
> website and/or an online-archive of your employer,
> 
> It is very important to do that, as people will not jump through hoops to get 
> your paper (e.g. go to the library?).
> In the past I send emails to authors to get paper copies, but today I would 
> just *never* do that. If *you* don't make your
> paper available, why should I bother? i will just not read it and not cite it.
> 
> The journal publishing is just important for your CV and getting tenure and 
> things like that, the paper the people
> really *read* is the one they can download from your website.
> 
> Marcus
> 
> 



Re: [Pharo-users] Generate Bytecodes manually

2013-07-20 Thread Udo Schneider

I just stumbled over some IRBuilder behaviour which I'm not sure about.

1) Jump/Target Pairs
As far as I understood each jump target can only be used by one jump. So 
if multiple jumps need to jump to the same location I have to create 
multiple targets (one per jump) pointing to the same location.
I can work with this behavior just fine - I'm just wondering what's the 
rationale behind this restriction? IMHO the bytecode itself does not 
impose that restriction.


2) IR -> AST
I created some IR sequences which works perfectly fine as expected. 
However trying to get the compiled method's AST results in an endless 
loop. I assume this is expected behavior as the process IR -> AST only 
works for a subset of instruction sequences normally generated by 
Smalltalk code. But I just wanted to be sure.


Thanks,

Udo





Re: [Pharo-users] Generate Bytecodes manually

2013-07-20 Thread Marcus Denker

On Jul 20, 2013, at 8:59 PM, Udo Schneider  wrote:

> I just stumbled over some IRBuilder behaviour which I'm not sure about.
> 
> 1) Jump/Target Pairs
> As far as I understood each jump target can only be used by one jump. So if 
> multiple jumps need to jump to the same location I have to create multiple 
> targets (one per jump) pointing to the same location.
> I can work with this behavior just fine - I'm just wondering what's the 
> rationale behind this restriction? IMHO the bytecode itself does not impose 
> that restriction.
> 
It's not needed for the compiler...

> 2) IR -> AST
> I created some IR sequences which works perfectly fine as expected. However 
> trying to get the compiled method's AST results in an endless loop. I assume 
> this is expected behavior as the process IR -> AST only works for a subset of 
> instruction sequences normally generated by Smalltalk code. But I just wanted 
> to be sure.
> 
IR-> AST Is *NOT* there. (THere is no code that does IR ->AST).

there is just the old BC->OLD AST which only works on code compiled with the 
*OLD* compiler.

The decompielr right now is called when there is no byte code (the old 
decompiler).
This will be fixed soonish.

Marcus





Re: [Pharo-users] Generate Bytecodes manually

2013-07-20 Thread Udo Schneider

On 20.07.13 21:05, Marcus Denker wrote:

It's not needed for the compiler...
Thought so - I can work around it using the public IRBuilder API. So no 
problem.



The decompielr right now is called when there is no byte code (the old 
decompiler).
This will be fixed soonish.
Good to know - I'll stay tuned. For those sequences where the 
decompilation worked it was already quite impressive to see the 
Smalltalk code for something which was created in a totally different 
language :-)


Thanks,

Udo






[Pharo-users] Testing the OpenCalais web service

2013-07-20 Thread Hernán Morales Durand

I'm testing the OpenCalais web service. This is a web service which
needs an API key to be used (registering takes only 1 minute in
http://www.opencalais.com/APIkey). To check the service first I've used
a Python script, taken from [1]

import httplib2
import json
LOCAL_API_KEY = '' # Aquire this by registering at the Calais site
CALAIS_TAG_API = 'http://api.opencalais.com/tag/rs/enrich'
# Some sample text from a news story to pass to Calais for analysis
test_body = """
Some huge announcements were made at Apple's Worldwide Developer's
Conference Monday, including the new mobile operating system iOS 5, PC
software OS X Lion, and the unveiling of the iCloud.
"""
# header information need by Calais. For more info see
http://www.opencalais.com/documentation/calais-web-service-api/api-invocation/rest
headers = {
'x-calais-licenseID': LOCAL_API_KEY,
'content-type': 'text/raw',
'accept': 'application/json',
}
# Create your http object
http = httplib2.Http()
# Make the http post request, passing the body and headers as needed.
response, content = http.request(CALAIS_TAG_API, 'POST',
headers=headers, body=test_body)
jcontent = json.loads(content) # Parse the json return into a python dict
print json.dumps(jcontent, indent=4) # Pretty print the resulting
dictionary returned.

The Python script works fine for me. I have tried to translate the code
above, but my version in Pharo 2.0 using Zinc returns "I Read a
ZnResponse(415 Unsupported Media Type text/plain 365B)"

| httpClient localApiKey |
localApiKey := ''. " my API key "
httpClient := ZnClient new
logToTranscript;
url: 'http://api.opencalais.com/tag/rs/enrich';
method: #POST;
headerAt: 'x-calais-licenseID' put: localApiKey;
headerAt: 'accept' put: 'application/json';
headerAt: 'content-Type' put: 'text/raw';   
contents: 'Some huge announcements were made at Apple''s 
Worldwide
Developer''s Conference Monday, including the new mobile operating
system iOS 5, PC software OS X Lion, and the unveiling of the iCloud.'.
httpClient execute.

Additionally the request returns the following message:

'Document conversion error. Please make sure that the content-type
(passed through the paramsXML) matches this document contents.
[ErrorMessage:
com.clearforest.platform.system.CLFRuntimeException: There is no
converter for this type of URI
"file:/C:/CLFSW/v71/ct/bin/../../../v71/ct/var/dptemp/prvt/228295-app9/dp/papi/data/1374378595643-DF317E60-6634505.asc"
]'

From what I could see, a difference is the 'text/raw'
content-type is passed in Python's httplib2, but in Zinc is overriding
by 'text/plain' it in #acceptEntityDescription: ? Any hints?

Hernán

[1]
http://www.flagonwiththedragon.com/2011/06/08/dead-simple-python-calls-to-open-calais-api/