Search in sources :

Example 6 with ExperimentModel

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

the class BaseCaseIT method testEchoServiceStampede.

@Test(groups = { "echoGroup" }, dependsOnGroups = { "setupTests" })
public void testEchoServiceStampede() throws Exception {
    log.info("Running job in Stampede...");
    DocumentCreatorNew documentCreator = new DocumentCreatorNew(client);
    documentCreator.createSlurmDocs();
    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", "SimpleEcho3", "SimpleEcho3", exInputs);
    simpleExperiment.setExperimentOutputs(exOut);
    ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling("stampede.tacc.xsede.org", 1, 1, 1, "normal", 0, 0);
    scheduling.setResourceHostId("stampede-host");
    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)

Example 7 with ExperimentModel

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

the class ExperimentRegistry method getExperimentList.

public List<ExperimentModel> getExperimentList(String fieldName, Object value, int limit, int offset, Object orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
    List<ExperimentModel> experiments = new ArrayList<ExperimentModel>();
    try {
        if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.USER_NAME)) {
            WorkerResource resource = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
            resource.setUser((String) value);
            List<ExperimentResource> resources = resource.getExperiments(limit, offset, orderByIdentifier, resultOrderType);
            for (ExperimentResource experimentResource : resources) {
                ExperimentModel experiment = ThriftDataModelConversion.getExperiment(experimentResource);
                experiments.add(experiment);
            }
            return experiments;
        } else if (fieldName.equals(Constants.FieldConstants.ExperimentConstants.PROJECT_ID)) {
            ProjectResource project = workerResource.getProject((String) value);
            List<ExperimentResource> resources = project.getExperiments(limit, offset, Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
            for (ExperimentResource resource : resources) {
                ExperimentModel experiment = ThriftDataModelConversion.getExperiment(resource);
                experiments.add(experiment);
            }
            return experiments;
        }
        logger.error("Unsupported field name to retrieve experiment list...");
    } catch (Exception e) {
        logger.error("Error while getting experiment list...", e);
        throw new RegistryException(e);
    }
    return experiments;
}
Also used : ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) RegistryException(org.apache.airavata.registry.cpi.RegistryException) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Example 8 with ExperimentModel

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

the class CreateLaunchExperiment method createEchoExperimentForStampede.

// public static String createExperimentForSSHHost(Airavata.Client client) throws TException {
// try {
// List<OutputDataObjectType> exInputs = new ArrayList<OutputDataObjectType>();
// OutputDataObjectType input = new OutputDataObjectType();
// input.setName("echo_input");
// input.setType(DataType.STRING);
// input.setValue("Echoed_Output=Hello World");
// exInputs.add(input);
// 
// List<OutputDataObjectType> exOut = new ArrayList<OutputDataObjectType>();
// OutputDataObjectType output = new OutputDataObjectType();
// output.setName("Echoed_Output");
// output.setType(DataType.STRING);
// output.setValue("");
// exOut.add(output);
// 
// Project project = ProjectModelUtil.createProject("default", "admin", "test project");
// String projectId = client.createProject(project);
// 
// ExperimentModel simpleExperiment =
// ExperimentModelUtil.createSimpleExperiment(projectId, "admin", "sshEchoExperiment", "SSHEcho1", sshHostAppId.split(",")[1], exInputs);
// simpleExperiment.setExperimentOutputs(exOut);
// 
// ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(sshHostAppId.split(",")[0], 1, 1, 1, "normal", 1, 0, 1, "sds128");
// scheduling.setResourceHostId("gw111.iu.xsede.org");
// UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
// userConfigurationData.setAiravataAutoSchedule(false);
// userConfigurationData.setOverrideManualScheduledParams(false);
// userConfigurationData.setComputationalResourceScheduling(scheduling);
// simpleExperiment.setUserConfigurationData(userConfigurationData);
// return client.createExperiment(simpleExperiment);
// } catch (AiravataSystemException e) {
// logger.error("Error occured while creating the experiment...", e.getMessage());
// throw new AiravataSystemException(e);
// } catch (InvalidRequestException e) {
// logger.error("Error occured while creating the experiment...", e.getMessage());
// throw new InvalidRequestException(e);
// } catch (AiravataClientException e) {
// logger.error("Error occured while creating the experiment...", e.getMessage());
// throw new AiravataClientException(e);
// } catch (TException e) {
// logger.error("Error occured while creating the experiment...", e.getMessage());
// throw new TException(e);
// }
// }
public static String createEchoExperimentForStampede(Airavata.Client client) throws TException {
    try {
        List<InputDataObjectType> exInputs = client.getApplicationInputs(new AuthzToken(""), echoAppId);
        // for (InputDataObjectType inputDataObjectType : exInputs) {
        // if (inputDataObjectType.getName().equalsIgnoreCase("Input_to_Echo")) {
        // inputDataObjectType.setValue("Hello World");
        // }
        // }
        // List<OutputDataObjectType> exOut = client.getApplicationOutputs(new AuthzToken(""), echoAppId);
        Project project = ProjectModelUtil.createProject("default", "admin", "test project");
        String projectId = client.createProject(new AuthzToken(""), DEFAULT_GATEWAY, project);
        ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, projectId, "admin", "echoExperiment", "SimpleEcho3", echoAppId, exInputs);
        // simpleExperiment.setExperimentOutputs(exOut);
        Map<String, String> computeResources = airavataClient.getAvailableAppInterfaceComputeResources(new AuthzToken(""), echoAppId);
        if (computeResources != null && computeResources.size() != 0) {
            for (String id : computeResources.keySet()) {
                String resourceName = computeResources.get(id);
                if (resourceName.equals(stampedeHostName)) {
                    ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 1, 1, 1, "normal", 30, 1);
                    UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
                    userConfigurationData.setAiravataAutoSchedule(false);
                    userConfigurationData.setOverrideManualScheduledParams(false);
                    userConfigurationData.setComputationalResourceScheduling(scheduling);
                    simpleExperiment.setUserConfigurationData(userConfigurationData);
                    return client.createExperiment(new AuthzToken(""), DEFAULT_GATEWAY, simpleExperiment);
                }
            }
        }
    } catch (AiravataSystemException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataSystemException(e);
    } catch (InvalidRequestException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new InvalidRequestException(e);
    } catch (AiravataClientException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataClientException(e);
    } catch (TException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new TException(e);
    }
    return null;
}
Also used : TException(org.apache.thrift.TException) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) Project(org.apache.airavata.model.workspace.Project) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) AuthzToken(org.apache.airavata.model.security.AuthzToken) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 9 with ExperimentModel

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

the class CreateLaunchExperiment method getExperiment.

public static void getExperiment(Airavata.Client client, String expId) throws Exception {
    try {
        ExperimentModel experiment = client.getExperiment(new AuthzToken(""), expId);
        List<ErrorModel> errors = experiment.getErrors();
        if (errors != null && !errors.isEmpty()) {
            for (ErrorModel error : errors) {
                System.out.println("ERROR MESSAGE : " + error.getActualErrorMessage());
            }
        }
    } catch (ExperimentNotFoundException e) {
        logger.error("Experiment does not exist", e);
        throw new ExperimentNotFoundException("Experiment does not exist");
    } catch (AiravataSystemException e) {
        logger.error("Error while retrieving experiment", e);
        throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
    } catch (InvalidRequestException e) {
        logger.error("Error while retrieving experiment", e);
        throw new InvalidRequestException("Error while retrieving experiment");
    } catch (AiravataClientException e) {
        logger.error("Error while retrieving experiment", e);
        throw new AiravataClientException(AiravataErrorType.INTERNAL_ERROR);
    }
}
Also used : ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) AuthzToken(org.apache.airavata.model.security.AuthzToken) ErrorModel(org.apache.airavata.model.commons.ErrorModel)

Example 10 with ExperimentModel

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

the class CreateLaunchExperiment method createExperimentESPRESSOStampede.

public static String createExperimentESPRESSOStampede(Airavata.Client client) throws TException {
    try {
        List<InputDataObjectType> exInputs = client.getApplicationInputs(new AuthzToken(""), espressoAppId);
        setESPRESSOInputs(exInputs);
        List<OutputDataObjectType> exOut = client.getApplicationOutputs(new AuthzToken(""), espressoAppId);
        ExperimentModel simpleExperiment = ExperimentModelUtil.createSimpleExperiment(DEFAULT_GATEWAY, "default", "admin", "EspressoExperiment", "Testing", espressoAppId, exInputs);
        simpleExperiment.setExperimentOutputs(exOut);
        Map<String, String> computeResources = airavataClient.getAvailableAppInterfaceComputeResources(new AuthzToken(""), espressoAppId);
        if (computeResources != null && computeResources.size() != 0) {
            for (String id : computeResources.keySet()) {
                String resourceName = computeResources.get(id);
                if (resourceName.equals(stampedeHostName)) {
                    ComputationalResourceSchedulingModel scheduling = ExperimentModelUtil.createComputationResourceScheduling(id, 1, 16, 1, "development", 30, 1);
                    UserConfigurationDataModel userConfigurationData = new UserConfigurationDataModel();
                    userConfigurationData.setAiravataAutoSchedule(false);
                    userConfigurationData.setOverrideManualScheduledParams(false);
                    userConfigurationData.setComputationalResourceScheduling(scheduling);
                    simpleExperiment.setUserConfigurationData(userConfigurationData);
                    return client.createExperiment(new AuthzToken(""), DEFAULT_GATEWAY, simpleExperiment);
                }
            }
        }
    } catch (AiravataSystemException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataSystemException(e);
    } catch (InvalidRequestException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new InvalidRequestException(e);
    } catch (AiravataClientException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new AiravataClientException(e);
    } catch (TException e) {
        logger.error("Error occured while creating the experiment...", e.getMessage());
        throw new TException(e);
    }
    return null;
}
Also used : TException(org.apache.thrift.TException) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) UserConfigurationDataModel(org.apache.airavata.model.experiment.UserConfigurationDataModel) AuthzToken(org.apache.airavata.model.security.AuthzToken) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

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