throws ScriptException {
engine.eval("import inspect");
PyList args = (PyList) engine.eval("inspect.getargspec(run.func_closure[0].cell_contents)[0]");
PyTuple defaults = (PyTuple) engine
.eval("inspect.getargspec(run.func_closure[0].cell_contents)[3]");
PyDictionary inputs = (PyDictionary) process(engine).__getattr__("inputs");
if (args.size() != inputs.size()) {
throw new RuntimeException(String.format("process function specified %d arguments but"+
" describes %d inputs", args.size(), inputs.size()));
}
Map<String, Parameter<?>> map = new LinkedHashMap<String, Parameter<?>>();
for (int i = 0; i < args.size(); i++) {
String arg = args.get(i).toString();
PyTuple input = (PyTuple) inputs.get(arg);
if (input == null) {
throw new RuntimeException(String.format("process function specified argument %s" +
" but does not specify it as an input", arg));
}
int min = 1;
int max = 1;
Object defaultValue = null;
Map metadata = null;
if (input.size() == 3) {
PyDictionary meta = (PyDictionary) input.get(2);
min = getParameter(meta, "min", Integer.class, 1);
max = getParameter(meta, "max", Integer.class, 1);
List<String> options = getParameter(meta, "domain", List.class, null);
if (options != null) {
metadata = new HashMap();
metadata.put(Parameter.OPTIONS, options);
}
// map every other key as parameter metadata entry
HashSet<String> otherKeys = new HashSet<String>(meta.keySet());
otherKeys.remove("min");
otherKeys.remove("max");
otherKeys.remove("domain");
if(!otherKeys.isEmpty()) {
if (metadata == null) {
metadata = new HashMap();
}
for (String key : otherKeys) {
metadata.put(key, meta.get(key));
}
}
}
if (defaults != null) {
// from the python guide: