<commit_before>import zmq
import msgpack
import time

class BasicMLTesting(object):
    def __init__(self):
        self.chip_buffer = []
        self.recv_count = 0

    def run(self, port = 5570):
        self.port = port

        print 'Running Basic Machine learning-based testing, listening on port %d ...' % port
        self.context = zmq.Context()
        self.socket  = self.context.socket(zmq.REQ)
        self.socket.connect("tcp://127.0.0.1:5570")

        unpacker = msgpack.Unpacker()
        try:
            while True:
                print 'Requesting chip instance ...',
                self.socket.send('REQ:send_LCT')

                unpacker.feed(self.socket.recv())
                chip = unpacker.unpack()
                if chip is not None:
                    self.recv_count += 1
                    self.chip_buffer.append(chip)
                    print 'received chip #', self.recv_count

                    print 'sending done to ATE simulator ...\n'
                    self.socket.send('REQ:done')
                    assert self.socket.recv() == 'RES:ack', \
                        'Error: invalid ack from ATE simulator'

        except KeyboardInterrupt:
            print '\nterminating basic ML testing.'<commit_msg>where to put training algorithm<commit_after>import zmq
import msgpack
import time

class BasicMLTesting(object):
    def __init__(self):
        self.chip_buffer = []
        self.recv_count = 0

    def run(self, port = 5570):
        self.port = port

        print 'Running Basic Machine learning-based testing, listening on port %d ...' % port
        self.context = zmq.Context()
        self.socket  = self.context.socket(zmq.REQ)
        self.socket.connect("tcp://127.0.0.1:5570")

        unpacker = msgpack.Unpacker()
        try:
            while True:
                print 'Requesting chip instance ...',
                self.socket.send('REQ:send_LCT')

                unpacker.feed(self.socket.recv())
                chip = unpacker.unpack()
                if chip is not None:
                    self.recv_count += 1
                    self.chip_buffer.append(chip)
                    print 'received chip #', self.recv_count

                    print 'sending done to ATE simulator ...\n'
                    self.socket.send('REQ:done')
                    assert self.socket.recv() == 'RES:ack', \
                        'Error: invalid ack from ATE simulator'
                if self.recv_count==1000:
                    print "Training Algorithm will run on these 1000 chips"

        except KeyboardInterrupt:
            print '\nterminating basic ML testing.'
{'fraction_non_alphanumeric': 0.10105580693815988, 'fraction_numerical': 0.015082956259426848, 'mean_word_length': 1.5782312925170068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4872701', 'n_tokens_mistral': 764, 'n_tokens_neox': 690, 'n_words': 182}