From piccoli at fnal.gov Mon Jun 25 21:53:15 2007 From: piccoli at fnal.gov (Luciano Piccoli) Date: Mon, 25 Jun 2007 21:53:15 -0500 Subject: [Swift-user] Could not convert value to number: true Message-ID: <46807F9B.6050008@fnal.gov> Hi, I am getting the following error when running the swift script below: bash-3.00$ swift -dryrun age.swift -tc.file tc.data Swift V 0.0405 RunID: phvopumbeee40 Execution failed: org.globus.cog.karajan.workflow.KarajanRuntimeException: Could not convert value to number: true Is the multiplication an invalid operation in this case? Thanks, Luciano ---- age.swift ---- type student { string name; int age; float GPA; } type messagefile {} (messagefile t) sayAge(int age) { app { echo "Age: " @age stdout=@filename(t); } } student p[]; messagefile outfile <"age.txt">; int age = p[0].age * 4; outfile = sayAge(age); ------------------ ---- student.txt --- name age GPA Aaaa 23 3.1415 Bbbb 12 2.7212 Cccc 25 4.456 ------------------- From benc at hawaga.org.uk Mon Jun 25 22:11:45 2007 From: benc at hawaga.org.uk (Ben Clifford) Date: Tue, 26 Jun 2007 03:11:45 +0000 (GMT) Subject: [Swift-user] Could not convert value to number: true In-Reply-To: <46807F9B.6050008@fnal.gov> References: <46807F9B.6050008@fnal.gov> Message-ID: Hi. The csv_mapper only maps the filename of datafiles into an array. It doesn't map actual data itself. So this: > type student { string name; int age; float GPA; > } > student p[]; says to make an array called p[], and the filename that indicates where data is stored for each field in student comes from each field in student.txt. Also, when you say this: > int age = p[0].age * 4; swift thinks that the data in p[0].age is stored in a disk file (because it is mapped) and in that case, can't multiple the contents of a file by a number. -- From hategan at mcs.anl.gov Mon Jun 25 22:09:19 2007 From: hategan at mcs.anl.gov (Mihael Hategan) Date: Mon, 25 Jun 2007 22:09:19 -0500 Subject: [Swift-user] Could not convert value to number: true In-Reply-To: <46807F9B.6050008@fnal.gov> References: <46807F9B.6050008@fnal.gov> Message-ID: <1182827359.17489.5.camel@blabla.mcs.anl.gov> Mappers don't populate data structures with values. They can indicate the files where data can be found. Try this: ---------------- type student { string name; int age; float GPA; } type messagefile {} (messagefile t) sayAge(string file) { app { echo "Age: " file stdout=@filename(t); } } student p[]; messagefile outfile <"age.txt">; string f = @filename(p[0].name); outfile=sayAge(f); ------------------ And you'll get: bash-3.1$ cat age.txt Age: Aaaa As for doing what you want, I have to think about it. Mihael On Mon, 2007-06-25 at 21:53 -0500, Luciano Piccoli wrote: > Hi, > > I am getting the following error when running the swift script below: > > bash-3.00$ swift -dryrun age.swift -tc.file tc.data > Swift V 0.0405 > RunID: phvopumbeee40 > Execution failed: > org.globus.cog.karajan.workflow.KarajanRuntimeException: > Could not convert value to number: true > > Is the multiplication an invalid operation in this case? > Thanks, > Luciano > > ---- age.swift ---- > type student { > string name; > int age; > float GPA; > } > > type messagefile {} > > (messagefile t) sayAge(int age) { > app { > echo "Age: " @age stdout=@filename(t); > } > } > > student p[]; > > messagefile outfile <"age.txt">; > > int age = p[0].age * 4; > > outfile = sayAge(age); > ------------------ > > ---- student.txt --- > name age GPA > Aaaa 23 3.1415 > Bbbb 12 2.7212 > Cccc 25 4.456 > ------------------- > _______________________________________________ > Swift-user mailing list > Swift-user at ci.uchicago.edu > http://mail.ci.uchicago.edu/mailman/listinfo/swift-user > From piccoli at fnal.gov Mon Jun 25 22:51:45 2007 From: piccoli at fnal.gov (Luciano Piccoli) Date: Mon, 25 Jun 2007 22:51:45 -0500 Subject: [Swift-user] Could not convert value to number: true In-Reply-To: References: <46807F9B.6050008@fnal.gov> Message-ID: <46808D51.8070309@fnal.gov> > Also, when you say this: > > >> int age = p[0].age * 4; >> > > swift thinks that the data in p[0].age is stored in a disk file (because > it is mapped) and in that case, can't multiple the contents of a file by a > number. > What happens in the following cases? int age = p[0].age; outfile = sayAge (age); Does the variable age gets read from the file at the first line? Is it an integer at that point or is it still a reference to the file? If the variable age is then used later the conversion error comes up again: int age = p[0].age; int age2 = age * 2; outfile = sayAge (age); Thanks, Luciano From benc at hawaga.org.uk Mon Jun 25 23:49:51 2007 From: benc at hawaga.org.uk (Ben Clifford) Date: Tue, 26 Jun 2007 04:49:51 +0000 (GMT) Subject: [Swift-user] Could not convert value to number: true In-Reply-To: <46808D51.8070309@fnal.gov> References: <46807F9B.6050008@fnal.gov> <46808D51.8070309@fnal.gov> Message-ID: On Mon, 25 Jun 2007, Luciano Piccoli wrote: > Does the variable age gets read from the file at the first line? Is it an > integer at that point or is it still a reference to the file? The content of the file is never read into Swift itself. Swift will track files so that when you run an app block, you can refer to files there using the @filename construct (or equivalently, @ shorthand). So in: > (messagefile t) sayAge(int age) { > app { > echo "Age: " @age stdout=@filename(t); > } > } @age and @filename(t) will evaluate to the filename of the 'age' or 't' datafiles. If swift decides to run 'echo' on a different machine it will move those files to/from that remote machine and ensure that @age and @filename(t) evaluate to the appropriate remote filenames. But it won't read the contents of those files into a variable for evaluation. -- From piccoli at fnal.gov Tue Jun 26 20:25:27 2007 From: piccoli at fnal.gov (Luciano Piccoli) Date: Tue, 26 Jun 2007 20:25:27 -0500 Subject: [Swift-user] Could not convert value to number: true In-Reply-To: References: <46807F9B.6050008@fnal.gov> <46808D51.8070309@fnal.gov> Message-ID: <4681BC87.4060402@fnal.gov> Thank you for the clarification. My goal in using the csv_mapper was to extract out the from the swift script all hardcoded physics parameters, so that the same swift file could be reused on different configurations without changes. A second option is to pass all the parameters via the command line, which I wanted to avoid. Well, the actual swift command line can be wrapped in a shell script so the end user does not have to deal with all the parameters. Are there - or will there be - other ways to pass parameters to a swift script? For example, if these parameters are kept in a database, could they be accessed via a database mapper? Yong mentioned plans about a database mapper last time he came to FNAL. Thanks, Luciano Ben Clifford wrote: > On Mon, 25 Jun 2007, Luciano Piccoli wrote: > > >> Does the variable age gets read from the file at the first line? Is it an >> integer at that point or is it still a reference to the file? >> > > The content of the file is never read into Swift itself. Swift will track > files so that when you run an app block, you can refer to files there > using the @filename construct (or equivalently, @ shorthand). > > So in: > > >> (messagefile t) sayAge(int age) { >> app { >> echo "Age: " @age stdout=@filename(t); >> } >> } >> > > @age and @filename(t) will evaluate to the filename of the 'age' or 't' > datafiles. > > If swift decides to run 'echo' on a different machine it will move those > files to/from that remote machine and ensure that @age and @filename(t) > evaluate to the appropriate remote filenames. > > But it won't read the contents of those files into a variable for > evaluation. > >