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;
}
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);
}
}
}
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();
}
}
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;
}
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;
}
Aggregations