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