Skip to content

Commit

Permalink
Merge branch 'develop' into reproVIP_add_support_public_exec
Browse files Browse the repository at this point in the history
  • Loading branch information
axlbonnet committed Dec 7, 2023
2 parents 6fad8f5 + 9a1d4ea commit 6f382f7
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 62 deletions.
14 changes: 11 additions & 3 deletions vip-portal/src/main/resources/vm/gwendia-dot-inputs.vm
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@
#set($type="URI")
#end
#if($input.getType().getCamelName()=="Flag")
<source name="$input.getId()" type="string" optional="$input.isOptional()" default="$input.getCommandLineFlag()" vip-type-restriction="flag" pretty-name="$input.getName()">
#if($input.getDefaultValue() && $input.getDefaultValue()!="")
<source name="$input.getId()" type="string" optional="$input.isOptional()" default="$input.getDefaultValue()" vip-type-restriction="flag" pretty-name="$input.getName()">
#else
<source name="$input.getId()" type="string" optional="$input.isOptional()" default="false" vip-type-restriction="flag" pretty-name="$input.getName()">
#end
#else
#if($input.getDefaultValue() && $input.getDefaultValue()!="")
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="$input.getDefaultValue()" pretty-name="$input.getName()">
#if($input.getType().getCamelName()=="Number" && $input.isInteger())
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="$input.getDefaultValue().intValue()" pretty-name="$input.getName()">
#else
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="$input.getDefaultValue()" pretty-name="$input.getName()">
#end
#else
#if($input.isOptional()==true)
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="No_value_provided" pretty-name="$input.getName()">
Expand Down Expand Up @@ -73,7 +81,7 @@ if ( result.startsWith("/") || result.startsWith("lfn:") ) {
<port name="results-directory" />
</cross>
</iterationstrategy>
<gasw descriptor="lfn:$tool.getGASWLFN()"/>
<gasw descriptor="$fileAccessProtocol:$tool.getGASWLFN()"/>
</processor>
</processors>
<links>
Expand Down
12 changes: 10 additions & 2 deletions vip-portal/src/main/resources/vm/gwendia-standalone.vm
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@
#set($type="URI")
#end
#if($input.getType().getCamelName()=="Flag")
<source name="$input.getId()" type="string" optional="$input.isOptional()" default="$input.getCommandLineFlag()" vip-type-restriction="flag" pretty-name="$input.getName()">
#if($input.getDefaultValue() && $input.getDefaultValue()!="")
<source name="$input.getId()" type="string" optional="$input.isOptional()" default="$input.getDefaultValue()" vip-type-restriction="flag" pretty-name="$input.getName()">
#else
<source name="$input.getId()" type="string" optional="$input.isOptional()" default="false" vip-type-restriction="flag" pretty-name="$input.getName()">
#end
#else
#if($input.getDefaultValue() && $input.getDefaultValue()!="")
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="$input.getDefaultValue()" pretty-name="$input.getName()">
#if($input.getType().getCamelName()=="Number" && $input.isInteger())
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="$input.getDefaultValue().intValue()" pretty-name="$input.getName()">
#else
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="$input.getDefaultValue()" pretty-name="$input.getName()">
#end
#else
#if($input.isOptional()==true)
<source name="$input.getId()" type="$type" optional="$input.isOptional()" default="No_value_provided" pretty-name="$input.getName()">
Expand Down
13 changes: 12 additions & 1 deletion vip-portal/src/main/resources/vm/wrapper.vm
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,18 @@ fi
# Change PYTHONPATH to make all strings unicode by default in python2 (as in python3)
# Otherwise `bosh exec` fails on any non-ascii characters in outputs
echo "import sys; sys.setdefaultencoding(\"UTF8\")" > sitecustomize.py
PYTHONPATH=".:$PYTHONPATH" $BOSHEXEC exec launch $JSONFILE input_param_file.json -v $PWD/../cache:$PWD/../cache
#creating a temporary directory for bindmount /tmp of containers
mkdir -p tmp
#TMP_FOLDER is created differently for execution on GRID and execution on LOCAL
#TMP of the container is bind mounted on TMP_FOLDER to avoid creating temporary files on container.
TMP_FOLDER=tmp_$(basename $PWD)
#if($isRunOnGrid == false)
TMP_FOLDER=/tmp/$TMP_FOLDER
#else
TMP_FOLDER=../$TMP_FOLDER
#end

PYTHONPATH=".:$PYTHONPATH" $BOSHEXEC exec launch $JSONFILE input_param_file.json -v $PWD/../cache:$PWD/../cache -v $TMP_FOLDER:/tmp

if [ $? != 0 ]
then
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package fr.insalyon.creatis.applicationimporter;

import fr.insalyon.creatis.vip.application.client.ApplicationConstants;
import fr.insalyon.creatis.vip.application.client.bean.Descriptor;
import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesApplication;
import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesInput;
import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesNumberInput;
import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesStringInput;
import fr.insalyon.creatis.vip.application.client.view.boutiquesParsing.InvalidBoutiquesDescriptorException;
import fr.insalyon.creatis.vip.application.server.business.simulation.parser.GwendiaParser;
import fr.insalyon.creatis.vip.applicationimporter.server.business.VelocityUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.xml.sax.SAXException;

import java.io.IOException;

/*
This needs te be here to use the production velocity templates
*/
public class GwendiaTemplateTest {

final protected String DOT_TEMPLATE = "vm/gwendia-dot-inputs.vm";
final protected String STANDALONE_TEMPLATE = "vm/gwendia-standalone.vm";

@ParameterizedTest
@ValueSource(strings = {DOT_TEMPLATE, STANDALONE_TEMPLATE})
public void testTemplateWithNonNullDescription(String template) throws IOException, InvalidBoutiquesDescriptorException, SAXException {
String inputDescription = "test input description";
Descriptor gwendiaDesc = testGwendiaTemplate(
template,
getBasicFileInput(1, inputDescription, null));
Assertions.assertEquals(ApplicationConstants.INPUT_WITHOUT_VALUE, gwendiaDesc.getSources().get(1).getDefaultValue());
Assertions.assertEquals(inputDescription, gwendiaDesc.getSources().get(1).getDescription());
}

@ParameterizedTest
@ValueSource(strings = {DOT_TEMPLATE, STANDALONE_TEMPLATE})
public void testTemplateWithNullDescription(String template) throws IOException, InvalidBoutiquesDescriptorException, SAXException {
// when the description is not in boutiques, it must be an empty string in gwendia
Descriptor gwendiaDesc = testGwendiaTemplate(
template,
getBasicFileInput(1, null, null));
Assertions.assertEquals(ApplicationConstants.INPUT_WITHOUT_VALUE, gwendiaDesc.getSources().get(1).getDefaultValue());
Assertions.assertEquals("", gwendiaDesc.getSources().get(1).getDescription());
}

@ParameterizedTest
@ValueSource(strings = {DOT_TEMPLATE, STANDALONE_TEMPLATE})
public void testTemplateWithAIntegerInput(String template) throws IOException, InvalidBoutiquesDescriptorException, SAXException {
Descriptor gwendiaDesc = testGwendiaTemplate(
template,
getIntegerInput(1, 42.));
Assertions.assertEquals("42", gwendiaDesc.getSources().get(1).getDefaultValue());
}

@ParameterizedTest
@ValueSource(strings = {DOT_TEMPLATE, STANDALONE_TEMPLATE})
public void testTemplateWithANumberInput(String template) throws IOException, InvalidBoutiquesDescriptorException, SAXException {
Descriptor gwendiaDesc = testGwendiaTemplate(
template,
getNumberInput(1, false, 42.));
Assertions.assertEquals("42.0", gwendiaDesc.getSources().get(1).getDefaultValue());
}

protected BoutiquesInput getIntegerInput(Object id, Double defaultValue) {
return getNumberInput(1, true, 42.);
}

protected BoutiquesInput getNumberInput(Object id, boolean isInteger, Double defaultValue) {
return new BoutiquesNumberInput("testNumberInput" + id, "test number input " + id, "test number description",
true, null, null, null, null, null, defaultValue, isInteger, false, false, null, null);
}

protected BoutiquesInput getBasicFileInput(Object id, String description, String defaultValue) {
return new BoutiquesStringInput(
"testFileInput" + id, "test file input " +id, description, BoutiquesInput.InputType.FILE,
true, null, null, null, null, null, defaultValue);
}

protected Descriptor testGwendiaTemplate(String templateFile, BoutiquesInput... inputs) throws IOException, SAXException {
BoutiquesApplication boutiquesApp = new BoutiquesApplication("testApp", "test app desc", "42.43");
for (BoutiquesInput input : inputs) {
boutiquesApp.addInput(input);
}
VelocityUtils sut = new VelocityUtils();
String gwendiaString = sut.createDocument(boutiquesApp, "lnf:", templateFile);
return new GwendiaParser().parseString(gwendiaString);
}

}

0 comments on commit 6f382f7

Please sign in to comment.