Search in sources :

Example 6 with InputDataObjectType

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

Example 7 with InputDataObjectType

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;
}
Also used : InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType)

Example 8 with InputDataObjectType

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);
    }
}
Also used : InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel)

Example 9 with InputDataObjectType

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);
    }
}
Also used : ProcessModel(org.apache.airavata.model.process.ProcessModel) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType)

Example 10 with InputDataObjectType

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;
    }
}
Also used : RegistryServiceException(org.apache.airavata.registry.api.exception.RegistryServiceException) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType)

Aggregations

InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)86 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)60 TException (org.apache.thrift.TException)49 AuthzToken (org.apache.airavata.model.security.AuthzToken)46 UserConfigurationDataModel (org.apache.airavata.model.experiment.UserConfigurationDataModel)35 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)35 ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)34 ArrayList (java.util.ArrayList)20 Project (org.apache.airavata.model.workspace.Project)17 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)7 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)7 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)7 RegistryException (org.apache.airavata.registry.cpi.RegistryException)6 HashMap (java.util.HashMap)3 DocumentCreatorNew (org.apache.airavata.integration.tools.DocumentCreatorNew)3 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)3 BeforeTest (org.testng.annotations.BeforeTest)3 Test (org.testng.annotations.Test)3 JSchException (com.jcraft.jsch.JSchException)2 Session (com.jcraft.jsch.Session)2