Skip to content

Commit 61c0a63

Browse files
committed
Update to new API from the interaction library.
1 parent fe5c37f commit 61c0a63

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

creole.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ along with this software. If not, see <http://www.gnu.org/licenses/>.
3737
<JAR>lib/httpcore-4.4.4.jar</JAR>
3838
<JAR>lib/httpcore-nio-4.4.4.jar</JAR>
3939
<JAR>lib/httpmime-4.5.2.jar</JAR>
40-
<JAR>lib/interaction-3.5.1.jar</JAR>
40+
<JAR>lib/interaction-3.8.jar</JAR>
4141
<JAR>lib/jdom-1.1.jar</JAR>
4242
<JAR>lib/jgrapht-0.6.0.jar</JAR>
4343
<JAR>lib/json-20160212.jar</JAR>

lib/interaction-3.5.1.jar

-16.2 KB
Binary file not shown.

lib/interaction-3.8.jar

16.5 KB
Binary file not shown.

src/gate/plugin/learningframework/engines/EnginePythonNetworksBase.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public abstract class EnginePythonNetworksBase extends Engine {
8888
* The setting for the [wrappername] wrapper home can be relative in which case it
8989
* will be resolved relative to the dataDirectory
9090
* @param dataDirectory
91+
* @param apply
9192
* @return
9293
*/
9394
protected File findWrapperCommand(File dataDirectory, boolean apply) {
@@ -180,7 +181,6 @@ protected void loadModel(File directory, String parms) {
180181
File commandFile = findWrapperCommand(directory, true);
181182
String modelFileName = new File(directory,MODEL_BASENAME).getAbsolutePath();
182183
finalCommand.add(commandFile.getAbsolutePath());
183-
finalCommand.add(wrapperhome);
184184
finalCommand.add(modelFileName);
185185
finalCommand.add(mode);
186186
finalCommand.add(nrClasses.toString());
@@ -195,7 +195,9 @@ protected void loadModel(File directory, String parms) {
195195
//System.err.println("Running: "+finalCommand);
196196
// Create a fake Model jsut to make LF_Apply... happy which checks if this is null
197197
model = MODEL_INSTANCE;
198-
process = new Process4JsonStream(directory,finalCommand);
198+
Map<String,String> env = new HashMap<>();
199+
env.put(ENV_WRAPPER_HOME, wrapperhome);
200+
process = Process4JsonStream.create(directory,env,finalCommand);
199201
}
200202

201203
@Override
@@ -232,7 +234,6 @@ public void trainModel(File dataDirectory, String instanceType, String parms) {
232234
String dataFileName = dataDirectory.getAbsolutePath()+File.separator;
233235
String modelFileName = new File(dataDirectory, MODEL_BASENAME).getAbsolutePath();
234236
finalCommand.add(commandFile.getAbsolutePath());
235-
finalCommand.add(wrapperhome);
236237
finalCommand.add(dataFileName);
237238
finalCommand.add(modelFileName);
238239
finalCommand.add(mode);
@@ -255,8 +256,9 @@ public void trainModel(File dataDirectory, String instanceType, String parms) {
255256
//}
256257
// Create a fake Model jsut to make LF_Apply... happy which checks if this is null
257258
model = MODEL_INSTANCE;
258-
259-
process = new ProcessSimple(dataDirectory,finalCommand);
259+
Map<String,String> env = new HashMap<String,String>();
260+
env.put(ENV_WRAPPER_HOME,wrapperhome);
261+
process = ProcessSimple.create(dataDirectory,env,finalCommand);
260262
process.waitFor();
261263
}
262264

src/gate/plugin/learningframework/engines/EngineSklearnBase.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ protected void loadModel(File directory, String parms) {
173173
File commandFile = findWrapperCommand(directory, true);
174174
String modelFileName = new File(directory,MODEL_BASENAME).getAbsolutePath();
175175
finalCommand.add(commandFile.getAbsolutePath());
176-
finalCommand.add(wrapperhome);
177176
finalCommand.add(modelFileName);
178177
// if we have a shell command prepend that, and if we have shell parms too, include them
179178
if(shellcmd != null) {
@@ -186,7 +185,9 @@ protected void loadModel(File directory, String parms) {
186185
//System.err.println("Running: "+finalCommand);
187186
// Create a fake Model jsut to make LF_Apply... happy which checks if this is null
188187
model = MODEL_INSTANCE;
189-
process = new Process4JsonStream(directory,finalCommand);
188+
Map<String,String> env = new HashMap<>();
189+
env.put(ENV_WRAPPER_HOME, wrapperhome);
190+
process = Process4JsonStream.create(directory,env,finalCommand);
190191
}
191192

192193
@Override
@@ -227,7 +228,6 @@ public void trainModel(File dataDirectory, String instanceType, String parms) {
227228
String dataFileName = dataDirectory.getAbsolutePath()+File.separator;
228229
String modelFileName = new File(dataDirectory, MODEL_BASENAME).getAbsolutePath();
229230
finalCommand.add(commandFile.getAbsolutePath());
230-
finalCommand.add(wrapperhome);
231231
finalCommand.add(dataFileName);
232232
finalCommand.add(modelFileName);
233233
finalCommand.add(sklearnClass);
@@ -249,8 +249,9 @@ public void trainModel(File dataDirectory, String instanceType, String parms) {
249249
//}
250250
// Create a fake Model jsut to make LF_Apply... happy which checks if this is null
251251
model = MODEL_INSTANCE;
252-
253-
process = new ProcessSimple(dataDirectory,finalCommand);
252+
Map<String,String> env = new HashMap<>();
253+
env.put(ENV_WRAPPER_HOME,wrapperhome);
254+
process = ProcessSimple.create(dataDirectory,env,finalCommand);
254255
process.waitFor();
255256
}
256257

src/gate/plugin/learningframework/engines/EngineWekaWrapper.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.io.InputStreamReader;
4040
import java.util.ArrayList;
4141
import java.util.Arrays;
42+
import java.util.HashMap;
4243
import java.util.List;
4344
import java.util.Map;
4445
import org.yaml.snakeyaml.Yaml;
@@ -71,6 +72,8 @@ public class EngineWekaWrapper extends Engine {
7172
private String wrapperhome = null;
7273
private boolean linuxLike = true;
7374
private boolean windowsLike = false;
75+
76+
protected final String ENV_WRAPPER_HOME = "WEKA_WRAPPER_HOME";
7477

7578
/**
7679
* Try to find the script running the Weka-Wrapper command.
@@ -87,7 +90,7 @@ public class EngineWekaWrapper extends Engine {
8790
* @return
8891
*/
8992
private File findWrapperCommand(File dataDirectory, boolean apply) {
90-
String homeDir = System.getenv("WEKA_WRAPPER_HOME");
93+
String homeDir = System.getenv(ENV_WRAPPER_HOME);
9194
String tmp = System.getProperty("gate.plugin.learningframework.wekawrapper.home");
9295
if(tmp!=null) homeDir = tmp;
9396
File wekaInfoFile = new File(dataDirectory,"weka.yaml");
@@ -182,14 +185,15 @@ protected void loadModel(File directory, String parms) {
182185
}
183186

184187
finalCommand.add(commandFile.getAbsolutePath());
185-
finalCommand.add(wrapperhome);
186188
finalCommand.add(modelFileName);
187189
finalCommand.add(header);
188190

189191
//System.err.println("Running: "+finalCommand);
190192
// Create a fake Model jsut to make LF_Apply... happy which checks if this is null
191193
model = "ExternalWekaWrapperModel";
192-
process = new Process4ObjectStream(directory,finalCommand);
194+
Map<String,String> env = new HashMap<>();
195+
env.put(ENV_WRAPPER_HOME,wrapperhome);
196+
process = Process4ObjectStream.create(directory,env,finalCommand);
193197
}
194198

195199
@Override
@@ -239,7 +243,6 @@ public void trainModel(File dataDirectory, String instanceType, String parms) {
239243
}
240244

241245
finalCommand.add(commandFile.getAbsolutePath());
242-
finalCommand.add(wrapperhome);
243246
finalCommand.add(dataFileName);
244247
finalCommand.add(modelFileName);
245248
finalCommand.add(wekaClass);
@@ -250,7 +253,9 @@ public void trainModel(File dataDirectory, String instanceType, String parms) {
250253
// Create a fake Model jsut to make LF_Apply... happy which checks if this is null
251254
model = "ExternalWekaWrapperModel";
252255

253-
process = new ProcessSimple(dataDirectory,finalCommand);
256+
model = "ExternalWekaWrapperModel";
257+
Map<String,String> env = new HashMap<>();
258+
process = ProcessSimple.create(dataDirectory,env,finalCommand);
254259
process.waitFor();
255260
}
256261

0 commit comments

Comments
 (0)