Search in sources :

Example 6 with PipeConfValueVO

use of com.epam.pipeline.entity.configuration.PipeConfValueVO in project cloud-pipeline by epam.

the class PipelineRunManager method setRunParentId.

private void setRunParentId(PipelineRun run, Map<String, PipeConfValueVO> parameters) {
    if (run.getParentRunId() != null) {
        return;
    }
    if (MapUtils.isEmpty(parameters)) {
        return;
    }
    PipeConfValueVO parentValue = parameters.get(PipelineRun.PARENT_ID_PARAM);
    if (parentValue == null || !NumberUtils.isDigits(parentValue.getValue())) {
        return;
    }
    run.setParentRunId(Long.parseLong(parentValue.getValue()));
}
Also used : PipeConfValueVO(com.epam.pipeline.entity.configuration.PipeConfValueVO)

Example 7 with PipeConfValueVO

use of com.epam.pipeline.entity.configuration.PipeConfValueVO in project cloud-pipeline by epam.

the class PipelineConfigurationManager method mergeParameters.

public PipelineConfiguration mergeParameters(PipelineStart runVO, PipelineConfiguration defaultConfig) {
    Map<String, PipeConfValueVO> params = runVO.getParams() == null ? Collections.emptyMap() : runVO.getParams();
    PipelineConfiguration configuration = new PipelineConfiguration();
    configuration.setMainFile(defaultConfig.getMainFile());
    configuration.setMainClass(defaultConfig.getMainClass());
    configuration.setEnvironmentParams(defaultConfig.getEnvironmentParams());
    configuration.setPrettyUrl(runVO.getPrettyUrl());
    Map<String, PipeConfValueVO> runParameters = new LinkedHashMap<>();
    // filter and get parameters from user
    params.entrySet().stream().filter(entry -> entry.getValue().isRequired() || !StringUtils.isEmpty(entry.getValue().getValue())).forEach(entry -> runParameters.put(entry.getKey(), entry.getValue()));
    // fill in default values, only if user's value wasn't provided
    if (defaultConfig.getParameters() != null) {
        defaultConfig.getParameters().entrySet().stream().filter(entry -> entry.getValue().isRequired() || !StringUtils.isEmpty(entry.getValue().getValue())).forEach(entry -> runParameters.putIfAbsent(entry.getKey(), entry.getValue()));
    }
    // set parameters to the final configuration
    configuration.setParameters(runParameters);
    // fill instance settings
    if (runVO.getHddSize() != null) {
        configuration.setInstanceDisk(String.valueOf(runVO.getHddSize()));
    } else {
        configuration.setInstanceDisk(defaultConfig.getInstanceDisk());
    }
    if (runVO.getInstanceType() != null) {
        configuration.setInstanceType(String.valueOf(runVO.getInstanceType()));
    } else {
        configuration.setInstanceType(defaultConfig.getInstanceType());
    }
    if (runVO.getTimeout() != null) {
        configuration.setTimeout(runVO.getTimeout());
    } else {
        configuration.setTimeout(defaultConfig.getTimeout());
    }
    // client always sends actual node-count
    configuration.setNodeCount(runVO.getNodeCount());
    configuration.setCmdTemplate(runVO.getCmdTemplate() == null ? defaultConfig.getCmdTemplate() : runVO.getCmdTemplate());
    Boolean isSpot = runVO.getIsSpot() == null ? defaultConfig.getIsSpot() : runVO.getIsSpot();
    configuration.setIsSpot(isSpot);
    if (isSpot != null && !isSpot) {
        configuration.setNonPause(runVO.isNonPause());
    }
    configuration.setWorkerCmd(runVO.getWorkerCmd() == null ? defaultConfig.getWorkerCmd() : runVO.getWorkerCmd());
    configuration.setDockerImage(chooseDockerImage(runVO, defaultConfig));
    configuration.buildEnvVariables();
    return configuration;
}
Also used : PermissionsService(com.epam.pipeline.manager.security.PermissionsService) MessageConstants(com.epam.pipeline.common.MessageConstants) GitClientException(com.epam.pipeline.exception.git.GitClientException) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) PipeConfValueVO(com.epam.pipeline.entity.configuration.PipeConfValueVO) Function(java.util.function.Function) CollectionUtils(org.apache.commons.collections4.CollectionUtils) LinkedHashMap(java.util.LinkedHashMap) PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) DataStorageApiService(com.epam.pipeline.manager.datastorage.DataStorageApiService) MessageHelper(com.epam.pipeline.common.MessageHelper) Service(org.springframework.stereotype.Service) AclPermission(com.epam.pipeline.security.acl.AclPermission) Map(java.util.Map) ConfigurationEntry(com.epam.pipeline.entity.configuration.ConfigurationEntry) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) ToolVersion(com.epam.pipeline.entity.docker.ToolVersion) MapUtils(org.apache.commons.collections4.MapUtils) GitManager(com.epam.pipeline.manager.git.GitManager) RunInstance(com.epam.pipeline.entity.pipeline.RunInstance) AbstractDataStorage(com.epam.pipeline.entity.datastorage.AbstractDataStorage) Collectors(java.util.stream.Collectors) NFSDataStorage(com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage) Tool(com.epam.pipeline.entity.pipeline.Tool) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Optional(java.util.Optional) PipelineStart(com.epam.pipeline.entity.pipeline.run.PipelineStart) ToolVersionManager(com.epam.pipeline.manager.docker.ToolVersionManager) Collections(java.util.Collections) AwsRegionManager(com.epam.pipeline.manager.region.AwsRegionManager) StringUtils(org.springframework.util.StringUtils) PipeConfValueVO(com.epam.pipeline.entity.configuration.PipeConfValueVO) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Example 8 with PipeConfValueVO

use of com.epam.pipeline.entity.configuration.PipeConfValueVO in project cloud-pipeline by epam.

the class CommandBuilderTest method constructConfiguration.

private PipelineConfiguration constructConfiguration() {
    PipelineConfiguration configuration = new PipelineConfiguration();
    configuration.setCmdTemplate(template);
    configuration.setMainFile(MAIN_FILE);
    configuration.setMainClass(MAIN_CLASS);
    configuration.setEnvironmentParams(new LinkedHashMap<String, String>() {

        {
            put("main_class", MAIN_CLASS);
            put("main_file", MAIN_FILE);
            put("cmd_template", template);
        }
    });
    configuration.setParameters(new LinkedHashMap<String, PipeConfValueVO>() {

        {
            put("sample", new PipeConfValueVO(SAMPLE));
            put("input-fastq", new PipeConfValueVO(INPUT_FASTQ));
        }
    });
    return configuration;
}
Also used : PipeConfValueVO(com.epam.pipeline.entity.configuration.PipeConfValueVO) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration)

Example 9 with PipeConfValueVO

use of com.epam.pipeline.entity.configuration.PipeConfValueVO in project cloud-pipeline by epam.

the class EnvVarsBuilderTest method matchPipeConfig.

public static PipelineConfiguration matchPipeConfig() {
    PipelineConfiguration configuration = new PipelineConfiguration();
    configuration.setCmdTemplate(CMD_TEMPLATE);
    configuration.setMainClass(MAIN_CLASS_VALUE);
    configuration.setMainFile(MAIN_FILE_VALUE);
    configuration.buildEnvVariables();
    configuration.setParameters(new HashMap<String, PipeConfValueVO>() {

        {
            put(P1, new PipeConfValueVO(P1_VALUE, NUMBER_TYPE));
            put(P2, new PipeConfValueVO(P2_VALUE, STRING_TYPE));
        }
    });
    return configuration;
}
Also used : PipeConfValueVO(com.epam.pipeline.entity.configuration.PipeConfValueVO) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration)

Example 10 with PipeConfValueVO

use of com.epam.pipeline.entity.configuration.PipeConfValueVO in project cloud-pipeline by epam.

the class ParameterMapperTest method mapParameters.

@Test
public void mapParameters() throws Exception {
    Map<String, PipeConfValueVO> parametersToResolve = new HashMap<>();
    parametersToResolve.put(PATIENT_PIPE_PARAM, new PipeConfValueVO("this.Patient.Patient_ID"));
    parametersToResolve.put(SAMPLE_PIPE_PARAM, new PipeConfValueVO("this.Sample_Name"));
    parametersToResolve.put(REFERENCE_PIPE_PARAM, new PipeConfValueVO(SCALAR_VALUE));
    parametersToResolve.put(BATCHES_PIPE_PARAM, new PipeConfValueVO("this.Patient.Batch.Batch_Name"));
    Map<ParameterMapper.MetadataKey, MetadataEntity> references = new HashMap<>();
    MetadataEntity sample = new MetadataEntity();
    sample.setExternalId(SAMPLE_ID);
    Map<String, PipeConfValue> sampleData = new HashMap<>();
    sampleData.put("Patient", new PipeConfValue("Participant:ID", PATIENT_ID));
    sampleData.put("Sample_Name", new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, SAMPLE_NAME));
    sample.setData(sampleData);
    references.put(new ParameterMapper.MetadataKey("Sample", SAMPLE_ID), sample);
    MetadataEntity patient = new MetadataEntity();
    patient.setExternalId(PATIENT_ID);
    Map<String, PipeConfValue> patientData = new HashMap<>();
    patientData.put("Patient_ID", new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, PATIENT_UID));
    patientData.put("Batch", new PipeConfValue("Array[Batch]", "[\"b1\", \"b2\"]"));
    patient.setData(patientData);
    references.put(new ParameterMapper.MetadataKey("Participant", PATIENT_ID), patient);
    MetadataEntity batch1 = new MetadataEntity();
    batch1.setExternalId(BATCH1_ID);
    Map<String, PipeConfValue> batch1Data = new HashMap<>();
    batch1Data.put(BATCH_NAME_PARAMETER, new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, BATCH1_NAME));
    batch1.setData(batch1Data);
    references.put(new ParameterMapper.MetadataKey(BATCH_CLASS, BATCH1_ID), batch1);
    MetadataEntity batch2 = new MetadataEntity();
    batch2.setExternalId(BATCH2_ID);
    Map<String, PipeConfValue> batch2Data = new HashMap<>();
    batch2Data.put(BATCH_NAME_PARAMETER, new PipeConfValue(PipeConfValueVO.DEFAULT_TYPE, BATCH2_NAME));
    batch2.setData(batch2Data);
    references.put(new ParameterMapper.MetadataKey(BATCH_CLASS, BATCH2_ID), batch2);
    Map<String, PipeConfValueVO> result = parameterMapper.mapParameters(sample, null, parametersToResolve, references);
    assertEquals(SAMPLE_NAME, result.get(SAMPLE_PIPE_PARAM).getValue());
    assertEquals(PATIENT_UID, result.get(PATIENT_PIPE_PARAM).getValue());
    assertEquals(SCALAR_VALUE, result.get(REFERENCE_PIPE_PARAM).getValue());
    assertEquals(BATCH1_NAME + "," + BATCH2_NAME, result.get(BATCHES_PIPE_PARAM).getValue());
}
Also used : MetadataEntity(com.epam.pipeline.entity.metadata.MetadataEntity) PipeConfValueVO(com.epam.pipeline.entity.configuration.PipeConfValueVO) HashMap(java.util.HashMap) PipeConfValue(com.epam.pipeline.entity.metadata.PipeConfValue) AbstractManagerTest(com.epam.pipeline.manager.AbstractManagerTest) Test(org.junit.Test)

Aggregations

PipeConfValueVO (com.epam.pipeline.entity.configuration.PipeConfValueVO)11 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 ConfigurationEntry (com.epam.pipeline.entity.configuration.ConfigurationEntry)2 ToolVersion (com.epam.pipeline.entity.docker.ToolVersion)2 PipelineStart (com.epam.pipeline.entity.pipeline.run.PipelineStart)2 AbstractSpringTest (com.epam.pipeline.AbstractSpringTest)1 MessageConstants (com.epam.pipeline.common.MessageConstants)1 MessageHelper (com.epam.pipeline.common.MessageHelper)1 AbstractDataStorage (com.epam.pipeline.entity.datastorage.AbstractDataStorage)1 NFSDataStorage (com.epam.pipeline.entity.datastorage.nfs.NFSDataStorage)1 MetadataEntity (com.epam.pipeline.entity.metadata.MetadataEntity)1 PipeConfValue (com.epam.pipeline.entity.metadata.PipeConfValue)1 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)1 RunInstance (com.epam.pipeline.entity.pipeline.RunInstance)1 Tool (com.epam.pipeline.entity.pipeline.Tool)1 GitClientException (com.epam.pipeline.exception.git.GitClientException)1 AbstractManagerTest (com.epam.pipeline.manager.AbstractManagerTest)1 DataStorageApiService (com.epam.pipeline.manager.datastorage.DataStorageApiService)1