[Swift-commit] r2959 - in trunk/src/org/griphyn/vdl/karajan/lib: . swiftscript
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Tue Jun 16 10:20:21 CDT 2009
Author: benc
Date: 2009-06-16 10:20:21 -0500 (Tue, 16 Jun 2009)
New Revision: 2959
Modified:
trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
Log:
Add logging of provenance information for @functions.
Modified: trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java 2009-06-16 15:19:51 UTC (rev 2958)
+++ trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java 2009-06-16 15:20:21 UTC (rev 2959)
@@ -572,4 +572,19 @@
return tc;
}
}
+
+ private static int provenanceIDCount = 451000;
+
+ public static synchronized int nextProvenanceID() {
+ return provenanceIDCount++;
+ }
+
+ public static void logProvenanceResult(int id, DSHandle result, String name) throws ExecutionException {
+ logger.info("FUNCTION id="+id+" name="+name+" result="+result.getIdentifier());
+ }
+
+ public static void logProvenanceParameter(int id, DSHandle parameter, String paramName) throws ExecutionException {
+ logger.info("FUNCTIONPARAMETER id="+id+" input="+parameter.getIdentifier()+" name="+paramName);
+
+ }
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java 2009-06-16 15:19:51 UTC (rev 2958)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java 2009-06-16 15:20:21 UTC (rev 2959)
@@ -35,7 +35,11 @@
String str = breader.readLine();
freader.close();
Double i = new Double(str);
- return RootDataNode.newNode(Types.FLOAT, i);
+ DSHandle result = RootDataNode.newNode(Types.FLOAT, i);
+ int provid = VDLFunction.nextProvenanceID();
+ VDLFunction.logProvenanceResult(provid, result, "extractint");
+ VDLFunction.logProvenanceParameter(provid, handle, "filename");
+ return result;
}
}
catch (IOException ioe) {
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java 2009-06-16 15:19:51 UTC (rev 2958)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java 2009-06-16 15:20:21 UTC (rev 2959)
@@ -6,6 +6,7 @@
import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
import org.griphyn.vdl.karajan.VDL2FutureException;
import org.griphyn.vdl.karajan.lib.VDLFunction;
+import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.RootDataNode;
import org.griphyn.vdl.type.Types;
@@ -17,7 +18,11 @@
public Object function(VariableStack stack) throws ExecutionException {
try {
String s = argList(filename(stack), true);
- return RootDataNode.newNode(Types.STRING, s);
+ DSHandle result = RootDataNode.newNode(Types.STRING, s);
+ int provid = VDLFunction.nextProvenanceID();
+ VDLFunction.logProvenanceParameter(provid, (DSHandle) PA_VAR.getValue(stack), "input");
+ VDLFunction.logProvenanceResult(provid, result, "filename");
+ return result;
} catch(VDL2FutureException ve) {
synchronized(ve.getHandle().getRoot()) {
throw new FutureNotYetAvailable(addFutureListener(stack, ve.getHandle()));
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java 2009-06-16 15:19:51 UTC (rev 2958)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java 2009-06-16 15:20:21 UTC (rev 2959)
@@ -31,6 +31,10 @@
} catch (InvalidPathException e) {
throw new ExecutionException("Unexpected invalid path exception",e);
}
+ int provid = VDLFunction.nextProvenanceID();
+ logProvenanceParameter(provid, (DSHandle) PA_VAR.getValue(stack), "input");
+ logProvenanceResult(provid, returnArray, "filenames");
+
return returnArray;
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java 2009-06-16 15:19:51 UTC (rev 2958)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java 2009-06-16 15:20:21 UTC (rev 2959)
@@ -15,9 +15,12 @@
import org.globus.cog.karajan.workflow.ExecutionException;
import org.globus.cog.karajan.workflow.nodes.functions.AbstractFunction;
import org.griphyn.vdl.karajan.lib.SwiftArg;
+import org.griphyn.vdl.karajan.lib.VDLFunction;
+import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.RootDataNode;
import org.griphyn.vdl.type.Types;
+
public class FnArg extends AbstractFunction {
public static final String PARSED_ARGS = "cmdline:named";
@@ -65,7 +68,14 @@
throw new ExecutionException("Missing command line argument: " + name);
}
else {
- return RootDataNode.newNode(Types.STRING, value);
+ DSHandle result = RootDataNode.newNode(Types.STRING, value);
+ int provid=VDLFunction.nextProvenanceID();
+ VDLFunction.logProvenanceResult(provid, result, "arg");
+ VDLFunction.logProvenanceParameter(provid, P_NAME.getRawValue(stack), "name");
+ if(P_VALUE.getRawValue(stack) != null) {
+ VDLFunction.logProvenanceParameter(provid, P_VALUE.getRawValue(stack), "value");
+ }
+ return result;
}
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2009-06-16 15:19:51 UTC (rev 2958)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2009-06-16 15:20:21 UTC (rev 2959)
@@ -1,5 +1,7 @@
package org.griphyn.vdl.karajan.lib.swiftscript;
+import java.io.IOException;
+
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -18,11 +20,11 @@
import org.griphyn.vdl.mapping.RootDataNode;
import org.griphyn.vdl.type.NoSuchTypeException;
import org.griphyn.vdl.type.Types;
+import org.griphyn.vdl.util.VDL2Config;
-
public class Misc extends FunctionsCollection {
- private static final Logger logger = Logger.getLogger(FunctionsCollection.class);
+ private static final Logger logger = Logger.getLogger(Misc.class);
public static final SwiftArg PA_INPUT = new SwiftArg.Positional("input");
public static final SwiftArg PA_PATTERN = new SwiftArg.Positional("regexp");
@@ -58,6 +60,7 @@
public DSHandle swiftscript_strcat(VariableStack stack) throws ExecutionException, NoSuchTypeException,
InvalidPathException {
Object[] args = SwiftArg.VARGS.asArray(stack);
+ int provid = VDLFunction.nextProvenanceID();
StringBuffer buf = new StringBuffer();
for (int i = 0; i < args.length; i++) {
buf.append(TypeUtil.toString(args[i]));
@@ -65,11 +68,23 @@
DSHandle handle = new RootDataNode(Types.STRING);
handle.setValue(buf.toString());
handle.closeShallow();
+ try {
+ if(VDL2Config.getConfig().getProvenanceLog()) {
+ DSHandle[] provArgs = SwiftArg.VARGS.asDSHandleArray(stack);
+ for (int i = 0; i < provArgs.length; i++) {
+ VDLFunction.logProvenanceParameter(provid, (DSHandle)provArgs[i], ""+i);
+ }
+ VDLFunction.logProvenanceResult(provid, handle, "strcat");
+ }
+ } catch(IOException ioe) {
+ throw new ExecutionException("When logging provenance for strcat", ioe);
+ }
return handle;
}
public DSHandle swiftscript_strcut(VariableStack stack) throws ExecutionException, NoSuchTypeException,
InvalidPathException {
+ int provid = VDLFunction.nextProvenanceID();
String inputString = TypeUtil.toString(PA_INPUT.getValue(stack));
String pattern = TypeUtil.toString(PA_PATTERN.getValue(stack));
if (logger.isDebugEnabled()) {
@@ -95,6 +110,9 @@
DSHandle handle = new RootDataNode(Types.STRING);
handle.setValue(group);
handle.closeShallow();
+ VDLFunction.logProvenanceResult(provid, handle, "strcut");
+ VDLFunction.logProvenanceParameter(provid, PA_INPUT.getRawValue(stack), "input");
+ VDLFunction.logProvenanceParameter(provid, PA_PATTERN.getRawValue(stack), "pattern");
return handle;
}
@@ -111,6 +129,10 @@
el.setValue(split[i]);
}
handle.closeDeep();
+ int provid=VDLFunction.nextProvenanceID();
+ VDLFunction.logProvenanceResult(provid, handle, "strsplit");
+ VDLFunction.logProvenanceParameter(provid, PA_INPUT.getRawValue(stack), "input");
+ VDLFunction.logProvenanceParameter(provid, PA_PATTERN.getRawValue(stack), "pattern");
return handle;
}
@@ -142,6 +164,12 @@
DSHandle handle = new RootDataNode(Types.STRING);
handle.setValue(group);
handle.closeShallow();
+
+ int provid=VDLFunction.nextProvenanceID();
+ VDLFunction.logProvenanceResult(provid, handle, "regexp");
+ VDLFunction.logProvenanceParameter(provid, PA_INPUT.getRawValue(stack), "input");
+ VDLFunction.logProvenanceParameter(provid, PA_PATTERN.getRawValue(stack), "pattern");
+ VDLFunction.logProvenanceParameter(provid, PA_TRANSFORM.getRawValue(stack), "transform");
return handle;
}
@@ -151,7 +179,9 @@
DSHandle handle = new RootDataNode(Types.INT);
handle.setValue(new Double(Integer.parseInt(inputString)));
handle.closeShallow();
+ int provid=VDLFunction.nextProvenanceID();
+ VDLFunction.logProvenanceResult(provid, handle, "toint");
+ VDLFunction.logProvenanceParameter(provid, PA_INPUT.getRawValue(stack), "string");
return handle;
}
}
-
More information about the Swift-commit
mailing list