Search in sources :

Example 1 with CommandObject

use of org.apache.airavata.model.appcatalog.appdeployment.CommandObject in project airavata by apache.

the class GFacUtils method createGroovyMap.

public static GroovyMap createGroovyMap(ProcessContext processContext, TaskContext taskContext) throws GFacException, AppCatalogException, ApplicationSettingsException {
    GroovyMap groovyMap = new GroovyMap();
    ProcessModel processModel = processContext.getProcessModel();
    ResourceJobManager resourceJobManager = getResourceJobManager(processContext);
    // set email options and addresses
    setMailAddresses(processContext, groovyMap);
    groovyMap.add(Script.INPUT_DIR, processContext.getInputDir());
    groovyMap.add(Script.OUTPUT_DIR, processContext.getOutputDir());
    groovyMap.add(Script.EXECUTABLE_PATH, processContext.getApplicationDeploymentDescription().getExecutablePath());
    groovyMap.add(Script.STANDARD_OUT_FILE, processContext.getStdoutLocation());
    groovyMap.add(Script.STANDARD_ERROR_FILE, processContext.getStderrLocation());
    groovyMap.add(Script.SCRATCH_LOCATION, processContext.getScratchLocation());
    groovyMap.add(Script.GATEWAY_ID, processContext.getGatewayId());
    groovyMap.add(Script.GATEWAY_USER_NAME, processContext.getProcessModel().getUserName());
    groovyMap.add(Script.APPLICATION_NAME, processContext.getApplicationInterfaceDescription().getApplicationName());
    groovyMap.add(Script.QUEUE_SPECIFIC_MACROS, processContext.getQueueSpecificMacros());
    groovyMap.add(Script.ACCOUNT_STRING, processContext.getAllocationProjectNumber());
    groovyMap.add(Script.RESERVATION, processContext.getReservation());
    // To make job name alpha numeric
    groovyMap.add(Script.JOB_NAME, "A" + String.valueOf(generateJobName()));
    groovyMap.add(Script.WORKING_DIR, processContext.getWorkingDir());
    List<String> inputValues = getProcessInputValues(processModel.getProcessInputs());
    inputValues.addAll(getProcessOutputValues(processModel.getProcessOutputs()));
    groovyMap.add(Script.INPUTS, inputValues);
    groovyMap.add(Script.USER_NAME, processContext.getJobSubmissionRemoteCluster().getServerInfo().getUserName());
    groovyMap.add(Script.SHELL_NAME, "/bin/bash");
    // get walltime
    if (taskContext != null) {
        try {
            JobSubmissionTaskModel jobSubmissionTaskModel = ((JobSubmissionTaskModel) taskContext.getSubTaskModel());
            if (jobSubmissionTaskModel.getWallTime() > 0) {
                groovyMap.add(Script.MAX_WALL_TIME, GFacUtils.maxWallTimeCalculator(jobSubmissionTaskModel.getWallTime()));
                if (resourceJobManager != null) {
                    if (resourceJobManager.getResourceJobManagerType().equals(ResourceJobManagerType.LSF)) {
                        groovyMap.add(Script.MAX_WALL_TIME, GFacUtils.maxWallTimeCalculatorForLSF(jobSubmissionTaskModel.getWallTime()));
                    }
                }
            }
        } catch (TException e) {
            log.error("Error while getting job submission sub task model", e);
        }
    }
    // NOTE: Give precedence to data comes with experiment
    // qos per queue
    String qoS = getQoS(processContext.getQualityOfService(), processContext.getQueueName());
    if (qoS != null) {
        groovyMap.add(Script.QUALITY_OF_SERVICE, qoS);
    }
    ComputationalResourceSchedulingModel scheduling = processModel.getProcessResourceSchedule();
    if (scheduling != null) {
        int totalNodeCount = scheduling.getNodeCount();
        int totalCPUCount = scheduling.getTotalCPUCount();
        if (isValid(scheduling.getQueueName())) {
            groovyMap.add(Script.QUEUE_NAME, scheduling.getQueueName());
        }
        if (totalNodeCount > 0) {
            groovyMap.add(Script.NODES, totalNodeCount);
        }
        if (totalCPUCount > 0) {
            int ppn = totalCPUCount / totalNodeCount;
            groovyMap.add(Script.PROCESS_PER_NODE, ppn);
            groovyMap.add(Script.CPU_COUNT, totalCPUCount);
        }
        // if so we ignore scheduling configuration.
        if (scheduling.getWallTimeLimit() > 0 && groovyMap.get(Script.MAX_WALL_TIME) == null) {
            groovyMap.add(Script.MAX_WALL_TIME, GFacUtils.maxWallTimeCalculator(scheduling.getWallTimeLimit()));
            if (resourceJobManager != null) {
                if (resourceJobManager.getResourceJobManagerType().equals(ResourceJobManagerType.LSF)) {
                    groovyMap.add(Script.MAX_WALL_TIME, GFacUtils.maxWallTimeCalculatorForLSF(scheduling.getWallTimeLimit()));
                }
            }
        }
        if (scheduling.getTotalPhysicalMemory() > 0) {
            groovyMap.add(Script.USED_MEM, scheduling.getTotalPhysicalMemory());
        }
        if (isValid(scheduling.getOverrideLoginUserName())) {
            groovyMap.add(Script.USER_NAME, scheduling.getOverrideLoginUserName());
        }
        if (isValid(scheduling.getOverrideAllocationProjectNumber())) {
            groovyMap.add(Script.ACCOUNT_STRING, scheduling.getOverrideAllocationProjectNumber());
        }
        if (isValid(scheduling.getStaticWorkingDir())) {
            groovyMap.add(Script.WORKING_DIR, scheduling.getStaticWorkingDir());
        }
    } else {
        log.error("Task scheduling cannot be null at this point..");
    }
    ApplicationDeploymentDescription appDepDescription = processContext.getApplicationDeploymentDescription();
    List<CommandObject> moduleCmds = appDepDescription.getModuleLoadCmds();
    if (moduleCmds != null) {
        List<String> modulesCmdCollect = moduleCmds.stream().sorted((e1, e2) -> e1.getCommandOrder() - e2.getCommandOrder()).map(map -> map.getCommand()).collect(Collectors.toList());
        groovyMap.add(Script.MODULE_COMMANDS, modulesCmdCollect);
    }
    List<CommandObject> preJobCommands = appDepDescription.getPreJobCommands();
    if (preJobCommands != null) {
        List<String> preJobCmdCollect = preJobCommands.stream().sorted((e1, e2) -> e1.getCommandOrder() - e2.getCommandOrder()).map(map -> parseCommands(map.getCommand(), groovyMap)).collect(Collectors.toList());
        groovyMap.add(Script.PRE_JOB_COMMANDS, preJobCmdCollect);
    }
    List<CommandObject> postJobCommands = appDepDescription.getPostJobCommands();
    if (postJobCommands != null) {
        List<String> postJobCmdCollect = postJobCommands.stream().sorted((e1, e2) -> e1.getCommandOrder() - e2.getCommandOrder()).map(map -> parseCommands(map.getCommand(), groovyMap)).collect(Collectors.toList());
        groovyMap.add(Script.POST_JOB_COMMANDS, postJobCmdCollect);
    }
    ApplicationParallelismType parallelism = appDepDescription.getParallelism();
    if (parallelism != null) {
        if (parallelism != ApplicationParallelismType.SERIAL) {
            Map<ApplicationParallelismType, String> parallelismPrefix = processContext.getResourceJobManager().getParallelismPrefix();
            if (parallelismPrefix != null) {
                String parallelismCommand = parallelismPrefix.get(parallelism);
                if (parallelismCommand != null) {
                    groovyMap.add(Script.JOB_SUBMITTER_COMMAND, parallelismCommand);
                } else {
                    throw new GFacException("Parallelism prefix is not defined for given parallelism type " + parallelism + ".. Please define the parallelism prefix at App Catalog");
                }
            }
        }
    }
    return groovyMap;
}
Also used : TException(org.apache.thrift.TException) CreateMode(org.apache.zookeeper.CreateMode) TemplateEngine(groovy.text.TemplateEngine) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) TaskContext(org.apache.airavata.gfac.core.context.TaskContext) Stat(org.apache.zookeeper.data.Stat) ByteBuffer(java.nio.ByteBuffer) InetAddress(java.net.InetAddress) SecureRandom(java.security.SecureRandom) ZKPaths(org.apache.curator.utils.ZKPaths) Matcher(java.util.regex.Matcher) Document(org.w3c.dom.Document) CredentialReaderImpl(org.apache.airavata.credential.store.store.impl.CredentialReaderImpl) org.apache.airavata.model.data.replica(org.apache.airavata.model.data.replica) ProcessContext(org.apache.airavata.gfac.core.context.ProcessContext) DataType(org.apache.airavata.model.application.io.DataType) org.apache.airavata.common.utils(org.apache.airavata.common.utils) JobSubmissionTaskModel(org.apache.airavata.model.task.JobSubmissionTaskModel) Collectors(java.util.stream.Collectors) CuratorFramework(org.apache.curator.framework.CuratorFramework) ErrorModel(org.apache.airavata.model.commons.ErrorModel) GStringTemplateEngine(groovy.text.GStringTemplateEngine) Pattern(java.util.regex.Pattern) org.apache.airavata.model.appcatalog.computeresource(org.apache.airavata.model.appcatalog.computeresource) java.util(java.util) JobModel(org.apache.airavata.model.job.JobModel) ACL(org.apache.zookeeper.data.ACL) Writable(groovy.lang.Writable) javax.xml.xpath(javax.xml.xpath) CredentialReader(org.apache.airavata.credential.store.store.CredentialReader) Node(org.w3c.dom.Node) MessageContext(org.apache.airavata.messaging.core.MessageContext) RegistryFactory(org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory) InputDataObjectType(org.apache.airavata.model.application.io.InputDataObjectType) Logger(org.slf4j.Logger) NodeList(org.w3c.dom.NodeList) Constants(org.apache.airavata.registry.cpi.utils.Constants) TException(org.apache.thrift.TException) FileUtils(org.apache.commons.io.FileUtils) org.apache.airavata.model.status(org.apache.airavata.model.status) ApplicationParallelismType(org.apache.airavata.model.parallelism.ApplicationParallelismType) org.apache.airavata.registry.cpi(org.apache.airavata.registry.cpi) UnknownHostException(java.net.UnknownHostException) ComputeResourcePreference(org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference) Element(org.w3c.dom.Element) ExperimentModel(org.apache.airavata.model.experiment.ExperimentModel) ZooDefs(org.apache.zookeeper.ZooDefs) java.io(java.io) ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel) org.apache.airavata.model.messaging.event(org.apache.airavata.model.messaging.event) ProcessModel(org.apache.airavata.model.process.ProcessModel) ApplicationSettingsException(org.apache.airavata.common.exception.ApplicationSettingsException) CommandObject(org.apache.airavata.model.appcatalog.appdeployment.CommandObject) OutputDataObjectType(org.apache.airavata.model.application.io.OutputDataObjectType) ProcessModel(org.apache.airavata.model.process.ProcessModel) ApplicationDeploymentDescription(org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription) ApplicationParallelismType(org.apache.airavata.model.parallelism.ApplicationParallelismType) CommandObject(org.apache.airavata.model.appcatalog.appdeployment.CommandObject) JobSubmissionTaskModel(org.apache.airavata.model.task.JobSubmissionTaskModel) ComputationalResourceSchedulingModel(org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel)

Example 2 with CommandObject

use of org.apache.airavata.model.appcatalog.appdeployment.CommandObject in project airavata by apache.

the class AppCatalogThriftConversion method getCommandObject.

private static CommandObject getCommandObject(String command, int commandOrder) {
    CommandObject commandObject = new CommandObject();
    commandObject.setCommand(command);
    commandObject.setCommandOrder(commandOrder);
    return commandObject;
}
Also used : CommandObject(org.apache.airavata.model.appcatalog.appdeployment.CommandObject)

Example 3 with CommandObject

use of org.apache.airavata.model.appcatalog.appdeployment.CommandObject in project airavata by apache.

the class RegisterSampleApplications method registerAlamoApps.

public void registerAlamoApps() {
    try {
        System.out.println("#### Registering Application Deployments on Alamo #### \n");
        // Register Ultrascan on Alamo
        List<CommandObject> ultrascanMouldes = new ArrayList();
        ultrascanMouldes.add(new CommandObject("module load intel/2015/64"));
        ultrascanMouldes.add(new CommandObject("module load openmpi/intel/1.8.4"));
        ultrascanMouldes.add(new CommandObject("module load qt4/4.8.6"));
        ultrascanMouldes.add(new CommandObject("module load ultrascan3/3.3"));
        String ultrascanAppDeployId = airavataClient.registerApplicationDeployment(new AuthzToken(""), DEFAULT_GATEWAY, RegisterSampleApplicationsUtils.createApplicationDeployment(ultrascanModuleId, alamoResourceId, "/home/us3/bin/us_mpi_analysis", ApplicationParallelismType.OPENMP, ultrascanDescription, ultrascanMouldes, null, null));
        System.out.println("Ultrascan on alamo deployment Id " + ultrascanAppDeployId);
    } catch (TException e) {
        e.printStackTrace();
    }
}
Also used : CommandObject(org.apache.airavata.model.appcatalog.appdeployment.CommandObject) TException(org.apache.thrift.TException) AuthzToken(org.apache.airavata.model.security.AuthzToken)

Example 4 with CommandObject

use of org.apache.airavata.model.appcatalog.appdeployment.CommandObject in project airavata by apache.

the class RegisterSampleApplications method registerTrestlesApps.

public void registerTrestlesApps() {
    try {
        System.out.println("#### Registering Application Deployments on Trestles #### \n");
        // Register Echo
        String echoAppDeployId = airavataClient.registerApplicationDeployment(new AuthzToken(""), DEFAULT_GATEWAY, RegisterSampleApplicationsUtils.createApplicationDeployment(echoModuleId, trestlesResourceId, "/home/ogce/production/app_wrappers/echo_wrapper.sh", ApplicationParallelismType.SERIAL, echoDescription, null, null, null));
        System.out.println("Echo on trestles deployment Id " + echoAppDeployId);
        // Register Amber
        List<CommandObject> moduleLoadCMDs = new ArrayList();
        moduleLoadCMDs.add(new CommandObject("module load amber"));
        String amberAppDeployId = airavataClient.registerApplicationDeployment(new AuthzToken(""), DEFAULT_GATEWAY, RegisterSampleApplicationsUtils.createApplicationDeployment(amberModuleId, trestlesResourceId, "/opt/amber/bin/sander.MPI -O", ApplicationParallelismType.MPI, amberDescription, moduleLoadCMDs, null, null));
        System.out.println("Amber on trestles deployment Id " + amberAppDeployId);
        // Register GROMACS
        String gromacsAppDeployId = airavataClient.registerApplicationDeployment(new AuthzToken(""), DEFAULT_GATEWAY, RegisterSampleApplicationsUtils.createApplicationDeployment(gromacsModuleId, trestlesResourceId, "/home/ogce/production/app_wrappers/gromacs_wrapper.sh", ApplicationParallelismType.MPI, gromacsDescription, null, null, null));
        System.out.println("GROMACS on trestles deployment Id " + gromacsAppDeployId);
        // Register LAMMPS
        String lammpsAppDeployId = airavataClient.registerApplicationDeployment(new AuthzToken(""), DEFAULT_GATEWAY, RegisterSampleApplicationsUtils.createApplicationDeployment(lammpsModuleId, trestlesResourceId, "/home/ogce/production/app_wrappers/lammps_wrapper.sh", ApplicationParallelismType.MPI, lammpsDescription, null, null, null));
        System.out.println("LAMMPS on trestles deployment Id " + lammpsAppDeployId);
        // Register GAMESS
        List<CommandObject> moduleLoadCmd = new ArrayList();
        moduleLoadCmd.add(new CommandObject("module load gamess"));
        String gamessAppDeployId = airavataClient.registerApplicationDeployment(new AuthzToken(""), DEFAULT_GATEWAY, RegisterSampleApplicationsUtils.createApplicationDeployment(gamessModuleId, trestlesResourceId, "/opt/gamess/rungms", ApplicationParallelismType.MPI, gamessDescription, moduleLoadCmd, null, null));
        System.out.println("Gamess on trestles deployment Id " + gamessAppDeployId);
        List<CommandObject> gaussianMouldes = new ArrayList();
        gaussianMouldes.add(new CommandObject("module load gaussian"));
        String gaussianAppDeployId = airavataClient.registerApplicationDeployment(new AuthzToken(""), DEFAULT_GATEWAY, RegisterSampleApplicationsUtils.createApplicationDeployment(gaussianModuleId, trestlesResourceId, "g09", ApplicationParallelismType.OPENMP, gaussianDescription, gaussianMouldes, null, null));
        System.out.println("Gaussian on trestles deployment Id " + gaussianAppDeployId);
    } catch (TException e) {
        e.printStackTrace();
    }
}
Also used : CommandObject(org.apache.airavata.model.appcatalog.appdeployment.CommandObject) TException(org.apache.thrift.TException) AuthzToken(org.apache.airavata.model.security.AuthzToken)

Example 5 with CommandObject

use of org.apache.airavata.model.appcatalog.appdeployment.CommandObject in project airavata by apache.

the class RegisterSampleApplications method registerLSFApps.

public void registerLSFApps() {
    try {
        System.out.println("#### Registering Application Deployments on Trestles #### \n");
        // Register Echo
        String echoAppDeployId = airavataClient.registerApplicationDeployment(new AuthzToken(""), DEFAULT_GATEWAY, RegisterSampleApplicationsUtils.createApplicationDeployment(echoModuleId, lsfResourceId, "/home/lg11w/executables/echo.sh", ApplicationParallelismType.SERIAL, echoDescription, null, null, null));
        List<CommandObject> moduleLoadCmd = new ArrayList();
        moduleLoadCmd.add(new CommandObject("module load LAMMPS/28Jun14-base"));
        // Register Echo
        String lammpsDeployId = airavataClient.registerApplicationDeployment(new AuthzToken(""), DEFAULT_GATEWAY, RegisterSampleApplicationsUtils.createApplicationDeployment(lammpsModuleId, lsfResourceId, "lmp_ghpcc", ApplicationParallelismType.MPI, echoDescription, moduleLoadCmd, null, null));
        System.out.println("Echo on LSF deployment Id " + echoAppDeployId);
        System.out.println("LAMMPS on LSF deployment Id " + lammpsDeployId);
    } catch (TException e) {
        e.printStackTrace();
    }
}
Also used : CommandObject(org.apache.airavata.model.appcatalog.appdeployment.CommandObject) TException(org.apache.thrift.TException) AuthzToken(org.apache.airavata.model.security.AuthzToken)

Aggregations

CommandObject (org.apache.airavata.model.appcatalog.appdeployment.CommandObject)10 TException (org.apache.thrift.TException)6 AuthzToken (org.apache.airavata.model.security.AuthzToken)5 ApplicationDeploymentDescription (org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentDescription)3 SetEnvPaths (org.apache.airavata.model.appcatalog.appdeployment.SetEnvPaths)3 HashMap (java.util.HashMap)2 ApplicationParallelismType (org.apache.airavata.model.parallelism.ApplicationParallelismType)2 Writable (groovy.lang.Writable)1 GStringTemplateEngine (groovy.text.GStringTemplateEngine)1 TemplateEngine (groovy.text.TemplateEngine)1 java.io (java.io)1 InetAddress (java.net.InetAddress)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 ByteBuffer (java.nio.ByteBuffer)1 SecureRandom (java.security.SecureRandom)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1