Skip to content

Commit 426b4a6

Browse files
committed
Merge pull request #116 from SeqWare/feature/bundle-conf
Feature/bundle conf Former-commit-id: 506a2d6
2 parents f8c16f0 + 14c5f49 commit 426b4a6

File tree

8 files changed

+81
-37
lines changed

8 files changed

+81
-37
lines changed

seqware-common/src/main/java/net/sourceforge/seqware/common/metadata/MetadataWS.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,6 @@ public ReturnValue addWorkflow(String name, String version, String description,
189189
workflow.setWorkflowType(workflow_type);
190190
workflow.setWorkflowEngine(workflow_engine);
191191

192-
Log.info("Posting workflow");
193-
try {
194-
workflow = ll.addWorkflow(workflow);
195-
Log.stdout("WORKFLOW_ACCESSION: " + workflow.getSwAccession());
196-
ret.setAttribute("sw_accession", workflow.getSwAccession().toString());
197-
ret.setReturnValue(workflow.getWorkflowId());
198-
} catch (Exception e) {
199-
e.printStackTrace();
200-
ret.setExitStatus(ReturnValue.FAILURE);
201-
return ret;
202-
}
203192
// open the ini file and parse each item
204193
// FIXME: this assumes there is one ini file which is generally fine for
205194
// bundled workflows but we could make this more flexible
@@ -215,7 +204,19 @@ public ReturnValue addWorkflow(String name, String version, String description,
215204
}
216205
}
217206

218-
// foreach workflow param add an entry in the workflow_param table
207+
Log.info("Posting workflow");
208+
try {
209+
workflow = ll.addWorkflow(workflow);
210+
Log.stdout("WORKFLOW_ACCESSION: " + workflow.getSwAccession());
211+
ret.setAttribute("sw_accession", workflow.getSwAccession().toString());
212+
ret.setReturnValue(workflow.getWorkflowId());
213+
} catch (Exception e) {
214+
e.printStackTrace();
215+
ret.setExitStatus(ReturnValue.FAILURE);
216+
return ret;
217+
}
218+
219+
// foreach workflow param add an entry in the workflow_param table
219220
int count = 0;
220221
for (String key : hm.keySet()) {
221222
count++;

seqware-common/src/main/java/net/sourceforge/seqware/common/util/maptools/MapTools.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package net.sourceforge.seqware.common.util.maptools;
22

3+
import static net.sourceforge.seqware.common.util.Rethrow.rethrow;
4+
35
import java.io.BufferedReader;
46
import java.io.File;
57
import java.io.FileInputStream;
@@ -12,6 +14,7 @@
1214
import java.util.Iterator;
1315
import java.util.Map;
1416
import java.util.Properties;
17+
1518
import net.sourceforge.seqware.common.util.Log;
1619

1720
/**
@@ -89,12 +92,8 @@ public static void ini2RichMap(String iniFile, Map<String, Map<String, String>>
8992
hm.put(kv[0], detailsMap);
9093
}
9194
}
92-
} catch (FileNotFoundException e) {
93-
e.printStackTrace();
94-
Log.stderr(e.getMessage());
95-
} catch (IOException e) {
96-
e.printStackTrace();
97-
Log.stderr(e.getMessage());
95+
} catch (Exception e) {
96+
rethrow(e);
9897
}
9998

10099
}

seqware-ext-testing/src/test/java/net/sourceforge/seqware/pipeline/cli_tutorial/CLIDeveloperPhase2.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public class CLIDeveloperPhase2 extends DeveloperPhase2{
3030

3131
@Override
3232
protected void testWorkflow() throws IOException {
33-
ITUtility.runSeqwareCLI(" bundle test --dir " + DeveloperPhase1.BundleDir.getAbsolutePath(), ReturnValue.SUCCESS, null);
33+
ITUtility.runSeqwareCLI(" bundle test --dir " + DeveloperPhase1.BuildDir.getAbsolutePath(), ReturnValue.SUCCESS, null);
3434
}
3535

3636
@Override
3737
protected void packageBundle(File tempPackageDir) throws IOException {
3838
ITUtility.runSeqwareCLI(" bundle package --to " + tempPackageDir.getAbsolutePath() +
39-
" --dir " + DeveloperPhase1.BundleDir.getAbsolutePath() , ReturnValue.SUCCESS, null);
39+
" --dir " + DeveloperPhase1.BuildDir.getAbsolutePath() , ReturnValue.SUCCESS, null);
4040
}
4141
}

seqware-ext-testing/src/test/java/net/sourceforge/seqware/pipeline/tutorial/DeveloperPhase1.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@
2020
import java.io.IOException;
2121
import java.util.ArrayList;
2222
import java.util.List;
23+
2324
import junit.framework.Assert;
2425
import net.sourceforge.seqware.common.util.Log;
2526
import net.sourceforge.seqware.pipeline.plugins.ITUtility;
2627
import net.sourceforge.seqware.pipeline.plugins.PluginRunnerET;
2728
import net.sourceforge.seqware.pipeline.runner.PluginRunner;
29+
2830
import org.apache.commons.io.FileUtils;
31+
import org.apache.commons.io.filefilter.WildcardFileFilter;
2932
import org.junit.BeforeClass;
3033
import org.junit.Test;
3134

@@ -37,6 +40,7 @@ public class DeveloperPhase1 {
3740

3841
public static final String WORKFLOW = "Workflow";
3942
public static File BundleDir = null;
43+
public static File BuildDir = null;
4044
public static File JavaClient = null;
4145

4246
@BeforeClass
@@ -73,9 +77,20 @@ public static void testListAvailableWorkflowsAndTheirParameters() throws IOExcep
7377

7478
// allocate needed items for future tests
7579
BundleDir = bundleDir;
80+
BuildDir = findTargetBundleDir(bundleDir);
7681
JavaClient = workflowClientJava;
7782

7883
}
84+
85+
public static File findTargetBundleDir(File projectDir) {
86+
File targetDir = new File(projectDir, "target");
87+
for (File f : targetDir.listFiles()){
88+
if (f.isDirectory() && f.getName().startsWith("Workflow_Bundle_")){
89+
return f;
90+
}
91+
}
92+
throw new RuntimeException("Could not locate target/WorkflowBundle_* directory");
93+
}
7994

8095
@Test
8196
public void testModifyingTheWorkflow() throws IOException{

seqware-ext-testing/src/test/java/net/sourceforge/seqware/pipeline/tutorial/DeveloperPhase2.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717
package net.sourceforge.seqware.pipeline.tutorial;
1818

1919
import com.google.common.io.Files;
20+
2021
import java.io.File;
2122
import java.io.IOException;
23+
2224
import net.sourceforge.seqware.common.module.ReturnValue;
2325
import net.sourceforge.seqware.pipeline.plugins.ITUtility;
2426
import net.sourceforge.seqware.pipeline.plugins.PluginRunnerET;
27+
2528
import org.apache.commons.io.FileUtils;
2629
import org.junit.AfterClass;
2730
import org.junit.Test;
@@ -51,12 +54,12 @@ public static void cleanup() throws IOException{
5154
}
5255

5356
protected void testWorkflow() throws IOException {
54-
ITUtility.runSeqWareJar("-p net.sourceforge.seqware.pipeline.plugins.BundleManager -- -b " + DeveloperPhase1.BundleDir.getAbsolutePath() +
57+
ITUtility.runSeqWareJar("-p net.sourceforge.seqware.pipeline.plugins.BundleManager -- -b " + DeveloperPhase1.BuildDir.getAbsolutePath() +
5558
" -t --workflow seqware-archetype-java-workflow --version 1.0-SNAPSHOT", ReturnValue.SUCCESS, null);
5659
}
5760

5861
protected void packageBundle(File tempPackageDir) throws IOException {
5962
ITUtility.runSeqWareJar("-p net.sourceforge.seqware.pipeline.plugins.BundleManager -- -b " + tempPackageDir.getAbsolutePath() +
60-
" -p " + DeveloperPhase1.BundleDir.getAbsolutePath() , ReturnValue.SUCCESS, null);
63+
" -p " + DeveloperPhase1.BuildDir.getAbsolutePath() , ReturnValue.SUCCESS, null);
6164
}
6265
}

seqware-pipeline/src/main/java/net/sourceforge/seqware/pipeline/bundle/Bundle.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,11 @@ public ReturnValue unpackageBundle(File bundle) {
130130
String bundleName = bundle.getName();
131131
bundleName = bundleName.replaceAll(".zip", "");
132132
File outputDir = new File(bundleDir + File.separator + bundleName);
133-
FileTools.unzipFile(bundle, outputDir);
133+
if (outputDir.exists()){
134+
Log.stdout("Expanded bundle directory already exists, skipping unzip.");
135+
} else {
136+
FileTools.unzipFile(bundle, outputDir);
137+
}
134138
ret.setAttribute("outputDir", outputDir.getAbsolutePath());
135139
setOutputDir(outputDir.getAbsolutePath());
136140
FileTools.listFilesRecursive(outputDir, filesArray);
@@ -381,6 +385,18 @@ public ReturnValue validateBundle(File bundle) {
381385
bi.parseFromFile(file);
382386
}
383387
// TODO: add more validation here based on what's pulled out of the metadata bundle
388+
389+
for (WorkflowInfo wi : bi.getWorkflowInfo()) {
390+
// ensure conf file exists
391+
String orig = wi.getConfigPath();
392+
String abs = orig.replaceAll("\\$\\{workflow_bundle_dir\\}", outputDir);
393+
File f = new File(abs);
394+
if (!f.exists()){
395+
ret.setExitStatus(ReturnValue.FAILURE);
396+
ret.setStderr("ERROR: Configuration file does not exist: " + orig);
397+
}
398+
}
399+
384400
}
385401
} catch (Exception e) {
386402
ret.setExitStatus(ReturnValue.FAILURE);

seqware-pipeline/src/main/java/net/sourceforge/seqware/pipeline/plugins/BundleManager.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,24 @@ public ReturnValue do_run() {
138138
println("Bundle Validates!");
139139
}
140140
} else if (options.has("bundle") && options.has("test")) {
141-
println("Testing Bundle");
142-
String bundlePath = (String) options.valueOf("bundle");
143-
File bundle = new File(bundlePath);
144-
if (options.has("workflow") && options.has("version")) {
145-
// then just run the test for a particular workflow and version
146-
ret = b.testBundle(bundle, specificMetadataFile, (String) options.valueOf("workflow"), (String) options.valueOf("version"));
147-
} else {
148-
ret = b.testBundle(bundle, specificMetadataFile);
149-
}
150-
if (ret.getExitStatus() == ReturnValue.SUCCESS) {
151-
println("Bundle Passed Test!");
152-
}
141+
println("Validating Bundle structure");
142+
String bundlePath = (String) options.valueOf("bundle");
143+
File bundle = new File(bundlePath);
144+
ret = b.validateBundle(bundle);
145+
if (ret.getExitStatus() == ReturnValue.SUCCESS) {
146+
println("Bundle Validates!");
147+
println("Testing Bundle");
148+
if (options.has("workflow") && options.has("version")) {
149+
// then just run the test for a particular workflow and version
150+
ret = b.testBundle(bundle, specificMetadataFile, (String) options.valueOf("workflow"), (String) options.valueOf("version"));
151+
} else {
152+
ret = b.testBundle(bundle, specificMetadataFile);
153+
}
154+
if (ret.getExitStatus() == ReturnValue.SUCCESS) {
155+
println("Bundle Passed Test!");
156+
}
157+
}
158+
153159
} else if (options.has("bundle") && options.has("path-to-package")) {
154160
println("Packaging Bundle");
155161
String bundleOutput = (String) options.valueOf("bundle");

seqware-pipeline/src/main/java/net/sourceforge/seqware/pipeline/runner/PluginRunner.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,12 @@ private void evaluateReturn(Plugin app, String methodName) {
304304

305305
// On failure, update metadb and exit
306306
if (newReturn.getExitStatus() > ReturnValue.SUCCESS) {
307-
Log.stderr("The method '" + methodName + "' exited abnormally so the Runner will terminate here!");
308-
Log.stderr("Return value was: " + newReturn.getExitStatus());
307+
if (newReturn.getStderr() != null){
308+
Log.stderr(newReturn.getStderr());
309+
} else {
310+
Log.stderr("The method '" + methodName + "' exited abnormally so the Runner will terminate here!");
311+
Log.stderr("Return value was: " + newReturn.getExitStatus());
312+
}
309313
System.exit(newReturn.getExitStatus());
310314
}
311315

0 commit comments

Comments
 (0)