<commit_before>import sys
import json
import logging
import signal
import msgpack
from time import sleep
from docker import Client
from redis import StrictRedis
from multiprocessing import Process 

from statsquid.util import output

log = logging.getLogger('statsquid')

class Agent(object):
    """
    Collects stats from all containers on a single Docker host, appending
    container name and id fields and publishing to redis
    params:
     - docker_host(str): full base_url of a Docker host to connect to.
                  (e.g. 'tcp://127.0.0.1:4243')
     - redis_host(str): redis host to connect to. default 127.0.0.1
     - redis_port(int): port to connect to redis host on. default 6379
    """
    def __init__(self,docker_host,redis_host='127.0.0.1',redis_port=6379):
        self.docker     = Client(base_url=docker_host)
        self.source     = self.docker.info()['Name']
        self.ncpu       = self.docker.info()['NCPU']
        self.redis      = StrictRedis(host=redis_host,port=redis_port,db=0)
        self.children   = []
        self.stopped    = False

        log.info('Connected to Docker API at url %s' % docker_host)
        output('starting collector on source %s' % self.source)
        self.start()
<commit_msg>update docker client to use auto-detected api version<commit_after>import sys
import json
import logging
import signal
import msgpack
from time import sleep
from docker import Client
from redis import StrictRedis
from multiprocessing import Process 

from statsquid.util import output

log = logging.getLogger('statsquid')

class Agent(object):
    """
    Collects stats from all containers on a single Docker host, appending
    container name and id fields and publishing to redis
    params:
     - docker_host(str): full base_url of a Docker host to connect to.
                  (e.g. 'tcp://127.0.0.1:4243')
     - redis_host(str): redis host to connect to. default 127.0.0.1
     - redis_port(int): port to connect to redis host on. default 6379
    """
    def __init__(self,docker_host,redis_host='127.0.0.1',redis_port=6379):
        self.docker     = Client(base_url=docker_host, version='auto')
        self.source     = self.docker.info()['Name']
        self.ncpu       = self.docker.info()['NCPU']
        self.redis      = StrictRedis(host=redis_host,port=redis_port,db=0)
        self.children   = []
        self.stopped    = False

        log.info('Connected to Docker API at url %s' % docker_host)
        output('starting collector on source %s' % self.source)
        self.start()

{'fraction_non_alphanumeric': 0.09749412685982772, 'fraction_numerical': 0.02427564604541895, 'mean_word_length': 2.9307692307692306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '5173095', 'n_tokens_mistral': 842, 'n_tokens_neox': 780, 'n_words': 234}