use of org.apache.airavata.model.application.io.InputDataObjectType 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;
}
use of org.apache.airavata.model.application.io.InputDataObjectType in project airavata by apache.
the class GFacUtils method getProcessInputValues.
private static List<String> getProcessInputValues(List<InputDataObjectType> processInputs) {
List<String> inputValues = new ArrayList<String>();
if (processInputs != null) {
// sort the inputs first and then build the command ListR
Comparator<InputDataObjectType> inputOrderComparator = new Comparator<InputDataObjectType>() {
@Override
public int compare(InputDataObjectType inputDataObjectType, InputDataObjectType t1) {
return inputDataObjectType.getInputOrder() - t1.getInputOrder();
}
};
Set<InputDataObjectType> sortedInputSet = new TreeSet<InputDataObjectType>(inputOrderComparator);
for (InputDataObjectType input : processInputs) {
sortedInputSet.add(input);
}
for (InputDataObjectType inputDataObjectType : sortedInputSet) {
if (!inputDataObjectType.isRequiredToAddedToCommandLine()) {
continue;
}
if (inputDataObjectType.getApplicationArgument() != null && !inputDataObjectType.getApplicationArgument().equals("")) {
inputValues.add(inputDataObjectType.getApplicationArgument());
}
if (inputDataObjectType.getValue() != null && !inputDataObjectType.getValue().equals("")) {
if (inputDataObjectType.getType() == DataType.URI) {
// set only the relative path
String filePath = inputDataObjectType.getValue();
filePath = filePath.substring(filePath.lastIndexOf(File.separatorChar) + 1, filePath.length());
inputValues.add(filePath);
} else if (inputDataObjectType.getType() == DataType.URI_COLLECTION) {
String filePaths = inputDataObjectType.getValue();
String[] paths = filePaths.split(GFacConstants.MULTIPLE_INPUTS_SPLITTER);
String filePath;
String inputs = "";
int i = 0;
for (; i < paths.length - 1; i++) {
filePath = paths[i];
filePath = filePath.substring(filePath.lastIndexOf(File.separatorChar) + 1, filePath.length());
// File names separate by a space
inputs += filePath + " ";
}
inputs += paths[i];
inputValues.add(inputs);
} else {
inputValues.add(inputDataObjectType.getValue());
}
}
}
}
return inputValues;
}
use of org.apache.airavata.model.application.io.InputDataObjectType in project airavata by apache.
the class GFacUtils method saveExperimentInput.
public static void saveExperimentInput(ProcessContext processContext, String inputName, String inputVal) throws GFacException {
try {
ExperimentCatalog experimentCatalog = processContext.getExperimentCatalog();
String experimentId = processContext.getExperimentId();
ExperimentModel experiment = (ExperimentModel) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, experimentId);
List<InputDataObjectType> experimentInputs = experiment.getExperimentInputs();
if (experimentInputs != null && !experimentInputs.isEmpty()) {
for (InputDataObjectType expInput : experimentInputs) {
if (expInput.getName().equals(inputName)) {
expInput.setValue(inputVal);
}
}
}
experimentCatalog.update(ExperimentCatalogModelType.EXPERIMENT, experiment, experimentId);
} catch (RegistryException e) {
String msg = "expId: " + processContext.getExperimentId() + " processId: " + processContext.getProcessId() + " : - Error while updating experiment inputs";
throw new GFacException(msg, e);
}
}
use of org.apache.airavata.model.application.io.InputDataObjectType in project airavata by apache.
the class GFacUtils method saveProcessInput.
public static void saveProcessInput(ProcessContext processContext, String inputName, String inputVal) throws GFacException {
try {
ExperimentCatalog experimentCatalog = processContext.getExperimentCatalog();
String processId = processContext.getProcessId();
ProcessModel processModel = (ProcessModel) experimentCatalog.get(ExperimentCatalogModelType.PROCESS, processId);
List<InputDataObjectType> processInputs = processModel.getProcessInputs();
if (processInputs != null && !processInputs.isEmpty()) {
for (InputDataObjectType processInput : processInputs) {
if (processInput.getName().equals(inputName)) {
processInput.setValue(inputVal);
}
}
}
experimentCatalog.update(ExperimentCatalogModelType.PROCESS, processModel, processId);
} catch (RegistryException e) {
String msg = "expId: " + processContext.getExperimentId() + " processId: " + processContext.getProcessId() + " : - Error while updating experiment inputs";
throw new GFacException(msg, e);
}
}
use of org.apache.airavata.model.application.io.InputDataObjectType in project airavata by apache.
the class RegistryServerHandler method getApplicationInputs.
/**
* Fetch the list of Application Inputs.
*
* @param appInterfaceId The identifier of the application interface which need inputs to be fetched.
* @return list<application_interface_model.InputDataObjectType>
* Returns a list of application inputs.
*/
@Override
public List<InputDataObjectType> getApplicationInputs(String appInterfaceId) throws RegistryServiceException, TException {
try {
appCatalog = RegistryFactory.getAppCatalog();
List<InputDataObjectType> applicationInputs = appCatalog.getApplicationInterface().getApplicationInputs(appInterfaceId);
logger.debug("Airavata retrieved application inputs for application interface id : " + appInterfaceId);
return applicationInputs;
} catch (AppCatalogException e) {
logger.error(appInterfaceId, "Error while retrieving application inputs...", e);
RegistryServiceException exception = new RegistryServiceException();
exception.setMessage("Error while retrieving application inputs. More info : " + e.getMessage());
throw exception;
}
}
Aggregations