<jupyter_start><jupyter_text>ZeroMQ Interface<jupyter_code>from threading import Thread
from time import sleep
from profit.run.zeromq import ZeroMQInterface, ZeroMQRunnerInterface
from profit.config import BaseConfig, ZeroMQInterfaceConfig

BASE_CONFIG = BaseConfig.from_file('numpy.yaml')
MAX_IDS = BASE_CONFIG['ntrain']
config = {'class': 'zeromq'}
config = ZeroMQInterfaceConfig(**config)
config.process_entries(BASE_CONFIG)

def runner():
    rif = ZeroMQRunnerInterface(config, MAX_IDS, BASE_CONFIG['input'], BASE_CONFIG['output'])
    print(f'input_vars {rif.input_vars}')
    print(f'output_vars {rif.output_vars}')
    rif.input[['u', 'v']][1] = 1, -1
    for i in range(3):
        rif.poll()
        sleep(0.5)
        print(f'runner {i}')
    print(f'output {rif.output}')
    print(f'internal {rif.internal}')
    rif.clean()

def worker():
    wif = ZeroMQInterface(config, 1)
    print(f'input {wif.input}')
    wif.output['f'] = 2 * wif.input['u']
    wif.time = 2
    wif.done()

rt = Thread(target=runner)
wt = Thread(target=worker)

rt.start()
wt.start()
wt.join()
rt.join()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1532976827094474, 'fraction_numerical': 0.008021390374331552, 'mean_word_length': 4.758974358974359, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '648602', 'license': 'MIT', 'n_tokens_mistral': 416, 'n_tokens_neox': 402, 'n_words': 78, 'path': 'tests/run/interactive.ipynb', 'repo_name': 'Squadula/profit', 'size': '1122'}