Search in sources :

Example 6 with OutputDataObjectType

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

the class DataTransferrer method downloadRemoteFiles.

public List<OutputDataObjectType> downloadRemoteFiles() throws GFacException {
    if (log.isDebugEnabled()) {
        log.debug("Download location is:" + gatewayDownloadLocation);
    }
    List<OutputDataObjectType> applicationOutputs = processContext.getProcessModel().getProcessOutputs();
    if (applicationOutputs != null && !applicationOutputs.isEmpty()) {
        for (OutputDataObjectType output : applicationOutputs) {
            if ("".equals(output.getValue()) || output.getValue() == null) {
                continue;
            }
            if (output.getType().equals(DataType.STDOUT)) {
                output.setValue(stdoutLocation);
                resultantOutputsLst.add(output);
            } else if (output.getType().equals(DataType.STDERR)) {
                output.setValue(stderrLocation);
                resultantOutputsLst.add(output);
            } else if (output.getType().equals(DataType.URI)) {
                String value = null;
                if (!output.getLocation().isEmpty()) {
                    value = output.getLocation() + File.separator + output.getValue();
                } else {
                    value = output.getValue();
                }
                String outputPath = gatewayDownloadLocation + File.separator + output.getValue();
                File f = new File(gatewayDownloadLocation);
                if (!f.exists())
                    f.mkdirs();
                FileDownloader fileDownloader = new FileDownloader(value, outputPath, Mode.overwrite);
                try {
                    log.info("Downloading file {}", value);
                    fileDownloader.perform(storageClient);
                    output.setType(DataType.URI);
                    output.setValue(outputPath);
                    resultantOutputsLst.add(output);
                } catch (Exception e) {
                    log.error("Error downloading " + value + " from job working directory. ");
                // throw new GFacException(e.getLocalizedMessage(),e);
                }
            } else {
                log.info("Ignore output file {}, type {}", output.getValue(), output.getType().toString());
            }
        }
    }
    downloadStdOuts();
    return resultantOutputsLst;
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) GFacException(org.apache.airavata.gfac.core.GFacException) URISyntaxException(java.net.URISyntaxException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 7 with OutputDataObjectType

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

the class WorkflowInterpreter method sendOutputsDynamically.

private void sendOutputsDynamically() throws WorkflowException, RegistryException, AiravataException {
    ArrayList<Node> outputNodes = getReadyOutputNodesDynamically();
    if (outputNodes.size() != 0) {
        LinkedList<Object> outputValues = new LinkedList<Object>();
        LinkedList<String> outputKeywords = new LinkedList<String>();
        for (Node node : outputNodes) {
            // Change it to processing state so we will not pic it up in the
            // next run
            // even if the next run runs before the notification arrives
            WorkflowNodeDetails workflowNodeDetails = createWorkflowNodeDetails(node);
            // workflowNodeDetails.setNodeInstanceId((String)getExperimentCatalog().add(ChildDataType.WORKFLOW_NODE_DETAIL, workflowNodeDetails, getExperiment().getExperimentID()));
            node.setState(NodeExecutionState.EXECUTING);
            updateWorkflowNodeStatus(workflowNodeDetails, WorkflowNodeState.EXECUTING);
            publishNodeStatusChange(WorkflowNodeState.EXECUTING, node.getID(), experiment.getExperimentID());
            // OutputNode node = (OutputNode) outputNode;
            List<DataPort> inputPorts = node.getInputPorts();
            for (DataPort dataPort : inputPorts) {
                Object val = InterpreterUtil.findInputFromPort(dataPort);
                if (null == val) {
                    throw new WorkFlowInterpreterException("Unable to find output for the node:" + node.getID());
                }
                // input
                if (val instanceof org.xmlpull.v1.builder.XmlElement) {
                    ((OutputNode) node).setDescription(XMLUtil.xmlElementToString((org.xmlpull.v1.builder.XmlElement) val));
                } else {
                    ((OutputNode) node).setDescription(val.toString());
                }
                // Saving output Node data in to database
                // WorkflowNodeType workflowNodeType = new WorkflowNodeType();
                // workflowNodeType.setNodeType(WorkflowNodeType.WorkflowNode.OUTPUTNODE);
                // WorkflowInstanceNode workflowInstanceNode = new WorkflowInstanceNode(new WorkflowExecution(config.getTopic(), config.getTopic()), node.getID());
                String portname = node.getName();
                String portValue = ((OutputNode) node).getDescription();
                // this.getConfig().getConfiguration().getAiravataAPI().getProvenanceManager().setWorkflowInstanceNodeOutput(workflowInstanceNode, portname + "=" + portValue);
                // this.getConfig().getConfiguration().getAiravataAPI().getProvenanceManager().setWorkflowNodeType(workflowInstanceNode, workflowNodeType);
                OutputDataObjectType elem = new OutputDataObjectType();
                elem.setName(portname);
                elem.setValue(portValue);
                workflowNodeDetails.addToNodeOutputs(elem);
                getExperimentCatalog().update(ExperimentCatalogModelType.WORKFLOW_NODE_DETAIL, workflowNodeDetails, workflowNodeDetails.getNodeInstanceId());
                if (this.config.isActOnProvenance()) {
                // TODO do provanence thing
                // try {
                // if (val instanceof String) {
                // this.getConfig().getConfiguration().getAiravataAPI().getProvenanceManager()
                // .saveWorkflowExecutionOutput(this.config.getTopic(), node.getName(), val.toString());
                // } else if (val instanceof org.xmlpull.v1.builder.XmlElement) {
                // this.getConfig()
                // .getConfiguration()
                // .getAiravataAPI().getProvenanceManager()
                // .saveWorkflowExecutionOutput(this.config.getTopic(), node.getName(),
                // XMLUtil.xmlElementToString((org.xmlpull.v1.builder.XmlElement) val));
                // }
                // outputValues.add(val);
                // outputKeywords.add(dataPort.getID());
                // } catch (AiravataAPIInvocationException e) {
                // e.printStackTrace(); // To change body of catch
                // // statement use File |
                // // Settings | File
                // // Templates.
                // }
                }
            }
            node.setState(NodeExecutionState.FINISHED);
            publishNodeStatusChange(WorkflowNodeState.COMPLETED, node.getID(), experiment.getExperimentID());
            updateWorkflowNodeStatus(workflowNodeDetails, WorkflowNodeState.COMPLETED);
            notifyViaInteractor(WorkflowExecutionMessage.NODE_STATE_CHANGED, null);
        }
    }
}
Also used : 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) DataPort(org.apache.airavata.workflow.model.graph.DataPort) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType)

Example 8 with OutputDataObjectType

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

the class AiravataIT method testAddApplication.

@org.testng.annotations.Test(priority = 4)
public void testAddApplication() {
    try {
        logger.info("testAddApplication() -> Adding test application......");
        applicationProperties = setup.getApplicationRegister().addApplications();
        ;
        Assert.assertNotNull(applicationProperties);
        ApplicationModule applicationModule = setup.getApplicationRegister().getApplicationModule(applicationProperties.getApplicationModuleId());
        Assert.assertNotNull(applicationModule);
        Assert.assertEquals(applicationModule.getAppModuleName(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_NAME);
        Assert.assertEquals(applicationModule.getAppModuleVersion(), LOCAL_ECHO_VERSION);
        Assert.assertEquals(applicationModule.getAppModuleDescription(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_DESCRIPTION);
        Assert.assertEquals(applicationModule.getAppModuleName(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_NAME);
        ApplicationInterfaceDescription applicationInterfaceDescription = setup.getApplicationRegister().getApplicationInterfaceDescription(applicationProperties.getApplicationInterfaceId());
        Assert.assertNotNull(applicationInterfaceDescription);
        Assert.assertEquals(applicationInterfaceDescription.getApplicationName(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_NAME);
        Assert.assertEquals(applicationInterfaceDescription.getApplicationDescription(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_DESCRIPTION);
        InputDataObjectType input = applicationInterfaceDescription.getApplicationInputs().get(0);
        Assert.assertNotNull(input);
        Assert.assertEquals(input.getName(), INPUT_NAME);
        Assert.assertEquals(input.getValue(), INPUT_VALUE);
        Assert.assertEquals(input.getType(), DataType.STRING);
        Assert.assertEquals(input.getApplicationArgument(), null);
        Assert.assertEquals(input.getInputOrder(), 0);
        Assert.assertEquals(input.isIsRequired(), true);
        Assert.assertEquals(input.isRequiredToAddedToCommandLine(), true);
        Assert.assertEquals(input.isStandardInput(), false);
        Assert.assertEquals(input.getUserFriendlyDescription(), INPUT_DESC);
        Assert.assertEquals(input.getMetaData(), null);
        List<OutputDataObjectType> outputDataObjectTypes = applicationInterfaceDescription.getApplicationOutputs();
        Assert.assertNotNull(outputDataObjectTypes.get(0));
        Assert.assertEquals(outputDataObjectTypes.get(0).getName(), STDERR_NAME);
        Assert.assertEquals(outputDataObjectTypes.get(0).getValue(), STDERR_VALUE);
        Assert.assertEquals(outputDataObjectTypes.get(0).getType(), DataType.URI);
        Assert.assertEquals(outputDataObjectTypes.get(0).isIsRequired(), true);
        Assert.assertEquals(outputDataObjectTypes.get(0).isRequiredToAddedToCommandLine(), true);
        Assert.assertEquals(outputDataObjectTypes.get(0).getApplicationArgument(), null);
        Assert.assertNotNull(outputDataObjectTypes.get(1));
        Assert.assertEquals(outputDataObjectTypes.get(1).getName(), STDOUT_NAME);
        Assert.assertEquals(outputDataObjectTypes.get(1).getValue(), STDOUT_VALUE);
        Assert.assertEquals(outputDataObjectTypes.get(1).getType(), DataType.URI);
        Assert.assertEquals(outputDataObjectTypes.get(1).isIsRequired(), true);
        Assert.assertEquals(outputDataObjectTypes.get(1).isRequiredToAddedToCommandLine(), true);
        Assert.assertEquals(outputDataObjectTypes.get(1).getApplicationArgument(), null);
        ApplicationDeploymentDescription applicationDeploymentDescription = setup.getApplicationRegister().getApplicationDeploymentDescription(applicationProperties.getApplicationDeployId());
        Assert.assertNotNull(applicationDeploymentDescription);
        Assert.assertEquals(applicationDeploymentDescription.getExecutablePath(), TestFrameworkConstants.LOCAL_ECHO_JOB_FILE_PATH);
        Assert.assertEquals(applicationDeploymentDescription.getParallelism(), ApplicationParallelismType.SERIAL);
        Assert.assertEquals(applicationDeploymentDescription.getAppDeploymentDescription(), TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_DESCRIPTION);
        Assert.assertEquals(applicationDeploymentDescription.getModuleLoadCmds(), null);
        Assert.assertEquals(applicationDeploymentDescription.getPostJobCommands(), null);
        Assert.assertEquals(applicationDeploymentDescription.getPreJobCommands(), null);
        logger.info("testAddApplication() -> Adding test application." + applicationProperties.toString());
    } catch (Exception e) {
        logger.error("Error occured while testAddApplication", e);
        Assert.fail();
    }
}
Also used : ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ApplicationInterfaceDescription(org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription) ApplicationModule(org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule)

Example 9 with OutputDataObjectType

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

the class ApplicationRegister method registerLocalEchoInterface.

private String registerLocalEchoInterface(Gateway gateway, String moduleId) throws org.apache.thrift.TException {
    List<String> appModules = new ArrayList<String>();
    appModules.add(moduleId);
    InputDataObjectType input1 = createAppInput(INPUT_NAME, INPUT_VALUE, DataType.STRING, null, 0, true, true, false, INPUT_DESC, null);
    List<InputDataObjectType> applicationInputs = new ArrayList<InputDataObjectType>(1);
    applicationInputs.add(input1);
    OutputDataObjectType output1 = createAppOutput(STDOUT_NAME, STDOUT_VALUE, DataType.URI, true, true, null);
    OutputDataObjectType output2 = createAppOutput(STDERR_NAME, STDERR_VALUE, DataType.URI, true, true, null);
    List<OutputDataObjectType> applicationOutputs = new ArrayList<OutputDataObjectType>(2);
    applicationOutputs.add(output1);
    applicationOutputs.add(output2);
    String localEchoInterfaceId = airavata.registerApplicationInterface(authzToken, gateway.getGatewayId(), createApplicationInterfaceDescription(TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_NAME, TestFrameworkConstants.AppcatalogConstants.LOCAL_ECHO_DESCRIPTION, appModules, applicationInputs, applicationOutputs));
    System.out.println("Echo Local Application Interface Id " + localEchoInterfaceId);
    return localEchoInterfaceId;
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ArrayList(java.util.ArrayList)

Example 10 with OutputDataObjectType

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

the class ExperimentExecution method createLocalEchoExperiment.

public String createLocalEchoExperiment(String gatewayId, String applicationInterfaceId, String storageId, String computeResourceId) throws Exception {
    String experimentId = null;
    try {
        List<InputDataObjectType> applicationInputs = airavata.getApplicationInputs(authzToken, applicationInterfaceId);
        List<OutputDataObjectType> appOutputs = airavata.getApplicationOutputs(authzToken, applicationInterfaceId);
        for (InputDataObjectType inputDataObjectType : applicationInputs) {
            if (inputDataObjectType.getName().equalsIgnoreCase(INPUT_NAME)) {
                inputDataObjectType.setValue(LOCAL_ECHO_EXPERIMENT_INPUT);
            }
        }
        List<Project> projectsPerGateway = projectsMap.get(gatewayId);
        String projectID = null;
        if (projectsPerGateway != null && !projectsPerGateway.isEmpty()) {
            projectID = projectsPerGateway.get(0).getProjectID();
        }
        ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(gatewayId, projectID, properties.getTestUserName(), "Local Echo Experiment", "Local Echo Experiment run", applicationInterfaceId, applicationInputs);
        simpleExperiment.setExperimentOutputs(appOutputs);
        ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResourceId, 4, 1, 1, "cpu", 20, 0);
        UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
        userConfigurationData.setAiravataAutoSchedule(false);
        userConfigurationData.setOverrideManualScheduledParams(false);
        userConfigurationData.setComputationalResourceScheduling(scheduling);
        userConfigurationData.setStorageId(storageId);
        userConfigurationData.setExperimentDataDir(TestFrameworkConstants.STORAGE_LOCATION);
        simpleExperiment.setUserConfigurationData(userConfigurationData);
        experimentId = airavata.createExperiment(authzToken, gatewayId, simpleExperiment);
        experimentsWithGateway.put(experimentId, gatewayId);
    } catch (Exception e) {
        logger.error("Error while creating Echo experiment", e);
        throw new Exception("Error while creating Echo experiment", e);
    }
    return experimentId;
}
Also used : Project(org.apache.airavata.model.workspace.Project) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) TException(org.apache.thrift.TException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException)

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