Completed action result caching. Fixed goals parallelism.
This commit is contained in:
parent
ea2aea0f54
commit
8c42e44c98
@ -6,13 +6,12 @@
|
||||
package inr.numass.actions;
|
||||
|
||||
import hep.dataforge.actions.GenericAction;
|
||||
import hep.dataforge.work.Work;
|
||||
import hep.dataforge.work.WorkManager.Callback;
|
||||
import hep.dataforge.computation.Work;
|
||||
import hep.dataforge.computation.WorkManager.Callback;
|
||||
import hep.dataforge.data.Data;
|
||||
import hep.dataforge.data.DataFilter;
|
||||
import hep.dataforge.data.DataNode;
|
||||
import hep.dataforge.data.DataSet;
|
||||
import hep.dataforge.data.StaticData;
|
||||
import hep.dataforge.description.TypedActionDef;
|
||||
import hep.dataforge.description.ValueDef;
|
||||
import hep.dataforge.meta.Meta;
|
||||
@ -53,7 +52,7 @@ public class ReadNumassStorageAction extends GenericAction<Void, NumassData> {
|
||||
Loader loader = pair.getValue();
|
||||
if (loader instanceof NumassData) {
|
||||
NumassDataLoader nd = (NumassDataLoader) loader;
|
||||
Data<NumassData> datum = new StaticData<>(nd);
|
||||
Data<NumassData> datum = Data.buildStatic(nd);
|
||||
if (filter.acceptData(pair.getKey(), datum)) {
|
||||
boolean accept = true;
|
||||
if (forwardOnly || reverseOnly) {
|
||||
@ -71,7 +70,7 @@ public class ReadNumassStorageAction extends GenericAction<Void, NumassData> {
|
||||
if (actionMeta.getBoolean("loadLegacy", false)) {
|
||||
logger().info("Loading legacy files");
|
||||
storage.legacyFiles().forEach(nd -> {
|
||||
Data<NumassData> datum = new StaticData<>(nd);
|
||||
Data<NumassData> datum = Data.buildStatic(nd);
|
||||
if (filter.acceptData(nd.getName(), datum)) {
|
||||
builder.putData("legacy." + nd.getName(), datum);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class TransmissionInterpolator implements UnivariateFunction {
|
||||
public static TransmissionInterpolator fromAction(Context context, Meta actionAnnotation,
|
||||
String xName, String yName, int nSmooth, double w, double border) throws InterruptedException {
|
||||
DataNode<Table> node = ActionUtils.runConfig(context, actionAnnotation);
|
||||
PointSource data = node.getData().getNow();
|
||||
PointSource data = node.getData().get();
|
||||
return new TransmissionInterpolator(data, xName, yName, nSmooth, w, border);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ package inr.numass.tasks;
|
||||
|
||||
import hep.dataforge.actions.Action;
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.work.WorkManager;
|
||||
import hep.dataforge.computation.WorkManager;
|
||||
import hep.dataforge.data.DataNode;
|
||||
import hep.dataforge.data.DataTree;
|
||||
import hep.dataforge.meta.Meta;
|
||||
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package inr.numass.test;
|
||||
|
||||
import hep.dataforge.actions.ActionController;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexander Nozik
|
||||
*/
|
||||
public class TestLazyData {
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
ActionController lock = new ActionController();
|
||||
CompletableFuture<String> future = lock.hold(() -> {
|
||||
System.out.println(" I am initialized");
|
||||
return "abcd";
|
||||
});
|
||||
future = future.<String>thenCompose((String res) -> CompletableFuture.supplyAsync(() -> {
|
||||
System.out.println(" I am capitalized");
|
||||
return res.toUpperCase();
|
||||
}));
|
||||
future = future.handleAsync((res, err) -> {
|
||||
System.out.println(" I am handled");
|
||||
return "handled " + res;
|
||||
});
|
||||
System.out.println("Releasing hold");
|
||||
lock.release();
|
||||
|
||||
// dat1.getInFuture().thenRunAsync(() -> System.out.println(" I am finished"));
|
||||
// dat1.getInFuture().thenAcceptAsync((res) -> System.out.println(" I am finished"));
|
||||
}
|
||||
|
||||
}
|
@ -20,7 +20,7 @@ import hep.dataforge.fx.ConsoleFragment;
|
||||
import hep.dataforge.fx.FXDataOutputPane;
|
||||
import hep.dataforge.fx.FXReportListener;
|
||||
import hep.dataforge.fx.configuration.MetaEditor;
|
||||
import hep.dataforge.fx.process.ProcessManagerFragment;
|
||||
import hep.dataforge.fx.work.WorkManagerFragment;
|
||||
import hep.dataforge.io.IOManager;
|
||||
import hep.dataforge.io.MetaFileReader;
|
||||
import hep.dataforge.meta.ConfigChangeListener;
|
||||
@ -45,13 +45,15 @@ import java.util.ResourceBundle;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Accordion;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.control.TitledPane;
|
||||
@ -78,10 +80,12 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
||||
|
||||
Map<String, StagePane> stages = new ConcurrentHashMap<>();
|
||||
|
||||
ProcessManagerFragment processWindow;
|
||||
WorkManagerFragment processWindow;
|
||||
|
||||
FXDataOutputPane logPane;
|
||||
|
||||
BooleanProperty isRunning = new SimpleBooleanProperty(false);
|
||||
|
||||
@FXML
|
||||
private StatusBar statusBar;
|
||||
@FXML
|
||||
@ -91,7 +95,7 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
||||
@FXML
|
||||
private Tab logTab;
|
||||
@FXML
|
||||
private Button runButton;
|
||||
private ToggleButton runButton;
|
||||
@FXML
|
||||
private ToggleButton consoleButton;
|
||||
@FXML
|
||||
@ -121,14 +125,23 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
||||
consoleWindow.addRootLogHandler();
|
||||
consoleWindow.hookStd();
|
||||
|
||||
processWindow = new ProcessManagerFragment();
|
||||
processWindow = new WorkManagerFragment();
|
||||
processWindow.bindTo(processButton);
|
||||
|
||||
isRunning.addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
|
||||
runButton.setSelected(newValue);
|
||||
if (newValue) {
|
||||
runButton.setText("Stop");
|
||||
} else {
|
||||
runButton.setText("Run");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
if (context == null) {
|
||||
return GlobalContext.instance();
|
||||
throw new RuntimeException("Context not defined");
|
||||
} else {
|
||||
return context;
|
||||
}
|
||||
@ -158,7 +171,6 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
||||
context.setIO(new WorkbenchIOManager(new NumassIO(), this));
|
||||
buildContextPane();
|
||||
context.getReport().addReportListener(new FXReportListener(logPane));
|
||||
|
||||
|
||||
// display plots iside workbench
|
||||
PlotsPlugin.buildFrom(context).setPlotHolderDelegate(this);
|
||||
@ -322,9 +334,13 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
||||
|
||||
@FXML
|
||||
private void onRunButtonClick(ActionEvent event) {
|
||||
if (getContext() != null && !actionsConfig.isEmpty()) {
|
||||
statusBar.setText("Starting action execution");
|
||||
runActions();
|
||||
if (!isRunning.get()) {
|
||||
if (context != null && !actionsConfig.isEmpty()) {
|
||||
statusBar.setText("Starting action execution");
|
||||
runActions();
|
||||
}
|
||||
} else {
|
||||
this.context.workManager().shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,27 +357,42 @@ public class NumassWorkbenchController implements Initializable, StagePaneHolder
|
||||
clearAllStages();
|
||||
// processWindow.show();
|
||||
new Thread(() -> {
|
||||
|
||||
Platform.runLater(() -> {
|
||||
isRunning.set(true);
|
||||
statusBar.setProgress(-1);
|
||||
});
|
||||
|
||||
DataNode data = new FileDataFactory().build(getContext(), getDataConfiguration());
|
||||
Platform.runLater(() -> statusBar.setProgress(-1));
|
||||
try {
|
||||
ActionUtils.runAction(getContext(), data, getActionConfiguration()).compute();
|
||||
Platform.runLater(() -> statusBar.setText("Execution complete"));
|
||||
} catch (Exception ex) {
|
||||
GlobalContext.instance().getLogger().error("Exception while executing action chain", ex);
|
||||
Platform.runLater(() -> {
|
||||
//printing stack trace to the default output
|
||||
if (ex instanceof java.util.concurrent.CancellationException) {
|
||||
//cach cancelation exception
|
||||
GlobalContext.instance().getLogger().info("Interrupted by user");
|
||||
Platform.runLater(() -> {
|
||||
statusBar.setText("Execution interrupted by user");
|
||||
});
|
||||
} else {
|
||||
//cach all other exceptions
|
||||
GlobalContext.instance().getLogger().error("Exception while executing action chain", ex);
|
||||
ex.printStackTrace(System.err);
|
||||
// ex.printStackTrace();//??
|
||||
statusBar.setText("Execution failed");
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Exception!");
|
||||
alert.setHeaderText("Action execution failure");
|
||||
alert.setContentText(ex.getMessage());
|
||||
alert.show();
|
||||
|
||||
});
|
||||
Platform.runLater(() -> {
|
||||
//printing stack trace to the default output
|
||||
statusBar.setText("Execution failed");
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Exception!");
|
||||
alert.setHeaderText("Action execution failure");
|
||||
alert.setContentText(ex.getMessage());
|
||||
alert.show();
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
Platform.runLater(() -> statusBar.setProgress(0));
|
||||
Platform.runLater(() -> {
|
||||
isRunning.set(false);
|
||||
statusBar.setProgress(0);
|
||||
});
|
||||
}
|
||||
|
||||
}, "actions").start();
|
||||
|
@ -9,14 +9,13 @@
|
||||
<?import javafx.scene.control.TabPane?>
|
||||
<?import javafx.scene.control.ToggleButton?>
|
||||
<?import javafx.scene.control.ToolBar?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import org.controlsfx.control.StatusBar?>
|
||||
|
||||
<AnchorPane id="AnchorPane" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.workbench.NumassWorkbenchController">
|
||||
<AnchorPane id="AnchorPane" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="inr.numass.workbench.NumassWorkbenchController">
|
||||
<children>
|
||||
<BorderPane layoutX="-165.0" layoutY="100.0" prefHeight="200.0" prefWidth="765.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<bottom>
|
||||
@ -44,14 +43,10 @@
|
||||
<ToggleButton fx:id="consoleButton" mnemonicParsing="false" text="Console" />
|
||||
<ToggleButton fx:id="processButton" mnemonicParsing="false" text="Processes" />
|
||||
<Separator orientation="VERTICAL" />
|
||||
<Pane HBox.hgrow = "ALWAYS"/>
|
||||
<Pane HBox.hgrow="ALWAYS" />
|
||||
<Separator orientation="VERTICAL" />
|
||||
<Button mnemonicParsing="false" onAction="#onLoadConfigClick" text="Load" />
|
||||
<Button fx:id="runButton" disable="true" mnemonicParsing="false" onAction="#onRunButtonClick" text="Run">
|
||||
<font>
|
||||
<Font name="System Bold" size="12.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<ToggleButton fx:id="runButton" disable="true" mnemonicParsing="false" onAction="#onRunButtonClick" text="Run" />
|
||||
</items>
|
||||
</ToolBar>
|
||||
</top>
|
||||
|
@ -17,10 +17,10 @@ package inr.numass.viewer;
|
||||
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.context.GlobalContext;
|
||||
import hep.dataforge.work.WorkManager;
|
||||
import hep.dataforge.computation.WorkManager;
|
||||
import hep.dataforge.exceptions.StorageException;
|
||||
import hep.dataforge.fx.ConsoleFragment;
|
||||
import hep.dataforge.fx.process.ProcessManagerFragment;
|
||||
import hep.dataforge.fx.work.WorkManagerFragment;
|
||||
import inr.numass.NumassProperties;
|
||||
import inr.numass.storage.NumassData;
|
||||
import inr.numass.storage.NumassStorage;
|
||||
@ -66,7 +66,7 @@ public class MainViewerController implements Initializable {
|
||||
}
|
||||
|
||||
// private ConsoleFragment consoleFragment;
|
||||
// private ProcessManagerFragment processFragment = ProcessManagerFragment.attachToContext(GlobalContext.instance());
|
||||
// private WorkManagerFragment processFragment = WorkManagerFragment.attachToContext(GlobalContext.instance());
|
||||
@FXML
|
||||
private ToggleButton consoleButton;
|
||||
@FXML
|
||||
@ -115,7 +115,7 @@ public class MainViewerController implements Initializable {
|
||||
ConsoleFragment consoleFragment = new ConsoleFragment();
|
||||
consoleFragment.hookStd();
|
||||
consoleFragment.bindTo(consoleButton);
|
||||
ProcessManagerFragment.attachToContext(GlobalContext.instance()).bindTo(processManagerButton);
|
||||
WorkManagerFragment.attachToContext(GlobalContext.instance()).bindTo(processManagerButton);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -21,7 +21,7 @@ package inr.numass.viewer;
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.work.WorkManager;
|
||||
import hep.dataforge.computation.WorkManager;
|
||||
import hep.dataforge.exceptions.StorageException;
|
||||
import hep.dataforge.plots.PlotUtils;
|
||||
import hep.dataforge.plots.data.DynamicPlottable;
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package inr.numass.viewer;
|
||||
|
||||
import hep.dataforge.work.WorkManager;
|
||||
import hep.dataforge.computation.WorkManager;
|
||||
import hep.dataforge.exceptions.StorageException;
|
||||
import inr.numass.storage.NumassData;
|
||||
import inr.numass.storage.NumassStorage;
|
||||
|
@ -21,7 +21,7 @@ package inr.numass.viewer;
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
import hep.dataforge.context.Context;
|
||||
import hep.dataforge.work.WorkManager;
|
||||
import hep.dataforge.computation.WorkManager;
|
||||
import hep.dataforge.io.ColumnedDataWriter;
|
||||
import hep.dataforge.meta.Meta;
|
||||
import hep.dataforge.meta.MetaBuilder;
|
||||
|
Loading…
Reference in New Issue
Block a user