def ml_int_addition(value1, value2): """A simple and useless server side operation """ es = EvalService.from_envvar('MLLIB_TEST_SERVER') response = es.eval_post(xquery=ADDITION_XQY, vars={'value1': value1, 'value2': value2}) headers, document = response.iter_parts().next() assert headers['X-Primitive'] == 'integer' return int(document)
def ml_int_addition(value1, value2): """A simple and useless server side operation """ es = EvalService.from_envvar('MLLIB_TEST_SERVER') response = es.eval_post(xquery=ADDITION_XQY, vars={ 'value1': value1, 'value2': value2 }) headers, document = next(response.iter_parts()) assert headers['X-Primitive'] == 'integer' return int(document)
from mllib.documents import DocumentsService from mllib.eval import EvalService ALL_URIS_JS = r""" var res = []; for (var x of fn.doc()) { res.push(fn.documentUri(x)) } res; """ def hit_return(): raw_input("\nHit [Return] to continue:") if 'MLLIB_TEST_SERVER' not in os.environ: os.environ['MLLIB_TEST_SERVER'] = 'localhost:8000:admin:admin' print("Warning, your database will be cleaned") hit_return() es = EvalService.from_envvar('MLLIB_TEST_SERVER') ds = DocumentsService.from_envvar('MLLIB_TEST_SERVER') response = es.eval_post(javascript=ALL_URIS_JS) headers, document = response.iter_parts().next() uris = json.loads(document) if uris: ds.document_delete(uri=uris) print(len(uris), "document(s) deleted.")
from mllib.documents import DocumentsService from mllib.eval import EvalService ALL_URIS_JS = r""" var res = []; for (var x of fn.doc()) { res.push(fn.documentUri(x)) } res; """ def hit_return(): input("\nHit [Return] to continue:") if 'MLLIB_TEST_SERVER' not in os.environ: os.environ['MLLIB_TEST_SERVER'] = 'localhost:8000:admin:admin' print("Warning, your database will be cleaned") hit_return() es = EvalService.from_envvar('MLLIB_TEST_SERVER') ds = DocumentsService.from_envvar('MLLIB_TEST_SERVER') response = es.eval_post(javascript=ALL_URIS_JS) headers, document = next(response.iter_parts()) uris = json.loads(document) if uris: ds.document_delete(uri=uris) print(len(uris), "document(s) deleted.")