Dynamic calls from java to Groovy workspace DSL
This commit is contained in:
parent
867ace2d79
commit
154ff33bbd
@ -31,4 +31,13 @@ task listActions(dependsOn: classes, type: JavaExec) {
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
description "print a list of available actions as via -lc command line parameter"
|
||||
group "numass"
|
||||
}
|
||||
|
||||
task workspace(dependsOn: classes, type: JavaExec) {
|
||||
main 'inr.numass.workspace.NumassGrindLauncher'
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
args "-c \"D:\\Work\\Numass\\sterile2016\\workspace.groovy\" numass.fitsum sum".split()
|
||||
description "Run workspace task"
|
||||
group "numass"
|
||||
|
||||
}
|
@ -18,10 +18,10 @@ package inr.numass
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import hep.dataforge.grind.WorkspaceSpec
|
||||
import inr.numass.tasks.NumassFitScanSummaryTask
|
||||
import inr.numass.tasks.NumassFitScanTask
|
||||
import inr.numass.tasks.NumassPrepareTask
|
||||
import inr.numass.tasks.NumassTableFilterTask
|
||||
import inr.numass.workspace.NumassFitScanSummaryTask
|
||||
import inr.numass.workspace.NumassFitScanTask
|
||||
import inr.numass.workspace.NumassPrepareTask
|
||||
import inr.numass.workspace.NumassTableFilterTask
|
||||
|
||||
/**
|
||||
* Created by darksnake on 16-Aug-16.
|
||||
|
@ -1,18 +0,0 @@
|
||||
package inr.numass.tasks;
|
||||
|
||||
import hep.dataforge.grind.JavaGrindLauncher;
|
||||
import inr.numass.NumassWorkspaceSpec;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created by darksnake on 12-Aug-16.
|
||||
*/
|
||||
public class NumassGrindLauncher {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
JavaGrindLauncher.buildWorkspace(new File("D:\\Work\\Numass\\sterile2016\\workspace.groovy"), NumassWorkspaceSpec.class)
|
||||
.runTask("numass.fitsum", "fill_3").computeAll();
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.tasks;
|
||||
package inr.numass.workspace;
|
||||
|
||||
import hep.dataforge.actions.Action;
|
||||
import hep.dataforge.actions.ManyToOneAction;
|
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.tasks;
|
||||
package inr.numass.workspace;
|
||||
|
||||
import hep.dataforge.actions.Action;
|
||||
import hep.dataforge.computation.WorkManager;
|
@ -0,0 +1,59 @@
|
||||
package inr.numass.workspace;
|
||||
|
||||
import hep.dataforge.data.DataNode;
|
||||
import hep.dataforge.grind.JavaGrindLauncher;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.workspace.Workspace;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by darksnake on 12-Aug-16.
|
||||
*/
|
||||
public class NumassGrindLauncher {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Options options = new Options();
|
||||
options.addOption("c", "config", true, "Configuration file for workspace");
|
||||
options.addOption("o", "overlay", false, "If meta with the same name as parameter exist in the workspace, use it as lower layer");
|
||||
|
||||
CommandLine cli = new DefaultParser().parse(options, args);
|
||||
|
||||
String cfgPath = cli.getOptionValue('c', "workspace.groovy");
|
||||
|
||||
List<String> arglist = cli.getArgList();
|
||||
|
||||
Workspace workspace = JavaGrindLauncher.buildWorkspace(new File(cfgPath), "inr.numass.NumassWorkspaceSpec");
|
||||
|
||||
if (arglist.size() == 0) {
|
||||
new HelpFormatter().printHelp("launcher [opts] <task name> <meta name / meta>", options);
|
||||
return;
|
||||
} else if (arglist.size() == 1) {
|
||||
String taskName = arglist.get(0);
|
||||
workspace.runTask(taskName, taskName);
|
||||
} else {
|
||||
String taskName = arglist.get(0);
|
||||
String theRest = arglist.stream().skip(1).collect(Collectors.joining());
|
||||
DataNode node;
|
||||
if (theRest.contains("{") || theRest.contains("(")) {
|
||||
Meta meta = JavaGrindLauncher.buildMeta(theRest);
|
||||
boolean overlay = cli.hasOption("o");
|
||||
node = workspace.runTask(taskName, meta, overlay);
|
||||
} else {
|
||||
node = workspace.runTask(taskName, theRest);
|
||||
}
|
||||
|
||||
node.computeAll();
|
||||
}
|
||||
//
|
||||
// JavaGrindLauncher.buildWorkspace(new File(cfgPath), NumassWorkspaceSpec.class)
|
||||
// .runTask("numass.fitsum", "sum").computeAll();
|
||||
}
|
||||
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.tasks;
|
||||
package inr.numass.workspace;
|
||||
|
||||
import hep.dataforge.actions.Action;
|
||||
import hep.dataforge.computation.WorkManager;
|
@ -1,4 +1,4 @@
|
||||
package inr.numass.tasks;
|
||||
package inr.numass.workspace;
|
||||
|
||||
import hep.dataforge.actions.OneToOneAction;
|
||||
import hep.dataforge.computation.WorkManager;
|
@ -19,7 +19,7 @@ includeProjects(rootDir, '')
|
||||
File dataforgeDir = new File(rootDir,'../dataforge');
|
||||
|
||||
if(dataforgeDir.exists()){
|
||||
// include 'dataforge'
|
||||
// project(':dataforge').projectDir = dataforgeDir
|
||||
includeFlat "dataforge"
|
||||
includeProjects(dataforgeDir,'')
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user