<commit_before>import zmq
import signal
import sys

port = 5556
context = zmq.Context()
socket = context.socket(zmq.PAIR)
socket.connect("tcp://172.18.0.1:%s" % port)
socket.send_string("hello")

def handler(signal, frame):
    print('exiting...')
    socket.disconnect("tcp://172.18.0.1:%s" % port)
    exit()

signal.signal(signal.SIGINT, handler)

reward = socket.recv()
next_input = socket.recv()

while True:
    socket.send_string("a") # your attempt to solve the current task
    reward = socket.recv()
    next_input = socket.recv()
    print(reward)

signal.pause()<commit_msg>example_learner.py: allow to specify address and port via options<commit_after>import zmq
import signal
import sys
import getopt


host = '172.18.0.1'
port = 5556

try:
    opts, args = getopt.getopt(sys.argv[1:], 'a:p:', ['address=', 'port='])
except getopt.GetoptError:
    print("Error reading options. Usage:")
    print("  example_learner.py [-a <address> -p <port>]")
    sys.exit(2)

for opt, arg in opts:
    if opt in ('-a', '--address'):
        host = arg
    elif opt in ('-p', '--port'):
        try:
            port = int(arg)
            if port < 1 or port > 65535:
                raise ValueError("Out of range")
        except ValueError:
            print("Invalid port number: %s" % arg)
            sys.exit(2)

context = zmq.Context()
socket = context.socket(zmq.PAIR)

address = "tcp://%s:%s" % (host, port)
print("Connecting to %s" % address)
sys.stdout.flush()

socket.connect(address)
socket.send_string("hello")


def handler(signal, frame):
    print('exiting...')
    socket.disconnect(address)
    exit()


signal.signal(signal.SIGINT, handler)

reward = socket.recv()
next_input = socket.recv()

while True:
    socket.send_string("a")  # your attempt to solve the current task
    reward = socket.recv()
    next_input = socket.recv()
    print(reward)

signal.pause()
{'fraction_non_alphanumeric': 0.1530720338983051, 'fraction_numerical': 0.020127118644067795, 'mean_word_length': 3.2071269487750556, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, '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': '6813201', 'n_tokens_mistral': 660, 'n_tokens_neox': 636, 'n_words': 164}