Search in sources :

Example 86 with OutputDataObjectType

use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.

the class BESJobSubmissionTask method copyOutputFilesToStorage.

private void copyOutputFilesToStorage(TaskContext taskContext, List<OutputDataObjectType> copyOutput) throws GFacException {
    ProcessContext pc = taskContext.getParentProcessContext();
    String remoteFilePath = null, fileName = null, localFilePath = null;
    try {
        authenticationInfo = Factory.getStorageSSHKeyAuthentication(pc);
        ServerInfo serverInfo = pc.getComputeResourceServerInfo();
        Session sshSession = Factory.getSSHSession(authenticationInfo, serverInfo);
        for (OutputDataObjectType output : copyOutput) {
            switch(output.getType()) {
                case STDERR:
                case STDOUT:
                case STRING:
                case URI:
                    localFilePath = output.getValue();
                    if (localFilePath.contains("://")) {
                        localFilePath = localFilePath.substring(localFilePath.indexOf("://") + 2, localFilePath.length());
                    }
                    fileName = localFilePath.substring(localFilePath.lastIndexOf("/") + 1);
                    URI destinationURI = TaskUtils.getDestinationURI(taskContext, hostName, inputPath, fileName);
                    remoteFilePath = destinationURI.getPath();
                    log.info("SCP local file :{} -> from remote :{}", localFilePath, remoteFilePath);
                    SSHUtils.scpTo(localFilePath, remoteFilePath, sshSession);
                    output.setValue(destinationURI.toString());
                    break;
                default:
                    break;
            }
        }
    } catch (IOException | JSchException | SSHApiException | URISyntaxException | CredentialStoreException e) {
        log.error("Error while coping local file " + localFilePath + " to remote " + remoteFilePath, e);
        throw new GFacException("Error while scp output files to remote storage file location", e);
    }
}
Also used : JSchException(com.jcraft.jsch.JSchException) ServerInfo(org.apache.airavata.gfac.core.cluster.ServerInfo) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) CredentialStoreException(org.apache.airavata.credential.store.store.CredentialStoreException) URI(java.net.URI) SSHApiException(org.apache.airavata.gfac.core.SSHApiException) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) GFacException(org.apache.airavata.gfac.core.GFacException) Session(com.jcraft.jsch.Session)

Example 87 with OutputDataObjectType

use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.

the class GFacUtils method saveProcessOutput.

public static void saveProcessOutput(ProcessContext processContext, String outputName, String outputVal) throws GFacException {
    try {
        ExperimentCatalog experimentCatalog = processContext.getExperimentCatalog();
        String processId = processContext.getProcessId();
        List<OutputDataObjectType> processOutputs = (List<OutputDataObjectType>) experimentCatalog.get(ExperimentCatalogModelType.PROCESS_OUTPUT, processId);
        if (processOutputs != null && !processOutputs.isEmpty()) {
            for (OutputDataObjectType processOutput : processOutputs) {
                if (processOutput.getName().equals(outputName)) {
                    processOutput.setValue(outputVal);
                }
            }
        }
        ProcessModel processModel = processContext.getProcessModel();
        processModel.setProcessOutputs(processOutputs);
        experimentCatalog.update(ExperimentCatalogModelType.PROCESS, processModel, processId);
    } catch (RegistryException e) {
        String msg = "expId: " + processContext.getExperimentId() + " processId: " + processContext.getProcessId() + " : - Error while updating experiment outputs";
        throw new GFacException(msg, e);
    }
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) NodeList(org.w3c.dom.NodeList)

Example 88 with OutputDataObjectType

use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.

the class GFacUtils method getProcessOutputValues.

private static List<String> getProcessOutputValues(List<OutputDataObjectType> processOutputs) {
    List<String> inputValues = new ArrayList<>();
    if (processOutputs != null) {
        for (OutputDataObjectType output : processOutputs) {
            if (output.getApplicationArgument() != null && !output.getApplicationArgument().equals("")) {
                inputValues.add(output.getApplicationArgument());
            }
            if (output.getValue() != null && !output.getValue().equals("") && output.isRequiredToAddedToCommandLine()) {
                if (output.getType() == DataType.URI) {
                    String filePath = output.getValue();
                    filePath = filePath.substring(filePath.lastIndexOf(File.separatorChar) + 1, filePath.length());
                    inputValues.add(filePath);
                }
            }
        }
    }
    return inputValues;
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType)

Example 89 with OutputDataObjectType

use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.

the class WorkflowInterpreter method finish.

private void finish() throws WorkflowException, RegistryException {
    ArrayList<Node> outoutNodes = new ArrayList<Node>();
    List<NodeImpl> nodes = this.getGraph().getNodes();
    for (Node node : nodes) {
        if (node instanceof OutputNode) {
            if (node.getInputPort(0).getFromNode().getState() == NodeExecutionState.FINISHED) {
                outoutNodes.add(node);
            } else {
                // workflowFinished
                return;
            }
        }
    }
    LinkedList<Object> outputValues = new LinkedList<Object>();
    LinkedList<String> outputKeywords = new LinkedList<String>();
    for (Node outputNode : outoutNodes) {
        OutputNode node = (OutputNode) outputNode;
        List<DataPort> inputPorts = node.getInputPorts();
        for (DataPort dataPort : inputPorts) {
            Object val = InterpreterUtil.findInputFromPort(dataPort, this.invokerMap);
            ;
            if (null == val) {
                throw new WorkFlowInterpreterException("Unable to find output for the node:" + node.getID());
            }
            WorkflowNodeDetails workflowNodeDetails = nodeInstanceList.get(node);
            OutputDataObjectType elem = new OutputDataObjectType();
            elem.setName(node.getName());
            elem.setValue(val.toString());
            workflowNodeDetails.addToNodeOutputs(elem);
            try {
                getExperimentCatalog().update(ExperimentCatalogModelType.WORKFLOW_NODE_DETAIL, workflowNodeDetails, workflowNodeDetails.getNodeInstanceId());
            } catch (RegistryException e) {
                log.error(e.getMessage(), e);
            }
            updateWorkflowNodeStatus(workflowNodeDetails, WorkflowNodeState.COMPLETED);
        }
    }
}
Also used : NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) SubWorkflowNode(org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) RegistryException(org.apache.airavata.registry.cpi.RegistryException) DataPort(org.apache.airavata.workflow.model.graph.DataPort) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType)

Example 90 with OutputDataObjectType

use of org.apache.airavata.model.application.io.OutputDataObjectType in project airavata by apache.

the class WorkflowInterpreter method taskOutputChanged.

@Subscribe
public void taskOutputChanged(TaskOutputChangeEvent taskOutputEvent) {
    String taskId = taskOutputEvent.getTaskIdentity().getTaskId();
    if (isTaskAwaiting(taskId)) {
        ProcessState state = ProcessState.COMPLETED;
        Node node = getAwaitingNodeForTask(taskId);
        List<OutputDataObjectType> applicationOutputs = taskOutputEvent.getOutput();
        Map<String, String> outputData = new HashMap<String, String>();
        for (OutputDataObjectType outputObj : applicationOutputs) {
            List<DataPort> outputPorts = node.getOutputPorts();
            for (DataPort dataPort : outputPorts) {
                if (dataPort.getName().equals(outputObj.getName())) {
                    outputData.put(outputObj.getName(), outputObj.getValue());
                }
            }
        }
        nodeOutputData.put(node, outputData);
        setupNodeDetailsOutput(node);
        node.setState(NodeExecutionState.FINISHED);
        try {
            publishNodeStatusChange(WorkflowNodeState.COMPLETED, node.getID(), experiment.getExperimentID());
            updateWorkflowNodeStatus(nodeInstanceList.get(node), state);
        } catch (RegistryException e) {
            log.error(e.getMessage(), e);
        } catch (AiravataException e) {
            log.error(e.getMessage(), e);
        }
    }
}
Also used : ProcessState(org.apache.airavata.model.status.ProcessState) DataPort(org.apache.airavata.workflow.model.graph.DataPort) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) SubWorkflowNode(org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) RegistryException(org.apache.airavata.registry.cpi.RegistryException) AiravataException(org.apache.airavata.common.exception.AiravataException) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)93 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)60 TException (org.apache.thrift.TException)51 AuthzToken (org.apache.airavata.model.security.AuthzToken)44 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)34 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)33 UserConfigurationDataModel (org.apache.airavata.model.experiment.UserConfigurationDataModel)33 ArrayList (java.util.ArrayList)18 Project (org.apache.airavata.model.workspace.Project)16 RegistryException (org.apache.airavata.registry.cpi.RegistryException)14 GFacException (org.apache.airavata.gfac.core.GFacException)7 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)7 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)7 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)7 URISyntaxException (java.net.URISyntaxException)6 AiravataException (org.apache.airavata.common.exception.AiravataException)5 HashMap (java.util.HashMap)4 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)4 ProcessContext (org.apache.airavata.gfac.core.context.ProcessContext)4 JobStatus (org.apache.airavata.model.status.JobStatus)4