def main(): bi.init("Python", "../../../h2o-py/h2o/estimators", clear_dir=False) modules = [("h2o.estimators.deeplearning", "deeplearning", "H2OAutoEncoderEstimator", "Unsupervised"), ("h2o.estimators.estimator_base", "estimator_base", "H2OEstimator", "Miscellaneous"), ("h2o.grid", "grid", "H2OGridSearch", "Miscellaneous"), ("h2o.automl", "automl", "H2OAutoML", "Miscellaneous")] builders = bi.model_builders().items() algo_to_module = dict(drf="random_forest", naivebayes="naive_bayes", isolationforest="isolation_forest", extendedisolationforest="extended_isolation_forest") algo_to_category = dict(svd="Miscellaneous", word2vec="Miscellaneous") for name, mb in builders: module = name if name in algo_to_module: module = algo_to_module[name] bi.vprint("Generating model: " + name) bi.write_to_file("%s.py" % module, gen_module(mb, name)) category = algo_to_category[name] if name in algo_to_category \ else "Supervised" if mb["supervised"] \ else "Unsupervised" full_module = '.'.join(["h2o.estimators", module]) modules.append( (full_module, module, algo_to_classname(name), category)) bi.write_to_file("__init__.py", gen_init(modules)) bi.write_to_file("../../docs/modeling.rst", gen_models_docs(modules)) type_adapter1.vprint_translation_map()
def main(): bi.init("Python", "../../../h2o-py/h2o/estimators", clear_dir=False) modules = [("deeplearning", "H2OAutoEncoderEstimator", "Unsupervised"), ("estimator_base", "H2OEstimator", "Miscellaneous"), ("grid_search", "H2OGridSearch", "Miscellaneous"), ("automl", "H2OAutoML", "Miscellaneous")] builders = filter( lambda b: b[0] != 'coxph', bi.model_builders().items()) # CoxPH is not supported in Python yet for name, mb in builders: module = name if name == "drf": module = "random_forest" if name == "naivebayes": module = "naive_bayes" bi.vprint("Generating model: " + name) bi.write_to_file("%s.py" % module, gen_module(mb, name)) category = "Supervised" if mb["supervised"] else "Unsupervised" if name in {"svd", "word2vec"}: category = "Miscellaneous" modules.append((module, algo_to_classname(name), category)) bi.write_to_file("__init__.py", gen_init(modules)) bi.write_to_file("../../docs/modeling.rst", gen_models_docs(modules)) type_adapter1.vprint_translation_map()
def main(): bi.init("Java", "java") schemas_map = bi.schemas_map(add_generics=True) for name, schema in schemas_map.items(): bi.vprint("Generating schema: " + name) bi.write_to_file("water/bindings/pojos/%s.java" % name, generate_schema(name, schema)) for name, values in bi.enums().items(): bi.vprint("Generating enum: " + name) bi.write_to_file("water/bindings/pojos/%s.java" % name, generate_enum(name, sorted(values))) for name, endpoints in bi.endpoint_groups().items(): if name != "SegmentModelsBuilders": bi.vprint("Generating proxy: " + name) bi.write_to_file("water/bindings/proxies/retrofit/%s.java" % name, generate_proxy(name, endpoints)) bi.vprint("Generating H2oApi.java") bi.write_to_file("water/bindings/H2oApi.java", generate_main_class(bi.endpoints())) type_adapter.vprint_translation_map()
def main(): bi.init("Docs Json", "../../../h2o-docs", clear_dir=False) bi.vprint("Writing schemas.json...") bi.write_to_file("schemas.json", json.dumps(bi.schemas(raw=True))) bi.vprint("Writing routes.json...") bi.write_to_file("routes.json", json.dumps(bi.endpoints(raw=True)))
def main(): bi.init("Thrift", "thrift") schemas_map = bi.schemas_map() ordered_schemas = OrderedDict() for name, schema in schemas_map.items(): add_schema_to_dependency_array(schema, ordered_schemas, schemas_map) bi.write_to_file("water/bindings/structs/H2O.thrift", generate_thrift(ordered_schemas)) type_adapter.vprint_translation_map()
def main(): bi.init("Python", "python") for name, mb in bi.model_builders().items(): module = name if name == "drf": module = "random_forest" if name == "naivebayes": module = "naive_bayes" bi.vprint("Generating model: " + name) bi.write_to_file("%s.py" % module, gen_module(mb, name)) type_adapter.vprint_translation_map()
def main(): bi.init("R", "../../../h2o-r/h2o-package/R", clear_dir=False) for name, mb in bi.model_builders().items(): module = name if name == "drf": module = "random_forest" if name == "naivebayes": module = "naive_bayes" bi.vprint("Generating model: " + name) if name == "deepwater" or name == "deeplearning": print("Generating model:" + module) bi.write_to_file("%s.R" % module, gen_module(mb, name))
def main(): bi.init("C#", "CSharp") for schema in bi.schemas(): name = schema["name"] bi.vprint("Generating schema: " + name) bi.write_to_file("h2o/%s.cs" % name, generate_schema(name, schema)) for name, values in bi.enums().items(): bi.vprint("Generating enum: " + name) bi.write_to_file("h2o/%s.cs" % name, generate_enum(name, sorted(values))) type_adapter.vprint_translation_map()
def main(): bi.init("R", "../../../h2o-r/h2o-package/R", clear_dir=False) for name, mb in bi.model_builders().items(): module = name file_name = name if name == "drf": module = "randomForest" file_name = "randomforest" if name == "naivebayes": module = "naiveBayes" if name == "stackedensemble": module = "stackedEnsemble" if name == "pca": module = "prcomp" bi.vprint("Generating model: " + name) bi.write_to_file("%s.R" % file_name, gen_module(mb, name, module))
def main(): bi.init("Python", "../../../h2o-py/h2o/estimators", clear_dir=False) modules = [("deeplearning", "H2OAutoEncoderEstimator")] # deeplearning module contains 2 classes in it... for name, mb in bi.model_builders().items(): module = name if name == "drf": module = "random_forest" if name == "naivebayes": module = "naive_bayes" bi.vprint("Generating model: " + name) bi.write_to_file("%s.py" % module, gen_module(mb, name)) modules.append((module, algo_to_classname(name))) bi.write_to_file("__init__.py", gen_init(modules)) type_adapter.vprint_translation_map()
def main(): bi.init("R", "../../../h2o-r/h2o-package/R", clear_dir=False) for name, mb in bi.model_builders().items(): if name in ["aggregator"]: continue module = name file_name = name if name == "drf": module = "randomForest" file_name = "randomforest" if name == "naivebayes": module = "naiveBayes" if name == "stackedensemble": module = "stackedEnsemble" if name == "pca": module = "prcomp" bi.vprint("Generating model: " + name) bi.write_to_file("%s.R" % file_name, gen_module(mb, name, module))
def __init__(self, tiapp, project_dir, java, classes_dir, gen_dir, root_dir, include_all_modules=False, ti_sdk_dir=None): self.ti_sdk_dir = ti_sdk_dir self.ti_android_dir = None self.tiapp = tiapp self.java = java self.appname = tiapp.properties['name'] self.classes_dir = classes_dir self.gen_dir = gen_dir self.this_dir = this_dir self.appid = tiapp.properties['id'] self.root_dir = root_dir self.use_bytecode = False self.project_dir = os.path.abspath(os.path.expanduser(project_dir)) self.modules = set() self.jar_libraries = set() json_contents = open(os.path.join(self.ti_sdk_dir, 'android', 'dependency.json')).read() self.depends_map = simplejson.loads(json_contents) if self.ti_sdk_dir: self.ti_android_dir = os.path.join(self.ti_sdk_dir, "android") bindings.init(self.ti_android_dir) # go ahead and slurp in any required modules for required in self.depends_map['required']: self.add_required_module(required) runtime = tiapp.app_properties.get('ti.android.runtime', self.depends_map['runtimes']['defaultRuntime']) for runtime_jar in self.depends_map['runtimes'][runtime]: self.jar_libraries.add(os.path.join(self.ti_android_dir, runtime_jar)) if (tiapp.has_app_property('ti.android.include_all_modules')): if tiapp.to_bool(tiapp.get_app_property('ti.android.include_all_modules')): include_all_modules = True if include_all_modules: print '[INFO] Force including all modules...' sys.stdout.flush() for module in bindings.get_all_module_names(): self.add_required_module(module) self.module_methods = set() self.js_files = {} self.html_scripts = [] self.compiled_files = []
def main(): bi.init("Java", "java") for schema in bi.schemas(): name = schema["name"] bi.vprint("Generating schema: " + name) bi.write_to_file("water/bindings/pojos/%s.java" % name, generate_schema(name, schema)) for name, values in bi.enums().items(): bi.vprint("Generating enum: " + name) bi.write_to_file("water/bindings/pojos/%s.java" % name, generate_enum(name, sorted(values))) for name, endpoints in bi.endpoint_groups().items(): bi.vprint("Generating proxy: " + name) bi.write_to_file("water/bindings/proxies/retrofit/%s.java" % name, generate_proxy(name, endpoints)) bi.vprint("Generating H2oApi.java") bi.write_to_file("water/bindings/H2oApi.java", generate_main_class(bi.endpoints())) type_adapter.vprint_translation_map()
def __init__(self, name, myid, android_sdk_dir, deploy_type, java, ti_sdk_dir): self.name = name # android requires at least one dot in packageid if len(re.findall(r'\.',myid))==0: myid = 'com.%s' % myid self.id = myid self.android_sdk_dir = android_sdk_dir self.ti_sdk_dir = ti_sdk_dir bindings.init(os.path.join(ti_sdk_dir, "android")) # Used in templating self.config = { 'appid': self.id, 'appname' : self.name, 'appversion' : '1', 'apiversion' : '7', #Android 2.1 'deploy_type': deploy_type, 'compile_js': False } self.config['classname'] = Android.strip_classname(self.name) self.deploy_type = deploy_type self.java = java
def main(): bi.init("Python", "../../../h2o-py/h2o/estimators", clear_dir=False) modules = [("deeplearning", "H2OAutoEncoderEstimator", "Unsupervised"), ("estimator_base", "H2OEstimator", "Miscellaneous"), ("grid_search", "H2OGridSearch", "Miscellaneous"), ("automl", "H2OAutoML", "Miscellaneous")] builders = filter(lambda b: b[0] != 'coxph', bi.model_builders().items()) # CoxPH is not supported in Python yet for name, mb in builders: module = name if name == "drf": module = "random_forest" if name == "naivebayes": module = "naive_bayes" bi.vprint("Generating model: " + name) bi.write_to_file("%s.py" % module, gen_module(mb, name)) category = "Supervised" if mb["supervised"] else "Unsupervised" if name in {"svd", "word2vec"}: category = "Miscellaneous" modules.append((module, algo_to_classname(name), category)) bi.write_to_file("__init__.py", gen_init(modules)) bi.write_to_file("../../docs/modeling.rst", gen_models_docs(modules)) type_adapter1.vprint_translation_map()
for i, field in enumerate(schema["fields"]): if field["name"] == "__meta": continue thrift_type = translate_type(field["type"], field["schema_name"]) name = field["name"] if name in thrift_reserved_words: name += "_" required = "required" if field["required"] else "optional" yield bi.wrap(field["help"], indent=" # ") yield " {num}: {req} {type} {name},".format(num=i, req=required, type=thrift_type, name=name) yield "" yield "}" yield "" # ---------------------------------------------------------------------------------------------------------------------- # MAIN # ---------------------------------------------------------------------------------------------------------------------- if __name__ == "__main__": bi.init("Thrift", "thrift") type_adapter = ThriftTypeTranslator() schemas_map = bi.schemas_map() ordered_schemas = OrderedDict() for name, schema in schemas_map.items(): add_schema_to_dependency_array(schema, ordered_schemas, schemas_map) bi.write_to_file("water/bindings/structs/H2O.thrift", generate_thrift(ordered_schemas)) type_adapter.vprint_translation_map()
#!/usr/bin/env python # -*- encoding: utf-8 -*- from __future__ import unicode_literals import json import bindings as bi if __name__ == "__main__": bi.init("Docs Json", "../../../h2o-docs", clear_dir=False) bi.vprint("Writing schemas.json...") bi.write_to_file("schemas.json", json.dumps(bi.schemas(raw=True))) bi.vprint("Writing routes.json...") bi.write_to_file("routes.json", json.dumps(bi.endpoints(raw=True)))
def initUI(self): """Initialise UI elements.""" self.log.write("Initialising UI") styles.init(self) # Top level frames try: self.titleBar = frames.titleBar(self, root) self.log.write(self.titleBar.testMessage) except Exception as ex: #print("titleBar was not initialised properly") self.log.writeError( "titleBar was not initialised properly. Error:\n" + str(ex)) self.quit() try: self.formatBar = frames.formatBar(self) self.log.write(self.formatBar.testMessage) except Exception as ex: #print("formatBar was not initialised properly") self.log.writeError( "formatBar was not initialised properly. Error:\n" + str(ex)) self.quit() try: self.arrangementFrame = frames.arrangementFrame(self) self.log.write(self.arrangementFrame.testMessage) except Exception as ex: #print("arrangementFrame was not initialised properly") e = "arrangementFrame was not initialised properly. Error:\n" e += str(ex) self.log.writeError(e) self.quit() try: self.textFrame = frames.text(self.arrangementFrame, root) self.log.write(self.textFrame.testMessage) except Exception as ex: #print("textFrame was not initialised properly") e = "textFrame was not initialised properly. Error:\n" e += str(ex) self.log.writeError(e) self.quit() try: self.tabBar = tabs.tabBar(self.arrangementFrame) self.log.write(self.tabBar.testMessage) except Exception as ex: #print("tabBar was not initialised properly") self.log.writeError( "tabBar was not initialised properly. Error:\n" + str(ex)) self.quit() try: bindings.init(self, root) except Exception as ex: #print("bindings were not initialised properly") self.log.writeError( "bindings were not initialised properly. Error:\n" + str(ex)) self.quit() self.textFrame.textBox.focus_set() self.log.write("All initialised\n")
name = field["name"] if name in thrift_reserved_words: name += "_" required = "required" if field["required"] else "optional" yield bi.wrap(field["help"], indent=" # ") yield " {num}: {req} {type} {name},".format(num=i, req=required, type=thrift_type, name=name) yield "" yield "}" yield "" # ---------------------------------------------------------------------------------------------------------------------- # MAIN # ---------------------------------------------------------------------------------------------------------------------- if __name__ == "__main__": bi.init("Thrift", "thrift") type_adapter = ThriftTypeTranslator() schemas_map = bi.schemas_map() ordered_schemas = OrderedDict() for name, schema in schemas_map.items(): add_schema_to_dependency_array(schema, ordered_schemas, schemas_map) bi.write_to_file("water/bindings/structs/H2O.thrift", generate_thrift(ordered_schemas)) type_adapter.vprint_translation_map()
yield " * This file is auto-generated by h2o-3/h2o-bindings/bin/gen_csharp.py" yield " * Copyright 2016 H2O.ai; Apache License Version 2.0 (see LICENSE for details)" yield " */" yield "namespace ai.h2o" yield "{" yield " public enum " + name + " {" for value in values: yield " %s," % value yield " }" yield "}" # ---------------------------------------------------------------------------------------------------------------------- # MAIN: # ---------------------------------------------------------------------------------------------------------------------- if __name__ == "__main__": bi.init("C#", "CSharp") type_adapter = CSharpTypeTranslator() for schema in bi.schemas(): name = schema["name"] bi.vprint("Generating schema: " + name) bi.write_to_file("h2o/%s.cs" % name, generate_schema(name, schema)) for name, values in bi.enums().items(): bi.vprint("Generating enum: " + name) bi.write_to_file("h2o/%s.cs" % name, generate_enum(name, sorted(values))) type_adapter.vprint_translation_map()
yield "/**" yield " * This file is auto-generated by h2o-3/h2o-bindings/bin/gen_csharp.py" yield " * Copyright 2016 H2O.ai; Apache License Version 2.0 (see LICENSE for details)" yield " */" yield "namespace ai.h2o" yield "{" yield " public enum " + name + " {" for value in values: yield " %s," % value yield " }" yield "}" # ---------------------------------------------------------------------------------------------------------------------- # MAIN: # ---------------------------------------------------------------------------------------------------------------------- if __name__ == "__main__": bi.init("C#", "CSharp") type_adapter = CSharpTypeTranslator() for schema in bi.schemas(): name = schema["name"] bi.vprint("Generating schema: " + name) bi.write_to_file("h2o/%s.cs" % name, generate_schema(name, schema)) for name, values in bi.enums().items(): bi.vprint("Generating enum: " + name) bi.write_to_file("h2o/%s.cs" % name, generate_enum(name, sorted(values))) type_adapter.vprint_translation_map()