<commit_before>#!/usr/bin/env python
import time
import gdapi
from gdapi import *  # NOQA

DEFAULT_TIMEOUT = 45


class Client(gdapi.Client):
    def __init__(self, *args, **kw):
        super(Client, self).__init__(*args, **kw)

    def wait_success(self, obj, timeout=DEFAULT_TIMEOUT):
        obj = self.wait_transitioning(obj, timeout)
        assert obj.transitioning == 'no'
        return obj

    def wait_transitioning(self, obj, timeout=DEFAULT_TIMEOUT):
        start = time.time()
        obj = self.reload(obj)
        while obj.transitioning == 'yes':
            time.sleep(.5)
            obj = self.reload(obj)
            if time.time() - start > timeout:
                msg = 'Timeout waiting for [{0}] to be done'.format(obj)
                raise Exception(msg)

        return obj


def from_env(prefix='CATTLE_', **kw):
    return gdapi.from_env(prefix=prefix, factory=Client, **kw)


def _main():
    gdapi._main()

if __name__ == '__main__':
    _main()<commit_msg>Default to env CATTLE_URL=http://localhost:8080/v1 is not set for CLI<commit_after>#!/usr/bin/env python
import time
import gdapi
import os
from gdapi import *  # NOQA

DEFAULT_TIMEOUT = 45


class Client(gdapi.Client):
    def __init__(self, *args, **kw):
        super(Client, self).__init__(*args, **kw)

    def wait_success(self, obj, timeout=DEFAULT_TIMEOUT):
        obj = self.wait_transitioning(obj, timeout)
        assert obj.transitioning == 'no'
        return obj

    def wait_transitioning(self, obj, timeout=DEFAULT_TIMEOUT):
        start = time.time()
        obj = self.reload(obj)
        while obj.transitioning == 'yes':
            time.sleep(.5)
            obj = self.reload(obj)
            if time.time() - start > timeout:
                msg = 'Timeout waiting for [{0}] to be done'.format(obj)
                raise Exception(msg)

        return obj


def from_env(prefix='CATTLE_', **kw):
    return gdapi.from_env(prefix=prefix, factory=Client, **kw)


def _main():
    if 'CATTLE_URL' not in os.environ:
        os.environ['CATTLE_URL'] = 'http://localhost:8080/v1'

    gdapi._main()

if __name__ == '__main__':
    _main()
{'fraction_non_alphanumeric': 0.12790697674418605, 'fraction_numerical': 0.008372093023255815, 'mean_word_length': 2.645762711864407, 'pattern_counts': {'":': 0, '<': 3, '<?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}}
{'dir': 'git-commits-cleaned', 'id': '5658919', 'n_tokens_mistral': 712, 'n_tokens_neox': 683, 'n_words': 170}