@@ -5,6 +5,7 @@ |
*/ |
package oms.utils; |
|
+import csip.Config; |
import csip.api.server.Executable; |
import csip.api.server.PayloadParameter; |
import csip.api.server.ServiceException; |
@@ -47,6 +48,11 @@ |
|
public static final String FILE_PARAMETER_REGEX_PATTERN = "\\A([^/]+)/([^/]+)/([^/]+)(?:/([^/;]+(?:;[^/;]+)*))?\\Z"; |
|
+ public static final String LOCATION_MNT_DATA |
+ = Config.getString("oms.data.path", "/mnt/csip-oms"); |
+ |
+ public static final String PROJECT = "project"; |
+ |
/** |
* |
*/ |
@@ -93,7 +99,7 @@ |
double avg = 0.0; |
for (int i = 0; i < sim.length; i++) { |
if (sim[i] >= 0.0 && obs[i] >= 0.0) { |
- // summing up |
+ // summing up |
avg += Math.log1p(obs[i]); |
valid++; |
} |
@@ -103,7 +109,7 @@ |
return Double.NEGATIVE_INFINITY; |
} |
|
- // calculating mean |
+ // calculating mean |
avg /= valid; |
|
// calculating mean pow deviations |
@@ -501,7 +507,66 @@ |
dsl, // the dsl file to run |
jvmOptions, // jvm options |
ws, // workspace dir |
- Arrays.asList(res.getFile(ID_AGES_JAR)), // the ages jar file |
+ Arrays.asList(res.getFile(ID_AGES_JAR)), // the ages jar file |
+ param.getString(KEY_LOGLEVEL, "INFO"), // The log level |
+ LOG); // This session logger |
+ } |
+ |
+ /** |
+ * Run Ages |
+ * |
+ * @param dsl |
+ * @throws Exception |
+ */ |
+ public static void runAgesNew(File dsl, File ws, PayloadParameter param, |
+ ServiceResources res, SessionLogger LOG) throws Exception { |
+ |
+ // Create/execute a Ages. |
+ Executable p = createProcessNew(dsl, ws, param, res, LOG); |
+ int result = p.exec(); |
+ if (result > 0) { |
+// File f = p.stderr(); |
+// if (f.exists() && f.length() > 10) { |
+// String err = FileUtils.readFileToString(f, "UTF-8"); |
+// LOG.info("Ages execution error. " + f + ":\n" + err); |
+// throw new ServiceException("Ages execution error. " + f + ":\n" + err); |
+// } |
+ throw new ServiceException("Ages execution error." + result); |
+ } |
+ } |
+ |
+ /** |
+ * Create the external Ages process. |
+ * |
+ * @param dsl |
+ * @param ws |
+ * @param param |
+ * @param res |
+ * @param LOG |
+ * @return |
+ * @throws java.lang.Exception |
+ */ |
+ public static Executable createProcessNew(File dsl, File ws, |
+ PayloadParameter param, ServiceResources res, SessionLogger LOG) throws Exception { |
+ |
+ Map<String, String> sysprops = new HashMap(); |
+ sysprops.put("oms_prj", ws.toString()); |
+ //System.out.println(" !!!! ws: " + ws.toString()); |
+ sysprops.put("csip_ages", LOCATION_MNT_DATA + "/ages_projects/ages_1_0/" + param.getString(PROJECT, "SFIR3")); |
+ //System.out.println(" csip_ages: " + LOCATION_MNT_DATA + "/ages_projects/ages_1_0/" + param.getString(PROJECT, "SFIR3")); |
+ |
+ String[] jvmOptions = Binaries.asSysProps(sysprops); |
+ String options = param.getString(KEY_OPTIONS, ""); |
+ if (options != null && !options.isEmpty()) { |
+ jvmOptions = (String[]) ArrayUtils.addAll(jvmOptions, options.split("\\s+")); |
+ } |
+ |
+ // java -Doms_prj=. -cp "dist/AgES.jar" oms3.CLI -l OFF -r "projects/sfir30/simulation/sfir30.sim" |
+ return Binaries.getResourceOMSDSL( |
+ dsl, // the dsl file to run |
+ jvmOptions, // jvm options |
+ ws, // workspace dir |
+ Arrays.asList(res.getFile(ID_AGES_JAR)), // the ages jar file |
param.getString(KEY_LOGLEVEL, "INFO"), // The log level |
LOG); // This session logger |
} |
@@ -545,7 +610,7 @@ |
|
// static void d() throws IOException { |
// CSProperties pr = DataIO.properties(new File("/od/projects/csip-all/csip-oms/tmp/data/main_params.csv"), "Parameter"); |
-// List<String> l = new ArrayList<>(pr.keySet()) ; |
+// List<String> l = new ArrayList<>(pr.keySet()) ; |
// Collections.sort(l); |
// for (String string : l) { |
// System.out.println("\"" + string + "\","); |