Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration #18

Merged
merged 5 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ml2wf/config/configuration.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# this is the configuration file for the ml2wf app

# constraints syntax (name : arity : symbol)
# ------- NOTE: only change the last column -------

before : 2 : >>
after : 2 : <<

imp : 2 : =>
equ : 2 : <=>

conj : 2 : &
disj : 2 : |

not : 1 : !

# others
# not implemented yet
72 changes: 57 additions & 15 deletions ml2wf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,69 @@
<version.jar.plugin>3.2.0</version.jar.plugin>
<version.assembly.plugin>3.3.0</version.assembly.plugin>
<version.surefire>3.0.0-M1</version.surefire>
<version.shade.plugin>3.2.3</version.shade.plugin>
<version.picocli>4.3.2</version.picocli>
<version.log4j>2.13.3</version.log4j>
<dependency.directory>dependency/</dependency.directory>
</properties>
<build>
<pluginManagement>
<plugins>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire}</version>
</plugin>
</plugins>
</pluginManagement>
<finalName>ml2wf</finalName>
<plugins>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire}</version>
</plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-shade-plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${version.shade.plugin}</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.ml2wf.App</mainClass>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<!-- for configuration file -->
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/*.cfg</include>
</includes>
</resource>
<!-- for BPMN files -->
<resource>
<directory>${basedir}/src/test/resources</directory>
<includes>
<include>**/*.bpmn2</include>
</includes>
</resource>
<!-- for FM files -->
<resource>
<directory>${basedir}/src/test/resources</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
<dependencies>
Expand All @@ -59,10 +101,10 @@
<version>${version.picocli}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${version.log4j}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${version.log4j}</version>
</dependency>
</dependencies>
</project>
11 changes: 8 additions & 3 deletions ml2wf/src/main/java/com/ml2wf/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Model;
import picocli.CommandLine.Option;
import picocli.CommandLine.Spec;

@Command(name = "ml2wf", version = "1.0", sortOptions = false, usageHelpWidth = 60, header = "\n ---- Machine Learning problem to Workflow ---- \n\n", footer = "\n\n ---- Provided by AUTHOR ---- \n", description = "")
public class App implements Runnable {
public class App {// implements Runnable {

@Spec
Model.CommandSpec spec;

@Option(names = { "-v",
"--version" }, versionHelp = true, arity = "0", order = 1, description = "Displays version info")
boolean version;

public static void main(String[] args) {
CommandLine commandLine = new CommandLine(new App())
.addSubcommand("-g", new Generate())
Expand All @@ -24,8 +29,8 @@ public static void main(String[] args) {
}
}

@Override
/*-@Override
public void run() {
CommandLine.usage(this.spec, System.out); // TODO: replace System.out by logger
}
}*/
}
4 changes: 2 additions & 2 deletions ml2wf/src/main/java/com/ml2wf/cmd/Generate.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public class Generate implements Runnable {
@Spec
Model.CommandSpec spec;

@Option(names = { "-i", "--input" }, arity = "1", order = 1, description = "input file")
@Option(names = { "-i", "--input" }, required = true, arity = "1", order = 1, description = "input file")
String input;

@Option(names = { "-o", "--output" }, arity = "1", order = 1, description = "output directory")
@Option(names = { "-o", "--output" }, required = true, arity = "1", order = 1, description = "output directory")
String output;

@Option(names = { "-v", "--verbose" }, arity = "0", order = 1, description = "verbose mode")
Expand Down
4 changes: 2 additions & 2 deletions ml2wf/src/main/java/com/ml2wf/cmd/Merge.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public class Merge implements Runnable {
@Spec
Model.CommandSpec spec;

@Option(names = { "-i", "--input" }, arity = "1", order = 1, description = "input file")
@Option(names = { "-i", "--input" }, required = true, arity = "1", order = 1, description = "input file")
String input;

@Option(names = { "-o", "--output" }, arity = "1", order = 1, description = "output file")
@Option(names = { "-o", "--output" }, required = true, arity = "1", order = 1, description = "output file")
String output;

@Option(names = { "-v", "--verbose" }, arity = "0", order = 1, description = "verbose mode")
Expand Down
70 changes: 13 additions & 57 deletions ml2wf/src/main/java/com/ml2wf/constraints/config/Config.java
Original file line number Diff line number Diff line change
@@ -1,65 +1,21 @@
package com.ml2wf.constraints.config;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.ml2wf.conventions.enums.fm.FeatureModelNames;

/**
* TODO
*
* This interface provides a method for loading a configuration from a
* configuration file.
*
* @author Nicolas Lacroix
*
* @version 1.0
*
*/
public class Config {

private String filePath;
private static final Map<String, FeatureModelNames> vocMapping; // TODO: replace by a Config instance
static {
Map<String, FeatureModelNames> aMap = new HashMap<>();
aMap.put(">>", null); // before : TODO
aMap.put("<<", null); // after : TODO
aMap.put("=>", FeatureModelNames.IMPLIES); // implies
aMap.put("!", FeatureModelNames.NOT); // not
aMap.put("<=>", FeatureModelNames.EQUIVALENT); // equivalent
aMap.put("&", FeatureModelNames.CONJ); // and
aMap.put("|", FeatureModelNames.DISJ); // or
vocMapping = Collections.unmodifiableMap(aMap);
}

public Config(String filePath) {

}

public static Map<String, FeatureModelNames> getVocmapping() {
return vocMapping;
}

public List<String> getOperatorsList() {
return vocMapping.keySet().stream().collect(Collectors.toList());
}

public List<String> getBinaryOperators() {
List<String> binary = this.getOperatorsList();
binary.removeAll(this.getUnaryOperators());
return binary;
}

public List<String> getUnaryOperators() {
return new ArrayList<>(Arrays.asList("!")); // TODO: replace with config file
}

public boolean isUnaryOperator(String operator) {
return this.getUnaryOperators().contains(operator); // TODO: change considering the config file
}

public boolean isAnOperator(String character) {
return this.getOperatorsList().contains(character);
}
public interface Config {

/**
* Reads the configuration file at the {@code filePath} location and initializes
* the {@code vocMapping Map} using the {@link #processEntry(String[])} method.
*
* @since 1.0
*/
public void readConfig();
}
Loading