Fixed an issue where weight learning was accidentally enabled in the new config.
@@ -132,19 +132,15 @@ public class RuntimeConfig {
* All relative paths will be resolved to absolute paths using |relativeBasePath|.
*/
public void validate() {
- boolean runLearn = RuntimeOptions.LEARN.getBoolean();
- boolean runInfer = RuntimeOptions.INFERENCE.getBoolean();
+ boolean runLearn = false;
+ boolean runInfer = false;
// Any top-level learn/infer indicates that those respective steps should be run.
- if (learn == null) {
- learn = new SplitConfigInfo();
- } else {
+ if (!learn.isEmpty()) {
runLearn = true;
}
- if (infer == null) {
- infer = new SplitConfigInfo();
- } else {
+ if (!infer.isEmpty()) {
runInfer = true;
}
@@ -175,6 +171,15 @@ public class RuntimeConfig {
runInfer = true;
}
+ // Any explicitly set value will always override.
+ if (RuntimeOptions.LEARN.isSet()) {
+ runLearn = RuntimeOptions.LEARN.getBoolean();
+ }
+
+ if (RuntimeOptions.INFERENCE.isSet()) {
+ runInfer = RuntimeOptions.INFERENCE.getBoolean();
+ }
+
options.put(RuntimeOptions.LEARN.name(), "" + runLearn);
options.put(RuntimeOptions.INFERENCE.name(), "" + runInfer);
}
@@ -453,6 +458,8 @@ public class RuntimeConfig {
public Iterable<Rule> getRules();
public void resolvePaths(String relativeBasePath);
+
+ public int size();
}
public static class RulePath implements RuleSource {
@@ -462,6 +469,11 @@ public class RuntimeConfig {
this.path = path;
}
+ @Override
+ public int size() {
+ return (path == null) ? 0 : 1;
+ }
+
@Override
public Iterable<Rule> getRules() {
Model model = null;
@@ -508,6 +520,11 @@ public class RuntimeConfig {
}
}
+ @Override
+ public int size() {
+ return (rules == null) ? 0 : rules.size();
+ }
+
@Override
public Iterable<Rule> getRules() {
List<Rule> parsedRules = new ArrayList<Rule>(rules.size());
@@ -546,6 +563,10 @@ public class RuntimeConfig {
options = new HashMap<String, String>();
}
+ public boolean isEmpty() {
+ return rules.size() == 0 && options.size() == 0;
+ }
+
@Override
public boolean equals(Object other) {
if (other == null || !(other instanceof SplitConfigInfo)) {
