Пример #1
0
def new(name, config):
    _c = config
    config = Config(name)
    if _c:
        code.interact(local=locals())
    swap = SWAP(config)
    print(config)
    swap.save()
Пример #2
0
def run(name, data):
    swap = SWAP.load(name)
    config = swap.config
    parser = ClassificationParser(config)

    with open(data, 'r') as file:
        reader = csv.DictReader(file)
        for i, row in enumerate(reader):
            row = parser.parse(row)
            if row is None:
                logger.error(row)
                continue

            if i % 100 == 0:
                sys.stdout.flush()
                sys.stdout.write("%d records processed\r" % i)

            swap.classify(**row)

            # if i > 0 and i % 1e6 == 0:
            # print()
            # print('Applying records')
            # swap()
            # swap.truncate()

    swap()
    swap.retire(config.fpr, config.mdr)
    swap.save()

    code.interact(local={**globals(), **locals()})
Пример #3
0
def send(name):
    swap = SWAP.load(name)
    ce.Config.load(swap.config.online_name)
    logger.info('Sending reductions to caesar')
    Online.send(swap)

    logger.debug('Done sending reductions to caesar')
    code.interact(local={**globals(), **locals()})
Пример #4
0
def run(name):
    swap = SWAP.load(name)
    ce.Config.load(swap.config.online_name)

    Online.receive(swap)
    swap.save()
    ce.Config.instance().save()
    logger.debug('Saved swap status')
    logger.info('Sending reductions to caesar')
    Online.send(swap)

    logger.debug('Done sending reductions to caesar')
    code.interact(local={**globals(), **locals()})
Пример #5
0
def new(name, config):
    if config:
        config = Config()
        code.interact(local=locals())
        swap = SWAP(name, config)
    else:
        swap = SWAP(name)
    swap.save()
Пример #6
0
def golds(name, path):
    golds = []
    with open(path, 'r') as file:
        reader = csv.DictReader(file)
        for i, row in enumerate(reader):
            golds.append((int(row['subject']), int(row['gold'])))

            if i % 100 == 0:
                sys.stdout.flush()
                sys.stdout.write("%d records processed\r" % i)

    swap = SWAP.load(name)
    swap.apply_golds(golds)
    swap.save()
    code.interact(local={**globals(), **locals()})
Пример #7
0
def config(name, online_name):
    """
    Configure swap to use caesar external configuration
    
    \b
    Arguments
    ---------
    name - Name of swap configuration
    online-name - Name of caesar_external configuration
    """
    swap = SWAP.load(name)
    config = swap.config
    config.online_name = online_name
    code.interact(local={**globals(), **locals()})
    swap.save()
Пример #8
0
def run_continuous(name):
    swap = SWAP.load(name)
    ce.Config.load(swap.config.online_name)

    try:
        logger.info('Starting SWAP (%s) in continuous online mode...' % name)
        while True:
            _, haveItems = Online.receive(swap)
            if haveItems:
                swap.save()
                ce.Config.instance().save()
                logger.debug('Saved swap status')

                logger.info('Sending reductions to caesar')
                Online.send(swap)
                logger.debug('Done sending reductions to caesar')
    except KeyboardInterrupt as e:
        logger.debug('Received KeyboardInterrupt {}'.format(e))
        logger.debug('Terminating SWAP instance ({}).'.format(name))
        return
Пример #9
0
def load(name):
    swap = SWAP.load(name)
    code.interact(local={**globals(), **locals()})
Пример #10
0
def clear(name):
    swap = SWAP.load(name)
    swap = SWAP(name, swap.config)
    swap.save()
Пример #11
0
def config(name, online_name):
    swap = SWAP.load(name)
    config = swap.config
    config.online_name = online_name
    code.interact(local={**globals(), **locals()})
    swap.save()