Search in sources :

Example 1 with ExperimentModel

use of org.apache.airavata.model.experiment.ExperimentModel 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 2 with ExperimentModel

use of org.apache.airavata.model.experiment.ExperimentModel 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 3 with ExperimentModel

use of org.apache.airavata.model.experiment.ExperimentModel in project airavata by apache.

the class GFacUtils method saveExperimentOutput.

public static void saveExperimentOutput(ProcessContext processContext, String outputName, String outputVal) throws GFacException {
    try {
        ExperimentCatalog experimentCatalog = processContext.getExperimentCatalog();
        String experimentId = processContext.getExperimentId();
        ExperimentModel experiment = (ExperimentModel) experimentCatalog.get(ExperimentCatalogModelType.EXPERIMENT, experimentId);
        List<OutputDataObjectType> experimentOutputs = experiment.getExperimentOutputs();
        if (experimentOutputs != null && !experimentOutputs.isEmpty()) {
            for (OutputDataObjectType expOutput : experimentOutputs) {
                if (expOutput.getName().equals(outputName)) {
                    DataProductModel dataProductModel = new DataProductModel();
                    dataProductModel.setGatewayId(processContext.getGatewayId());
                    dataProductModel.setOwnerName(processContext.getProcessModel().getUserName());
                    dataProductModel.setProductName(outputName);
                    dataProductModel.setDataProductType(DataProductType.FILE);
                    DataReplicaLocationModel replicaLocationModel = new DataReplicaLocationModel();
                    replicaLocationModel.setStorageResourceId(processContext.getStorageResource().getStorageResourceId());
                    replicaLocationModel.setReplicaName(outputName + " gateway data store copy");
                    replicaLocationModel.setReplicaLocationCategory(ReplicaLocationCategory.GATEWAY_DATA_STORE);
                    replicaLocationModel.setReplicaPersistentType(ReplicaPersistentType.TRANSIENT);
                    replicaLocationModel.setFilePath(outputVal);
                    dataProductModel.addToReplicaLocations(replicaLocationModel);
                    ReplicaCatalog replicaCatalog = RegistryFactory.getReplicaCatalog();
                    String productUri = replicaCatalog.registerDataProduct(dataProductModel);
                    expOutput.setValue(productUri);
                }
            }
        }
        experimentCatalog.update(ExperimentCatalogModelType.EXPERIMENT, experiment, experimentId);
    } catch (RegistryException e) {
        String msg = "expId: " + processContext.getExperimentId() + " processId: " + processContext.getProcessId() + " : - Error while updating experiment outputs";
        throw new GFacException(msg, e);
    }
}
Also used : OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel)

Example 4 with ExperimentModel

use of org.apache.airavata.model.experiment.ExperimentModel in project airavata by apache.

the class SimpleEchoIT method testSimpleLocalhostEchoService.

@Test
public void testSimpleLocalhostEchoService() throws Exception {
    log.info("Running job in localhost");
    log.info("========================");
    log.info("Adding applications...");
    DocumentCreatorNew documentCreatorNew = new DocumentCreatorNew(getClient());
    String hostAndappId = documentCreatorNew.createLocalHostDocs();
    String appId = hostAndappId.split(",")[1];
    String hostId = hostAndappId.split(",")[0];
    List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>();
    InputDataObjectType input = new InputDataObjectType();
    input.setName("echo_input");
    input.setType(DataType.STRING);
    input.setValue("echo_output=Hello World");
    exInputs.add(input);
    List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
    OutputDataObjectType output = new OutputDataObjectType();
    output.setName("echo_output");
    output.setType(DataType.STRING);
    output.setValue("");
    exOut.add(output);
    Project project = ProjectModelUtil.createProject("project1", "admin", "test project");
    String projectId = getClient().createProject(authzToken, "php_reference_gateway", project);
    ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment("php_reference_gateway", projectId, "admin", "echoExperiment", appId, appId, exInputs);
    simpleExperiment.setExperimentOutputs(exOut);
    ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(hostId, 1, 1, 1, "normal", 1, 0);
    scheduling.setResourceHostId(hostId);
    UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
    userConfigurationData.setAiravataAutoSchedule(false);
    userConfigurationData.setOverrideManualScheduledParams(false);
    userConfigurationData.setComputationalResourceScheduling(scheduling);
    simpleExperiment.setUserConfigurationData(userConfigurationData);
    log.info("Creating experiment...");
    final String expId = createExperiment(simpleExperiment);
    log.info("Experiment Id returned : " + expId);
    launchExperiment(expId);
    log.info("Experiment launched successfully\n");
    log.info("Monitoring job in localhost");
    log.info("===========================");
    monitorJob(expId);
}
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) ArrayList(java.util.ArrayList) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) DocumentCreatorNew(org.apache.airavata.integration.tools.DocumentCreatorNew) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 5 with ExperimentModel

use of org.apache.airavata.model.experiment.ExperimentModel in project airavata by apache.

the class BaseCaseIT method testEchoService.

// @Test(groups = {"setupTests"}, dependsOnMethods = {"testSetup"})
// public void testURLs() throws AiravataAPIInvocationException {
// URI eventingServiceURL = this.airavataAPI.getAiravataManager().getEventingServiceURL();
// Assert.assertNotNull(eventingServiceURL);
// 
// URI messageBoxServiceURL = this.airavataAPI.getAiravataManager().getMessageBoxServiceURL();
// Assert.assertNotNull(messageBoxServiceURL);
// }
@Test(groups = { "echoGroup" }, dependsOnGroups = { "setupTests" })
public void testEchoService() throws Exception {
    log.info("Running job in trestles...");
    DocumentCreatorNew documentCreator = new DocumentCreatorNew(client);
    documentCreator.createPBSDocsForOGCE_Echo();
    List<InputDataObjectType> exInputs = new ArrayList<InputDataObjectType>();
    InputDataObjectType input = new InputDataObjectType();
    input.setName("echo_input");
    input.setType(DataType.STRING);
    input.setValue("echo_output=Hello World");
    exInputs.add(input);
    List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
    OutputDataObjectType output = new OutputDataObjectType();
    output.setName("echo_output");
    output.setType(DataType.STRING);
    output.setValue("");
    exOut.add(output);
    Project project = ProjectModelUtil.createProject("project1", "admin", "test project");
    String projectId = getClient().createProject(authzToken, "default", project);
    ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(gatewayName, projectId, "admin", "echoExperiment", "SimpleEcho2", "SimpleEcho2", exInputs);
    simpleExperiment.setExperimentOutputs(exOut);
    ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("trestles.sdsc.edu", 1, 1, 1, "normal", 0, 0);
    scheduling.setResourceHostId("gsissh-trestles");
    UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
    userConfigurationData.setAiravataAutoSchedule(false);
    userConfigurationData.setOverrideManualScheduledParams(false);
    userConfigurationData.setComputationalResourceScheduling(scheduling);
    simpleExperiment.setUserConfigurationData(userConfigurationData);
    final String expId = createExperiment(simpleExperiment);
    System.out.println("Experiment Id returned : " + expId);
    log.info("Experiment Id returned : " + expId);
    launchExperiment(expId);
    System.out.println("Launched successfully");
    Thread monitor = (new Thread() {

        public void run() {
            Map<String, JobStatus> jobStatuses = null;
            while (true) {
                try {
                    jobStatuses = client.getJobStatuses(authzToken, expId);
                    Set<String> strings = jobStatuses.keySet();
                    for (String key : strings) {
                        JobStatus jobStatus = jobStatuses.get(key);
                        if (jobStatus == null) {
                            return;
                        } else {
                            if (JobState.COMPLETE.equals(jobStatus.getJobState())) {
                                log.info("Job completed Job ID: " + key);
                                return;
                            } else {
                                log.info("Job ID:" + key + "  Job Status : " + jobStatuses.get(key).getJobState().toString());
                            }
                        }
                    }
                    Thread.sleep(5000);
                } catch (Exception e) {
                    log.error("Thread interrupted", e.getMessage());
                }
            }
        }
    });
    monitor.start();
    try {
        monitor.join();
    } catch (InterruptedException e) {
        log.error("Thread interrupted..", e.getMessage());
    }
}
Also used : Set(java.util.Set) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ArrayList(java.util.ArrayList) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) JobStatus(org.apache.airavata.model.status.JobStatus) Project(org.apache.airavata.model.workspace.Project) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) DocumentCreatorNew(org.apache.airavata.integration.tools.DocumentCreatorNew) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) Map(java.util.Map) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

ExperimentModel (org.apache.airavata.model.experiment.ExperimentModel)49 TException (org.apache.thrift.TException)35 InputDataObjectType (org.apache.airavata.model.application.io.InputDataObjectType)34 UserConfigurationDataModel (org.apache.airavata.model.experiment.UserConfigurationDataModel)34 OutputDataObjectType (org.apache.airavata.model.application.io.OutputDataObjectType)33 ComputationalResourceSchedulingModel (org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)33 AuthzToken (org.apache.airavata.model.security.AuthzToken)33 Project (org.apache.airavata.model.workspace.Project)17 ArrayList (java.util.ArrayList)15 AiravataClientException (org.apache.airavata.model.error.AiravataClientException)7 AiravataSystemException (org.apache.airavata.model.error.AiravataSystemException)7 InvalidRequestException (org.apache.airavata.model.error.InvalidRequestException)7 ErrorModel (org.apache.airavata.model.commons.ErrorModel)5 DocumentCreatorNew (org.apache.airavata.integration.tools.DocumentCreatorNew)3 BeforeTest (org.testng.annotations.BeforeTest)3 Test (org.testng.annotations.Test)3 Map (java.util.Map)2 Set (java.util.Set)2 ApplicationSettingsException (org.apache.airavata.common.exception.ApplicationSettingsException)2 ComputeResourceDescription (org.apache.airavata.model.appcatalog.computeresource.ComputeResourceDescription)2