<commit_before>import time
import requests
import json
#
import numpy
#
import Engine as E


# settings
URI = 'http://localhost:8007'
id = 0


# helper functions
def create_message(method_name, params):
    global id
    id += 1
    message = {
        'jsonrpc': '2.0',
        'method': method_name,
        'params': params,
        'id': str(id),
        }
    return json.dumps(message)

def call_and_print(method_name, args_dict):
    message = create_message(method_name, args_dict)
    print 'trying message:', message
    r = requests.put(URI, data=message)
    r.raise_for_status()
    print json.loads(r.content)
    print

# non-stub functions
non_stub = set(['initialize', 'initialize_and_analyze'])
#
method_name = 'initialize'
args_dict = dict()
args_dict['M_c'] = 'M_c'
args_dict['M_r'] = 'M_r'
args_dict['i'] = ''
T_dim = (3, 4)
T = (numpy.arange(numpy.prod(T_dim)).reshape(T_dim) * 1.0).tolist()
args_dict['T'] = T
call_and_print(method_name, args_dict)
time.sleep(1)
#
method_name = 'initialize_and_analyze'
args_dict = dict()
args_dict['n_steps'] = 10
args_dict['SEED'] = 0
T_dim = (3, 4)
T = (numpy.arange(numpy.prod(T_dim)).reshape(T_dim) * 1.0).tolist()
args_dict['T'] = T
call_and_print(method_name, args_dict)
time.sleep(1)

# programmatically call all the other method calls
method_name_to_args = E.get_method_name_to_args()
for method_name, arg_str_list in method_name_to_args.iteritems():
    if method_name in non_stub:
        print 'skipping non-stub method:', method_name
        print
        continue
    args_dict = dict(zip(arg_str_list, arg_str_list))<commit_msg>call analyze<commit_after>import time
import requests
import json
#
import numpy
#
import Engine as E


# settings
URI = 'http://localhost:8007'
id = 0


# helper functions
def create_message(method_name, params):
    global id
    id += 1
    message = {
        'jsonrpc': '2.0',
        'method': method_name,
        'params': params,
        'id': str(id),
        }
    return json.dumps(message)

def call_and_print(method_name, args_dict):
    message = create_message(method_name, args_dict)
    print 'trying message:', message
    r = requests.put(URI, data=message)
    r.raise_for_status()
    out = json.loads(r.content)
    print out
    print
    if isinstance(out, dict) and 'result' in out:
        return out['result']
    else:
        # error?
        return out

T_dim = (3, 4)
T = (numpy.arange(numpy.prod(T_dim)).reshape(T_dim) * 1.0).tolist()

# non-stub functions
non_stub = set(['initialize', 'initialize_and_analyze', 'analyze'])
#
method_name = 'initialize'
args_dict = dict()
args_dict['M_c'] = 'M_c'
args_dict['M_r'] = 'M_r'
args_dict['i'] = ''
args_dict['T'] = T
out = call_and_print(method_name, args_dict)
time.sleep(1)
#
method_name = 'initialize_and_analyze'
args_dict = dict()
args_dict['n_steps'] = 10
args_dict['SEED'] = 0
args_dict['T'] = T
out = call_and_print(method_name, args_dict)
time.sleep(1)


X_L_prime, X_D_prime = out
method_name = 'analyze'
args_dict = dict()
args_dict['M_c'] = 'M_c'
args_dict['T'] = T
args_dict['X_L'] = X_L_prime
args_dict['X_D'] = X_D_prime
args_dict['kernel_list'] = 'kernel_list'
args_dict['n_steps'] = 2
args_dict['c'] = 'c'
args_dict['r'] = 'r'
args_dict['max_iterations'] = 'max_iterations'
args_dict['max_time'] = 'max_time'
out = call_and_print(method_name, args_dict)
time.sleep(1)

# programmatically call all the other method calls
method_name_to_args = E.get_method_name_to_args()
for method_name, arg_str_list in method_name_to_args.iteritems():
    if method_name in non_stub:
        print 'skipping non-stub method:', method_name
        print
        continue
    args_dict = dict(zip(arg_str_list, arg_str_list))
{'fraction_non_alphanumeric': 0.13695299837925445, 'fraction_numerical': 0.010804970286331712, 'mean_word_length': 4.252482269503546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4001551', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1386, 'n_words': 295}