Search in sources :

Example 1 with HpcAccountManager

use of edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager in project tetrad by cmu-phil.

the class HpcJobsScheduledTask method run.

// Pooling job status from HPC nodes
@Override
public void run() {
    TetradDesktop desktop = (TetradDesktop) DesktopController.getInstance();
    if (desktop == null)
        return;
    final HpcAccountManager hpcAccountManager = desktop.getHpcAccountManager();
    // No Hpc Account in the first place, no need to proceed!
    List<HpcAccount> hpcAccounts = hpcAccountManager.getHpcAccounts();
    if (hpcAccounts == null || hpcAccounts.isEmpty())
        return;
    final HpcJobManager hpcJobManager = desktop.getHpcJobManager();
    // LOGGER.debug("HpcJobsScheduledTask: " + new Date(System.currentTimeMillis()));
    // Load active jobs: Status (0 = Submitted; 1 = Running; 2 = Kill
    // Request)
    Map<HpcAccount, Set<HpcJobInfo>> submittedHpcJobInfos = hpcJobManager.getSubmittedHpcJobInfoMap();
    for (HpcAccount hpcAccount : submittedHpcJobInfos.keySet()) {
        LOGGER.debug("HpcJobsScheduledTask: " + hpcAccount.getConnectionName());
        Set<HpcJobInfo> hpcJobInfos = submittedHpcJobInfos.get(hpcAccount);
        // Pid-HpcJobInfo map
        Map<Long, HpcJobInfo> hpcJobInfoMap = new HashMap<>();
        for (HpcJobInfo hpcJobInfo : hpcJobInfos) {
            if (hpcJobInfo.getPid() != null) {
                long pid = hpcJobInfo.getPid().longValue();
                hpcJobInfoMap.put(pid, hpcJobInfo);
                LOGGER.debug("id: " + hpcJobInfo.getId() + " : " + hpcJobInfo.getAlgoId() + ": pid: " + pid + " : " + hpcJobInfo.getResultFileName());
            } else {
                LOGGER.debug("id: " + hpcJobInfo.getId() + " : " + hpcJobInfo.getAlgoId() + ": no pid! : " + hpcJobInfo.getResultFileName());
                hpcJobInfos.remove(hpcJobInfo);
            }
        }
        // Finished job map
        HashMap<Long, HpcJobInfo> finishedJobMap = new HashMap<>();
        for (HpcJobInfo job : hpcJobInfos) {
            finishedJobMap.put(job.getPid(), job);
        }
        try {
            List<JobInfo> jobInfos = hpcJobManager.getRemoteActiveJobs(hpcAccountManager, hpcAccount);
            for (JobInfo jobInfo : jobInfos) {
                LOGGER.debug("Remote pid: " + jobInfo.getId() + " : " + jobInfo.getAlgoId() + " : " + jobInfo.getResultFileName());
                long pid = jobInfo.getId();
                if (finishedJobMap.containsKey(pid)) {
                    finishedJobMap.remove(pid);
                }
                int remoteStatus = jobInfo.getStatus();
                String recentStatusText = (remoteStatus == 0 ? "Submitted" : (remoteStatus == 1 ? "Running" : "Kill Request"));
                // Local job
                HpcJobInfo hpcJobInfo = hpcJobInfoMap.get(pid);
                // map
                HpcJobLog hpcJobLog = hpcJobManager.getHpcJobLog(hpcJobInfo);
                if (hpcJobInfo != null) {
                    int status = hpcJobInfo.getStatus();
                    if (status != remoteStatus) {
                        // Update status
                        hpcJobInfo.setStatus(remoteStatus);
                        hpcJobManager.updateHpcJobInfo(hpcJobInfo);
                        hpcJobLog.setLastUpdatedTime(new Date(System.currentTimeMillis()));
                        String log = "Job status changed to " + recentStatusText;
                        LOGGER.debug(hpcJobInfo.getAlgoId() + " : id : " + hpcJobInfo.getId() + " : pid : " + pid);
                        LOGGER.debug(log);
                        hpcJobManager.logHpcJobLogDetail(hpcJobLog, remoteStatus, log);
                    }
                }
            }
            // Download finished jobs' results
            if (finishedJobMap.size() > 0) {
                Set<ResultFile> resultFiles = hpcJobManager.listRemoteAlgorithmResultFiles(hpcAccountManager, hpcAccount);
                Set<String> resultFileNames = new HashSet<>();
                for (ResultFile resultFile : resultFiles) {
                    resultFileNames.add(resultFile.getName());
                // LOGGER.debug(hpcAccount.getConnectionName()
                // + " Result : " + resultFile.getName());
                }
                for (HpcJobInfo hpcJobInfo : finishedJobMap.values()) {
                    // Job
                    // is
                    // done
                    // or
                    // killed or
                    // time-out
                    HpcJobLog hpcJobLog = hpcJobManager.getHpcJobLog(hpcJobInfo);
                    String recentStatusText = "Job finished";
                    // Finished
                    int recentStatus = 3;
                    if (hpcJobInfo.getStatus() == 2) {
                        recentStatusText = "Job killed";
                        // Killed
                        recentStatus = 4;
                    }
                    hpcJobInfo.setStatus(recentStatus);
                    hpcJobManager.updateHpcJobInfo(hpcJobInfo);
                    // LOGGER.debug("hpcJobInfo: id: "
                    // + hpcJobInfo.getId() + " : "
                    // + hpcJobInfo.getStatus());
                    hpcJobManager.logHpcJobLogDetail(hpcJobLog, recentStatus, recentStatusText);
                    LOGGER.debug(hpcJobInfo.getAlgoId() + " : id : " + hpcJobInfo.getId() + " : " + recentStatusText);
                    GeneralAlgorithmEditor editor = hpcJobManager.getGeneralAlgorithmEditor(hpcJobInfo);
                    if (editor != null) {
                        LOGGER.debug("GeneralAlgorithmEditor is not null");
                        String resultJsonFileName = hpcJobInfo.getResultJsonFileName();
                        String errorResultFileName = hpcJobInfo.getErrorResultFileName();
                        if (resultFileNames.contains(resultJsonFileName)) {
                            // Result Downloaded
                            recentStatus = 5;
                            String json = downloadAlgorithmResultFile(hpcAccountManager, hpcJobManager, hpcAccount, resultJsonFileName, editor);
                            if (!json.toLowerCase().contains("not found")) {
                                editor.setAlgorithmResult(json);
                            }
                            String log = "Result downloaded";
                            hpcJobManager.logHpcJobLogDetail(hpcJobLog, recentStatus, log);
                            LOGGER.debug(hpcJobInfo.getAlgoId() + " : id : " + hpcJobInfo.getId() + " : " + log);
                        } else if (resultFileNames.contains(errorResultFileName)) {
                            // Error Result Downloaded
                            recentStatus = 6;
                            String error = downloadAlgorithmResultFile(hpcAccountManager, hpcJobManager, hpcAccount, errorResultFileName, editor);
                            if (!error.toLowerCase().contains("not found")) {
                                editor.setAlgorithmErrorResult(error);
                            }
                            String log = "Error Result downloaded";
                            hpcJobManager.logHpcJobLogDetail(hpcJobLog, recentStatus, log);
                            LOGGER.debug(hpcJobInfo.getAlgoId() + " : id : " + hpcJobInfo.getId() + " : " + log);
                        } else {
                            // Try again
                            Thread.sleep(5000);
                            String json = downloadAlgorithmResultFile(hpcAccountManager, hpcJobManager, hpcAccount, resultJsonFileName, editor);
                            if (!json.toLowerCase().contains("not found")) {
                                editor.setAlgorithmResult(json);
                                // Result Downloaded
                                recentStatus = 5;
                                String log = "Result downloaded";
                                hpcJobManager.logHpcJobLogDetail(hpcJobLog, recentStatus, log);
                                LOGGER.debug(hpcJobInfo.getAlgoId() + " : id : " + hpcJobInfo.getId() + " : " + log);
                            } else {
                                String error = downloadAlgorithmResultFile(hpcAccountManager, hpcJobManager, hpcAccount, errorResultFileName, editor);
                                if (!error.toLowerCase().contains("not found")) {
                                    editor.setAlgorithmErrorResult(error);
                                    // Error Result
                                    recentStatus = 6;
                                    // Downloaded
                                    String log = "Error Result downloaded";
                                    hpcJobManager.logHpcJobLogDetail(hpcJobLog, recentStatus, log);
                                    LOGGER.debug(hpcJobInfo.getAlgoId() + " : id : " + hpcJobInfo.getId() + " : " + log);
                                } else {
                                    // Result Not Found
                                    recentStatus = 7;
                                    String log = resultJsonFileName + " not found";
                                    hpcJobManager.logHpcJobLogDetail(hpcJobLog, recentStatus, log);
                                    LOGGER.debug(hpcJobInfo.getAlgoId() + " : id : " + hpcJobInfo.getId() + " : " + log);
                                }
                            }
                        }
                    }
                    hpcJobManager.removeFinishedHpcJob(hpcJobInfo);
                }
            } else {
                LOGGER.debug("No finished job yet.");
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) HpcAccount(edu.pitt.dbmi.tetrad.db.entity.HpcAccount) GeneralAlgorithmEditor(edu.cmu.tetradapp.editor.GeneralAlgorithmEditor) HpcJobManager(edu.cmu.tetradapp.app.hpc.manager.HpcJobManager) JobInfo(edu.pitt.dbmi.ccd.rest.client.dto.algo.JobInfo) HpcJobInfo(edu.pitt.dbmi.tetrad.db.entity.HpcJobInfo) HpcAccountManager(edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager) TetradDesktop(edu.cmu.tetradapp.app.TetradDesktop) HashSet(java.util.HashSet) ResultFile(edu.pitt.dbmi.ccd.rest.client.dto.algo.ResultFile) Date(java.util.Date) ClientProtocolException(org.apache.http.client.ClientProtocolException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) HpcJobInfo(edu.pitt.dbmi.tetrad.db.entity.HpcJobInfo) HpcJobLog(edu.pitt.dbmi.tetrad.db.entity.HpcJobLog)

Example 2 with HpcAccountManager

use of edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager in project tetrad by cmu-phil.

the class WindowMenuListener method menuSelected.

/**
 * Reacts when the window menu is selected by constructing a menu on the fly
 * consisting of an alphabetized list of sessoin editors. The user can
 * navigate to any session editor by selecting its name from the list.
 *
 * @param e the menu event indicating that the window menu has been
 *          selected.
 */
public void menuSelected(MenuEvent e) {
    windowMenu.removeAll();
    itemsToFrames.clear();
    JInternalFrame[] layer0Frames = desktop.getDesktopPane().getAllFramesInLayer(0);
    List<String> titles = new ArrayList<>();
    Map<String, JInternalFrame> titlesToFrames = new HashMap<>();
    for (JInternalFrame layer0Frame : layer0Frames) {
        String title = layer0Frame.getTitle();
        title = ((title == null) || title.equals("")) ? "[untitled]" : title;
        titles.add(title);
        titlesToFrames.put(title, layer0Frame);
    }
    Collections.sort(titles);
    for (Object title1 : titles) {
        String title = (String) title1;
        JMenuItem item = new JMenuItem(title);
        this.windowMenu.add(item);
        item.addActionListener(this);
        this.itemsToFrames.put(item, titlesToFrames.get(title));
    }
    // If there are hpc account(s) setup, show the hpc activity
    HpcAccountManager hpcAccountManager = desktop.getHpcAccountManager();
    List<HpcAccount> hpcAccounts = hpcAccountManager.getHpcAccounts();
    if (hpcAccounts != null && !hpcAccounts.isEmpty()) {
        this.windowMenu.addSeparator();
        String title = "HPC Job Activity";
        JMenuItem item = new JMenuItem(new HpcJobActivityAction(title));
        this.windowMenu.add(item);
    // item.addActionListener(hpcJobActivityMenuListener);
    }
}
Also used : HpcAccount(edu.pitt.dbmi.tetrad.db.entity.HpcAccount) HpcJobActivityAction(edu.cmu.tetradapp.app.hpc.action.HpcJobActivityAction) HpcAccountManager(edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager)

Example 3 with HpcAccountManager

use of edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager in project tetrad by cmu-phil.

the class HpcAccountSettingAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    TetradDesktop desktop = (TetradDesktop) DesktopController.getInstance();
    HpcAccountManager manager = desktop.getHpcAccountManager();
    JComponent comp = buildHpcAccountSettingComponent(manager);
    JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), comp, "High-Performance Computing Account Setting", JOptionPane.PLAIN_MESSAGE);
}
Also used : HpcAccountManager(edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager) JComponent(javax.swing.JComponent) TetradDesktop(edu.cmu.tetradapp.app.TetradDesktop)

Example 4 with HpcAccountManager

use of edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager in project tetrad by cmu-phil.

the class HpcJobActivityEditor method buildController.

private void buildController(final JPanel controllerPane, final TetradDesktop desktop) {
    // Content
    Box contentBox = Box.createVerticalBox();
    JPanel hpcPanel = new JPanel(new BorderLayout());
    JLabel hpcAccountLabel = new JLabel("HPC Account: ", JLabel.TRAILING);
    hpcAccountLabel.setPreferredSize(new Dimension(100, 5));
    hpcPanel.add(hpcAccountLabel, BorderLayout.WEST);
    Box hpcAccountCheckBox = Box.createHorizontalBox();
    final HpcAccountManager hpcAccountManager = desktop.getHpcAccountManager();
    List<HpcAccount> hpcAccounts = hpcAccountManager.getHpcAccounts();
    HpcAccountSelectionAction hpcAccountSelectionAction = new HpcAccountSelectionAction(hpcAccounts);
    for (HpcAccount hpcAccount : hpcAccounts) {
        checkedHpcAccountList.add(hpcAccount);
        final JCheckBox hpcCheckBox = new JCheckBox(hpcAccount.getConnectionName(), true);
        hpcCheckBox.addActionListener(hpcAccountSelectionAction);
        hpcAccountCheckBox.add(hpcCheckBox);
    }
    hpcPanel.add(hpcAccountCheckBox, BorderLayout.CENTER);
    contentBox.add(hpcPanel);
    controllerPane.add(contentBox, BorderLayout.CENTER);
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) HpcAccountManager(edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager) JLabel(javax.swing.JLabel) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) HpcAccount(edu.pitt.dbmi.tetrad.db.entity.HpcAccount) Dimension(java.awt.Dimension)

Example 5 with HpcAccountManager

use of edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager in project tetrad by cmu-phil.

the class GeneralAlgorithmEditor method doRemoteCompute.

private void doRemoteCompute(final GeneralAlgorithmRunner runner, final HpcAccount hpcAccount) throws Exception {
    // **********************
    // Show progress panel *
    // **********************
    Frame ancestor = (Frame) JOptionUtils.centeringComp().getTopLevelAncestor();
    final JDialog progressDialog = new JDialog(ancestor, "HPC Job Submission's Progress...", false);
    Dimension progressDim = new Dimension(500, 150);
    JTextArea progressTextArea = new JTextArea();
    progressTextArea.setPreferredSize(progressDim);
    progressTextArea.setEditable(false);
    JScrollPane progressScroller = new JScrollPane(progressTextArea);
    progressScroller.setAlignmentX(LEFT_ALIGNMENT);
    progressDialog.setLayout(new BorderLayout());
    progressDialog.getContentPane().add(progressScroller, BorderLayout.CENTER);
    progressDialog.pack();
    Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
    progressDialog.setLocation((screenDim.width - progressDim.width) / 2, (screenDim.height - progressDim.height) / 2);
    progressDialog.setVisible(true);
    int totalProcesses = 4;
    String newline = "\n";
    String tab = "\t";
    int progressTextLength = 0;
    DataModel dataModel = runner.getDataModel();
    // 1. Generate temp file
    Path file = null;
    Path prior = null;
    try {
        // ****************************
        // Data Preparation Progress *
        // ****************************
        String dataMessage = String.format("1/%1$d Data Preparation", totalProcesses);
        progressTextArea.append(dataMessage);
        progressTextArea.append(tab);
        progressTextLength = progressTextArea.getText().length();
        progressTextArea.append("Preparing...");
        progressTextArea.updateUI();
        file = Files.createTempFile("Tetrad-data-", ".txt");
        // LOGGER.info(file.toAbsolutePath().toString());
        List<String> tempLine = new ArrayList<>();
        // Header
        List<Node> variables = dataModel.getVariables();
        if ((variables == null || variables.isEmpty()) && runner.getSourceGraph() != null) {
            variables = runner.getSourceGraph().getNodes();
        }
        String vars = StringUtils.join(variables.toArray(), tab);
        tempLine.add(vars);
        // Data
        DataSet dataSet = (DataSet) dataModel;
        for (int i = 0; i < dataSet.getNumRows(); i++) {
            String line = null;
            for (int j = 0; j < dataSet.getNumColumns(); j++) {
                String cell = null;
                if (dataSet.isContinuous()) {
                    cell = String.valueOf(dataSet.getDouble(i, j));
                } else {
                    cell = String.valueOf(dataSet.getInt(i, j));
                }
                if (line == null) {
                    line = cell;
                } else {
                    line = line + "\t" + cell;
                }
            }
            tempLine.add(line);
        }
        // for (String line : tempLine) {
        // LOGGER.info(line);
        // }
        Files.write(file, tempLine);
        // Get file's MD5 hash and use it as its identifier
        String datasetMd5 = MessageDigestHash.computeMD5Hash(file);
        progressTextArea.replaceRange("Done", progressTextLength, progressTextArea.getText().length());
        progressTextArea.append(newline);
        progressTextArea.updateUI();
        // ***************************************
        // Prior Knowledge Preparation Progress *
        // ***************************************
        String priorMessage = String.format("2/%1$d Prior Knowledge Preparation", totalProcesses);
        progressTextArea.append(priorMessage);
        progressTextArea.append(tab);
        progressTextLength = progressTextArea.getText().length();
        progressTextArea.append("Preparing...");
        progressTextArea.updateUI();
        // 2. Generate temp prior knowledge file
        Knowledge2 knowledge = (Knowledge2) dataModel.getKnowledge();
        if (knowledge != null && !knowledge.isEmpty()) {
            prior = Files.createTempFile(file.getFileName().toString(), ".prior");
            knowledge.saveKnowledge(Files.newBufferedWriter(prior));
            progressTextArea.replaceRange("Done", progressTextLength, progressTextArea.getText().length());
            progressTextArea.append(newline);
            progressTextArea.updateUI();
        } else {
            progressTextArea.replaceRange("Skipped", progressTextLength, progressTextArea.getText().length());
            progressTextArea.append(newline);
            progressTextArea.updateUI();
        }
        // Get knowledge file's MD5 hash and use it as its identifier
        String priorKnowledgeMd5 = null;
        if (prior != null) {
            priorKnowledgeMd5 = MessageDigestHash.computeMD5Hash(prior);
        }
        // *******************************************
        // Algorithm Parameter Preparation Progress *
        // *******************************************
        String algorMessage = String.format("3/%1$d Algorithm Preparation", totalProcesses);
        progressTextArea.append(algorMessage);
        progressTextArea.append(tab);
        progressTextLength = progressTextArea.getText().length();
        progressTextArea.append("Preparing...");
        progressTextArea.updateUI();
        // 3.1 Algorithm Id, Independent Test Id, Score Id
        AlgorithmModel algoModel = algorithmList.getSelectedValue();
        String algoId = algoModel.getAlgorithm().getAnnotation().command();
        // Test
        String testId = null;
        if (indTestComboBox.isEnabled()) {
            IndependenceTestModel indTestModel = indTestComboBox.getItemAt(indTestComboBox.getSelectedIndex());
            testId = indTestModel.getIndependenceTest().getAnnotation().command();
        }
        // Score
        String scoreId = null;
        if (scoreComboBox.isEnabled()) {
            ScoreModel scoreModel = scoreComboBox.getItemAt(scoreComboBox.getSelectedIndex());
            scoreId = scoreModel.getScore().getAnnotation().command();
        }
        // 3.2 Parameters
        AlgorithmParamRequest algorithmParamRequest = new AlgorithmParamRequest();
        // Test and score
        algorithmParamRequest.setTestId(testId);
        algorithmParamRequest.setScoreId(scoreId);
        // Dataset and Prior paths
        String datasetPath = file.toAbsolutePath().toString();
        LOGGER.info(datasetPath);
        algorithmParamRequest.setDatasetPath(datasetPath);
        algorithmParamRequest.setDatasetMd5(datasetMd5);
        if (prior != null) {
            String priorKnowledgePath = prior.toAbsolutePath().toString();
            LOGGER.info(priorKnowledgePath);
            algorithmParamRequest.setPriorKnowledgePath(priorKnowledgePath);
            algorithmParamRequest.setPriorKnowledgeMd5(priorKnowledgeMd5);
        }
        // VariableType
        if (dataModel.isContinuous()) {
            algorithmParamRequest.setVariableType("continuous");
        } else if (dataModel.isDiscrete()) {
            algorithmParamRequest.setVariableType("discrete");
        } else {
            algorithmParamRequest.setVariableType("mixed");
        }
        // FileDelimiter
        // Pre-determined
        String fileDelimiter = "tab";
        algorithmParamRequest.setFileDelimiter(fileDelimiter);
        Set<AlgorithmParameter> AlgorithmParameters = new HashSet<>();
        Parameters parameters = runner.getParameters();
        List<String> parameterNames = runner.getAlgorithm().getParameters();
        for (String parameter : parameterNames) {
            String value = parameters.get(parameter).toString();
            LOGGER.info("parameter: " + parameter + "\tvalue: " + value);
            if (value != null) {
                AlgorithmParameter algorParam = new AlgorithmParameter();
                algorParam.setParameter(parameter);
                algorParam.setValue(value);
                AlgorithmParameters.add(algorParam);
            }
        }
        algorithmParamRequest.setAlgorithmParameters(AlgorithmParameters);
        String maxHeapSize = null;
        do {
            maxHeapSize = JOptionPane.showInputDialog(progressDialog, "Enter Your Request Java Max Heap Size (GB):", "5");
        } while (maxHeapSize != null && !StringUtils.isNumeric(maxHeapSize));
        if (maxHeapSize != null) {
            JvmOptions jvmOptions = new JvmOptions();
            jvmOptions.setMaxHeapSize(Integer.parseInt(maxHeapSize));
            algorithmParamRequest.setJvmOptions(jvmOptions);
        }
        // Hpc parameters
        final HpcAccountManager hpcAccountManager = desktop.getHpcAccountManager();
        JsonWebToken jsonWebToken = HpcAccountUtils.getJsonWebToken(hpcAccountManager, hpcAccount);
        if (jsonWebToken.getWallTime() != null) {
            // User allowed to customize the job's wall time
            String[] wallTime = jsonWebToken.getWallTime();
            Object userwallTime = JOptionPane.showInputDialog(progressDialog, "Wall Time:", "Choose Your Wall Time (in Hour)", JOptionPane.QUESTION_MESSAGE, null, wallTime, wallTime[0]);
            if (wallTime != null && userwallTime != null) {
                HpcParameter hpcParameter = new HpcParameter();
                hpcParameter.setKey("walltime");
                hpcParameter.setValue(userwallTime.toString());
                LOGGER.info("walltime: " + userwallTime.toString());
                Set<HpcParameter> hpcParameters = new HashSet<>();
                hpcParameters.add(hpcParameter);
                algorithmParamRequest.setHpcParameters(hpcParameters);
            }
        }
        progressTextArea.replaceRange("Done", progressTextLength, progressTextArea.getText().length());
        progressTextArea.append(newline);
        progressTextArea.updateUI();
        // ********************************
        // Adding HPC Job Queue Progress *
        // ********************************
        String dbMessage = String.format("4/%1$d HPC Job Queue Submission", totalProcesses);
        progressTextArea.append(dbMessage);
        progressTextArea.append(tab);
        progressTextLength = progressTextArea.getText().length();
        progressTextArea.append("Preparing...");
        progressTextArea.updateUI();
        HpcJobManager hpcJobManager = desktop.getHpcJobManager();
        // 4.1 Save HpcJobInfo
        hpcJobInfo = new HpcJobInfo();
        hpcJobInfo.setAlgoId(algoId);
        hpcJobInfo.setAlgorithmParamRequest(algorithmParamRequest);
        hpcJobInfo.setStatus(-1);
        hpcJobInfo.setHpcAccount(hpcAccount);
        hpcJobManager.submitNewHpcJobToQueue(hpcJobInfo, this);
        progressTextArea.replaceRange("Done", progressTextLength, progressTextArea.getText().length());
        progressTextArea.append(newline);
        progressTextArea.updateUI();
        this.jsonResult = null;
        JOptionPane.showMessageDialog(ancestor, "The " + hpcJobInfo.getAlgoId() + " job on the " + hpcJobInfo.getHpcAccount().getConnectionName() + " node is in the queue successfully!");
    } catch (IOException exception) {
        LOGGER.error("", exception);
    } finally {
        progressDialog.setVisible(false);
        progressDialog.dispose();
    }
    (new HpcJobActivityAction("")).actionPerformed(null);
}
Also used : Frame(java.awt.Frame) JTextArea(javax.swing.JTextArea) IndependenceTestModel(edu.cmu.tetradapp.ui.model.IndependenceTestModel) DataSet(edu.cmu.tetrad.data.DataSet) Node(edu.cmu.tetrad.graph.Node) ArrayList(java.util.ArrayList) Knowledge2(edu.cmu.tetrad.data.Knowledge2) BorderLayout(java.awt.BorderLayout) HpcJobManager(edu.cmu.tetradapp.app.hpc.manager.HpcJobManager) HpcAccountManager(edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager) AlgorithmParamRequest(edu.pitt.dbmi.tetrad.db.entity.AlgorithmParamRequest) AlgorithmModel(edu.cmu.tetradapp.ui.model.AlgorithmModel) HashSet(java.util.HashSet) JScrollPane(javax.swing.JScrollPane) Path(java.nio.file.Path) Parameters(edu.cmu.tetrad.util.Parameters) Dimension(java.awt.Dimension) IOException(java.io.IOException) JsonWebToken(edu.pitt.dbmi.ccd.rest.client.dto.user.JsonWebToken) ScoreModel(edu.cmu.tetradapp.ui.model.ScoreModel) HpcParameter(edu.pitt.dbmi.tetrad.db.entity.HpcParameter) HpcJobActivityAction(edu.cmu.tetradapp.app.hpc.action.HpcJobActivityAction) DataModel(edu.cmu.tetrad.data.DataModel) JvmOptions(edu.pitt.dbmi.tetrad.db.entity.JvmOptions) HpcJobInfo(edu.pitt.dbmi.tetrad.db.entity.HpcJobInfo) AlgorithmParameter(edu.pitt.dbmi.tetrad.db.entity.AlgorithmParameter) JDialog(javax.swing.JDialog)

Aggregations

HpcAccountManager (edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager)8 HpcJobManager (edu.cmu.tetradapp.app.hpc.manager.HpcJobManager)5 HpcAccount (edu.pitt.dbmi.tetrad.db.entity.HpcAccount)5 TetradDesktop (edu.cmu.tetradapp.app.TetradDesktop)4 HpcAccountService (edu.cmu.tetradapp.app.hpc.manager.HpcAccountService)3 HpcJobInfo (edu.pitt.dbmi.tetrad.db.entity.HpcJobInfo)3 BorderLayout (java.awt.BorderLayout)3 Dimension (java.awt.Dimension)3 HashSet (java.util.HashSet)3 HpcJobActivityAction (edu.cmu.tetradapp.app.hpc.action.HpcJobActivityAction)2 FilePrint (edu.pitt.dbmi.ccd.commons.file.FilePrint)2 JobInfo (edu.pitt.dbmi.ccd.rest.client.dto.algo.JobInfo)2 ResultFile (edu.pitt.dbmi.ccd.rest.client.dto.algo.ResultFile)2 ResultService (edu.pitt.dbmi.ccd.rest.client.service.result.ResultService)2 AlgorithmParamRequest (edu.pitt.dbmi.tetrad.db.entity.AlgorithmParamRequest)2 AlgorithmParameter (edu.pitt.dbmi.tetrad.db.entity.AlgorithmParameter)2 HpcJobLog (edu.pitt.dbmi.tetrad.db.entity.HpcJobLog)2 HpcParameter (edu.pitt.dbmi.tetrad.db.entity.HpcParameter)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2