Search in sources :

Example 1 with CreateRunEnsembleDialog

use of gov.sandia.umf.platform.ui.ensemble.run.CreateRunEnsembleDialog in project n2a by frothga.

the class UIController method prepareAndSubmitRunEnsemble.

public boolean prepareAndSubmitRunEnsemble(Component parentComponent, MNode model) throws Exception {
    // Set up simulators.
    List<ExtensionPoint> simEP = PluginManager.getExtensionsForPoint(Backend.class);
    Backend[] simulators = new Backend[simEP.size()];
    int s = 0;
    for (ExtensionPoint ep : simEP) {
        simulators[s++] = (Backend) ep;
    }
    // Set up execution environments.
    // Hack to suppress errors in this outdated code.
    HostSystem[] envs = new HostSystem[0];
    // TODO: Fix this with appropriate interfaces.
    String name = (String) ReflectionUtil.invoke("getName", model);
    String owner = (String) ReflectionUtil.invoke("getOwner", model);
    CreateRunEnsembleDialog dlg = new CreateRunEnsembleDialog((JFrame) SwingUtilities.getRoot(parentComponent), // TODO change from -1
    -1, /*TEMP*/
    name, owner, 12342347483L, /*TEMP until appropriate interfaces*/
    model, simulators, simulators[0], envs, HostSystem.get("localhost"), false);
    dlg.setVisible(true);
    if (dlg.getResult() == CreateRunEnsembleDialog.CREATE) {
        String label = dlg.getLabel();
        HostSystem env = dlg.getEnvironment();
        Backend simulator = dlg.getSimulator();
        ParameterSpecGroupSet groups = dlg.getParameterSpecGroupSet();
        ParameterSpecGroupSet simHandledGroups;
        try {
            // next line modifies groups to remove any that the Simulator will handle
            simHandledGroups = divideEnsembleParams(model, groups, simulator);
        } catch (RuntimeException e) {
            Dialogs.showDetails(MainFrame.instance, "could not create run ensemble", e);
            return false;
        }
        List<String> outputExpressions = dlg.getSelectedOutputExpressions();
        /*            
            int runNum = 0;
            for(ParameterSet set : groups.generateAllSetsFromSpecs(false)) {
                ParameterSet modelParamSet = set.subset("Model");
                ParameterSet simParamSet = set.subset("Simulator");
                modelParamSet.sliceKeyPathKeys();
                simParamSet.sliceKeyPathKeys();

                Run run = model.addRun(modelParamSet, re);
                re.addRun(run);

                Simulation simulation = simulator.createSimulation();
                ParameterDomain domain = new ParameterDomain(simParamSet);
                simulation.setSelectedParameters(domain);
                try {
                    RunState runState;
                    logger.debug(System.currentTimeMillis() + " before execute for run " +
                            runNum++);
                    // quick and dirty attempt at batch script version of doing ensemble
                    runState = simulation.prepare(run, simHandledGroups, env);
//                    runState = simulation.execute(run, simHandledGroups, env);
                    run.setState(XStreamWrapper.writeToString(runState));
                    run.save();
                } catch(Exception e1) {
                    UMF.handleUnexpectedError(null, e1, "Could not create the run.  An error occurred.");
                    return false;
                }
            }
            env.submitBatch(re);
 */
        return true;
    }
    return false;
}
Also used : Backend(gov.sandia.n2a.plugins.extpoints.Backend) ExtensionPoint(gov.sandia.n2a.plugins.ExtensionPoint) CreateRunEnsembleDialog(gov.sandia.umf.platform.ui.ensemble.run.CreateRunEnsembleDialog) HostSystem(gov.sandia.n2a.execenvs.HostSystem) ParameterSpecGroupSet(gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet) ExtensionPoint(gov.sandia.n2a.plugins.ExtensionPoint)

Aggregations

HostSystem (gov.sandia.n2a.execenvs.HostSystem)1 ExtensionPoint (gov.sandia.n2a.plugins.ExtensionPoint)1 Backend (gov.sandia.n2a.plugins.extpoints.Backend)1 ParameterSpecGroupSet (gov.sandia.umf.platform.ensemble.params.groupset.ParameterSpecGroupSet)1 CreateRunEnsembleDialog (gov.sandia.umf.platform.ui.ensemble.run.CreateRunEnsembleDialog)1