Skip to content

Commit

Permalink
Merge pull request #491 from axlbonnet/improvements
Browse files Browse the repository at this point in the history
small improvement
  • Loading branch information
axlbonnet authored Oct 2, 2024
2 parents c038308 + a97aecd commit 2030acb
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static ApplicationImporterServiceAsync getInstance() {

String readAndValidateBoutiquesFile(String fileLFN) throws ApplicationImporterException;

void createApplication(BoutiquesApplication bt, String type, String tag, boolean isRunOnGrid, boolean overwriteVersion, String fileAccessProtocol) throws ApplicationImporterException;
void createApplication(BoutiquesApplication bt, String tag, boolean isRunOnGrid, boolean overwriteVersion, String fileAccessProtocol) throws ApplicationImporterException;

String getApplicationImporterRootFolder() throws ApplicationImporterException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface ApplicationImporterServiceAsync {

public void readAndValidateBoutiquesFile(String fileLFN, AsyncCallback<String> callback);

public void createApplication(BoutiquesApplication bt, String type, String tag, boolean isRunOnGrid, boolean overwriteVersion, String fileAccessProtocol, AsyncCallback<Void> callback);
public void createApplication(BoutiquesApplication bt, String tag, boolean isRunOnGrid, boolean overwriteVersion, String fileAccessProtocol, AsyncCallback<Void> callback);

public void getApplicationImporterRootFolder(AsyncCallback<String> asyncCallback);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ public class Constants {
public static final String APP_IMG_IMPORTER = IMG_FOLDER + "importer.png";
//Group
public static final String APPLICATION_IMPORTER_GROUP = "Application Importer";
//vm files
public static final String VM_GASW = "gasw.vm";
//LFN access to SegPerfAnalyzer
public static final String LNF_PATH = "";
// Application Importer types
public static final String APP_IMPORTER_STANDALONE_TYPE = "app-importer-standalone-type";
public static final String APP_IMPORTER_DOT_INPUTS_TYPE = "app-importer-dot-inputs-type";
//Execution type
public static final String APP_IMPORTER_FILE_PROTOCOL = "file";
public static final String APP_IMPORTER_LFN_PROTOCOL = "lfn";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ private void configure() {
createApplicationButton = WidgetUtil.getIButton("Create application", Constants.ICON_LAUNCH, new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if (vipLayout.getApplicationType() == null){
Layout.getInstance().setWarningMessage("Select type of Application is empty, please choose one.");
if (vipLayout.getFileAccessProtocol() == null){
Layout.getInstance().setWarningMessage("Select file access protocol.");
} else {
boutiquesTool.setApplicationLFN(vipLayout.getApplicationLocation() + "/" + boutiquesTool.getName());
createApplication();
Expand Down Expand Up @@ -215,7 +215,6 @@ public void onSuccess(Void result) {
modal.show("Creating application...", true);
ApplicationImporterService.Util.getInstance().createApplication(
boutiquesTool,
vipLayout.getApplicationType(),
vipLayout.getTag(),
vipLayout.getIsRunOnGrid(),
vipLayout.getOverwrite(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public class VIPLayout extends AbstractFormLayout {
private final LocalTextField applicationLocation;
private final CheckboxItem isRunOnGrid; // And not locally.
private final CheckboxItem overwriteIfexists;
private final SelectItem appCbItem;
private final SelectItem tagsCbItem;
private final SelectItem fileAccessProtocolItem;

Expand All @@ -72,15 +71,6 @@ public VIPLayout(String width, String height) {
isRunOnGrid = new CheckboxItem("ckbox_isRunOnGrid", "Application must run on grid, and not locally");
isRunOnGrid.setAlign(Alignment.LEFT);

//ComboBox to select type of application
appCbItem = new SelectItem();
appCbItem.setTitle("<b>Select type of application</b>");
appCbItem.setType("comboBox");
LinkedHashMap<String, String> valueMap = new LinkedHashMap<>();
valueMap.put(Constants.APP_IMPORTER_STANDALONE_TYPE, "standalone");
valueMap.put(Constants.APP_IMPORTER_DOT_INPUTS_TYPE, "Dot inputs (Challenge)");
appCbItem.setValueMap(valueMap);

tagsCbItem = createTagsSelect();

//select list to choose the execution type
Expand All @@ -92,7 +82,6 @@ public VIPLayout(String width, String height) {
fileAccessProtocolValueMap.put(Constants.APP_IMPORTER_LFN_PROTOCOL, "Grid (lfn)");
fileAccessProtocolItem.setValueMap(fileAccessProtocolValueMap);

this.addMember(FieldUtil.getForm(appCbItem));
this.addMember(FieldUtil.getForm(isRunOnGrid));
this.addMember(FieldUtil.getForm(overwriteIfexists));
this.addMember(FieldUtil.getForm(tagsCbItem));
Expand Down Expand Up @@ -141,19 +130,6 @@ public boolean getIsRunOnGrid() {
return this.isRunOnGrid.getValueAsBoolean();
}

/**
* Get the type of application (standalone or challenge)
*
* @return the type
*/
public String getApplicationType() {
if (appCbItem._getValue() == null){
return null;
} else {
return appCbItem._getValue().toString();
}
}

private SelectItem createTagsSelect() {
// ComboBox to select tags.
SelectItem tagsCb = new SelectItem();
Expand Down Expand Up @@ -192,6 +168,7 @@ public void onSuccess(List<String> result) {
public String getTag() {
return tagsCbItem._getValue().toString();
}

public String getFileAccessProtocol(){
return fileAccessProtocolItem._getValue().toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,13 @@ public String readAndValidationBoutiquesFile(String fileLFN, User user)
}

public void createApplication(
BoutiquesApplication bt, String type, String tag, boolean isRunOnGrid, boolean overwriteApplicationVersion, String fileAccessProtocol, User user)
BoutiquesApplication bt, String tag, boolean isRunOnGrid, boolean overwriteApplicationVersion, String fileAccessProtocol, User user)
throws BusinessException {

try {
String wrapperTemplate = "vm/wrapper.vm";
String gaswTemplate = "vm/gasw.vm";

String gwendiaTemplate = "vm/gwendia-standalone.vm";
if (Constants.APP_IMPORTER_DOT_INPUTS_TYPE.equals(type)) {
gwendiaTemplate = "vm/gwendia-dot-inputs.vm";
} else if ( ! Constants.APP_IMPORTER_STANDALONE_TYPE.equals(type)) {
logger.error("Cannot import pipeline : unknown importer type : {}", type);
throw new BusinessException("Cannot import pipeline : unknown importer type");
}

// Check rights
checkEditionRights(bt.getName(), bt.getToolVersion(), overwriteApplicationVersion, user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public String readAndValidateBoutiquesFile(String fileLFN) throws ApplicationImp

@Override
public void createApplication(
BoutiquesApplication bt, String type, String tag, boolean isRunOnGrid, boolean overwriteVersion, String fileAccessProtocol)
BoutiquesApplication bt, String tag, boolean isRunOnGrid, boolean overwriteVersion, String fileAccessProtocol)
throws ApplicationImporterException {
try {
trace(logger, "Creating application");
applicationImporterBusiness.createApplication(
bt, type, tag, isRunOnGrid, overwriteVersion, fileAccessProtocol, getSessionUser());
bt, tag, isRunOnGrid, overwriteVersion, fileAccessProtocol, getSessionUser());
} catch (CoreException | BusinessException ex) {
throw new ApplicationImporterException(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import fr.insalyon.creatis.vip.application.server.dao.ApplicationInputDAO;
import fr.insalyon.creatis.vip.core.client.bean.Group;
import fr.insalyon.creatis.vip.core.client.bean.User;
import fr.insalyon.creatis.vip.core.client.view.CoreConstants;
import fr.insalyon.creatis.vip.core.client.view.CoreException;
import fr.insalyon.creatis.vip.core.server.business.BusinessException;
import fr.insalyon.creatis.vip.core.server.business.ConfigurationBusiness;
Expand All @@ -60,6 +61,8 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -192,8 +195,9 @@ public void launchSimulation(Map<String, String> parametersMap,
}

for (Map.Entry<String,String> p : parametersMap.entrySet()) {
logger.info("received param {} : {}", p.getKey(), p.getValue());
logger.info("received param {} : {}", p.getKey(), p.getValue());
}
addTimestampedSubDirectoryIfNecessary(parametersMap);

String simulationID = workflowBusiness.launch(
user, groups,
Expand All @@ -207,6 +211,24 @@ public void launchSimulation(Map<String, String> parametersMap,
}
}

private void addTimestampedSubDirectoryIfNecessary(Map<String, String> parametersMap) {
if (server.useMoteurlite()) {
if (parametersMap.containsKey(CoreConstants.RESULTS_DIRECTORY_PARAM_NAME)) {
String resultDir = parametersMap.get(CoreConstants.RESULTS_DIRECTORY_PARAM_NAME);
if (resultDir.startsWith("/") || resultDir.startsWith("lfn:")) {
DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy_HH:mm:ss");
resultDir = resultDir + "/" + (dateFormat.format(System.currentTimeMillis()));
parametersMap.put(CoreConstants.RESULTS_DIRECTORY_PARAM_NAME, resultDir);
logger.info("For MoteurLite : changing results-directory to : {}", resultDir);
} else {
logger.info("Using MoteurLite but results-directory not a LFN ({})", resultDir);
}
} else {
logger.info("Using MoteurLite but no results-directory given -> no subdirectory added");
}
}
}

/**
*
* @param name
Expand Down
97 changes: 0 additions & 97 deletions vip-portal/src/main/resources/vm/gwendia-dot-inputs.vm

This file was deleted.

3 changes: 0 additions & 3 deletions vip-portal/src/main/resources/vm/wrapper.vm
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ then
fi
#end

# 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
#creating a temporary directory for bindmount /tmp of containers
#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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
*/
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})
@ValueSource(strings = {STANDALONE_TEMPLATE})
public void testTemplateWithNonNullDescription(String template) throws IOException, InvalidBoutiquesDescriptorException, SAXException {
String inputDescription = "test input description";
Descriptor gwendiaDesc = testGwendiaTemplate(
Expand All @@ -37,7 +36,7 @@ public void testTemplateWithNonNullDescription(String template) throws IOExcepti
}

@ParameterizedTest
@ValueSource(strings = {DOT_TEMPLATE, STANDALONE_TEMPLATE})
@ValueSource(strings = {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(
Expand All @@ -48,7 +47,7 @@ public void testTemplateWithNullDescription(String template) throws IOException,
}

@ParameterizedTest
@ValueSource(strings = {DOT_TEMPLATE, STANDALONE_TEMPLATE})
@ValueSource(strings = {STANDALONE_TEMPLATE})
public void testTemplateWithAIntegerInput(String template) throws IOException, InvalidBoutiquesDescriptorException, SAXException {
Descriptor gwendiaDesc = testGwendiaTemplate(
template,
Expand All @@ -57,7 +56,7 @@ public void testTemplateWithAIntegerInput(String template) throws IOException, I
}

@ParameterizedTest
@ValueSource(strings = {DOT_TEMPLATE, STANDALONE_TEMPLATE})
@ValueSource(strings = {STANDALONE_TEMPLATE})
public void testTemplateWithANumberInput(String template) throws IOException, InvalidBoutiquesDescriptorException, SAXException {
Descriptor gwendiaDesc = testGwendiaTemplate(
template,
Expand Down

0 comments on commit 2030acb

Please sign in to comment.