Esempio n. 1
0
#!/usr/bin/env python

import sys
from deiis.rabbit import Message, MessageBus

destination = '/tmp/submission.json'
if len(sys.argv) > 1:
    destination = sys.argv[1]

message = Message.Command('SAVE ' + destination, [])

bus = MessageBus()
bus.publish('results', message)
print 'Save command sent. Saving to ' + destination
Esempio n. 2
0
import sys
from deiis.rabbit import Message, MessageBus

if __name__ == '__main__':
    message = Message(body='start', route=sys.argv[1:])
    bus = MessageBus()
    bus.send(message)
Esempio n. 3
0
    print 'Processing ' + filename
    fp = open(filename, 'r')
    dataset = Serializer.parse(fp, DataSet)
    fp.close()

    # The list of services to send the questions to.

    """ Kaichen Chen 0304 """
    if not debug:
        pipeline = ['mmr.core', 'tiler.concat', 'results']
    else:
        pipeline = ['splitter', 'mmr.core', 'tiler.concat', 'results']

    """ kaichenc 0307 """
    host = os.environ.get('HOST', 'localhost')
    print "DEBUG: Current host of Message Bus: {}".format(host)

    count=0
    bus = MessageBus(host = host)
    for index in range(0,10):
        question = dataset.questions[index]
    # for question in dataset.questions:
        message = Message(body=question, route=pipeline)
        bus.publish('expand.none', message)
        # bus.publish('splitter', message)
        count = count + 1

    print 'Sent {} questions for ranking.'.format(count)
    print 'Done.'

Esempio n. 4
0
#!/usr/bin/env python

import sys
from deiis.rabbit import MessageBus, Message

# All the services that may be running.
all = ['splitter', 'mmr.hard', 'mmr.soft', 'mmr.core',
        'expand.none', 'expand.snomed', 'expand.umls',
        'tiler.concat',
        'results'
        ]

# The shutdown message for the services.
die = Message.Command('DIE', [])
bus = MessageBus()


if len(sys.argv) > 1:
    if sys.argv[1]  == 'all':
        services = all
    else:
        services = sys.argv[1:]
else:
    services = all

# Send the shutdown message to each of the services.
for service in services:
    print 'Terminating ' + service
    bus.publish(service, die)

print 'Done.'
Esempio n. 5
0
import os

print 'stop.py: called'

# All the services that may be running.
all = [
    'mmr.hard', 'mmr.soft', 'mmr.core', 'expand.none', 'expand.snomed',
    'expand.umls', 'tiler.concat', 'results', 'splitter'
]

# The shutdown message for the services.
die = Message.Command('DIE', [])
""" kaichenc 0307 """
host = os.environ.get('HOST', 'localhost')
print "DEBUG: Current host of Message Bus: {}".format(host)
bus = MessageBus(host=host)

if len(sys.argv) > 1:
    if sys.argv[1] == 'all':
        services = all
    else:
        services = sys.argv[1:]
else:
    services = all

# Send the shutdown message to each of the services.
for service in services:
    print 'Terminating ' + service
    bus.publish(service, die)

print 'Done.'
Esempio n. 6
0
from deiis.model import Serializer, DataSet, Question

if __name__ == '__main__':
    if len(sys.argv) <= 2:
        print 'Usage: python pipeline.py <data.json> <RabbitMQ_host>'
        exit(1)

    # filename = 'data/training.json'
    filename = sys.argv[1]
    print 'Processing ' + filename
    fp = open(filename, 'r')
    dataset = Serializer.parse(fp, DataSet)
    fp.close()

    # The list of services to send the questions to.
    #pipeline = ['mmr.core', 'tiler.concat', 'results']
    pipeline = ['mmr.core', 'tiler.concat', 'results']
    #pipeline = ['splitter', 'mmr.core', 'tiler.concat', 'results']
    count=0
    bus = MessageBus()
    for index in range(0,10):
        question = dataset.questions[index]
        # for question in dataset.questions:
        message = Message(body=question, route=pipeline)
        print(question.body)
        bus.publish('expand.none', message)
        count = count + 1

    print 'Sent {} questions for ranking.'.format(count)
    print 'Done.'
Esempio n. 7
0
#!/usr/bin/env python

import sys
from deiis.rabbit import Message, MessageBus
""" kaichenc 0307 """
import os

print 'save.py: called'

destination = '/tmp/submission.json'
if len(sys.argv) > 1:
    destination = sys.argv[1]

message = Message.Command('SAVE ' + destination, [])
""" kaichenc 0307 """
host = os.environ.get('HOST', 'localhost')
print "DEBUG: Current host of Message Bus: {}".format(host)
bus = MessageBus(host=host)

bus.publish('results', message)
# print 'Save command sent. Saving to ' + destination
print 'DEBUG: Save command sent.'
print 'kaichenc: please refer to ResultsCollector for final destination'
print 'kaichenc: default /tmp/submission.json in linux'
print 'kaichenc: if path invalid, always save to ./tmp/submission.json'
Esempio n. 8
0
#!/usr/bin/env python

import sys
from deiis.rabbit import Message, MessageBus
from deiis.model import Serializer, DataSet, Question
host = os.environ.get('RABBITMQ_HOST')

if __name__ == '__main__':
    if len(sys.argv) == 1:
        print 'Usage: python pipeline.py <data.json>'
        exit(1)
    filename = sys.argv[1]
    print 'Processing ' + filename
    fp = open(filename, 'r')
    dataset = Serializer.parse(fp, DataSet)
    fp.close()

    pipeline = ['expand.none', 'mmr.core', 'tiler.concat', 'results']
    count = 0
    bus = MessageBus(host=host)
    for index in range(0, 10):
        question = dataset.questions[index]

        message = Message(body=question, route=pipeline)
        bus.publish("splitter", message)
        count = count + 1

    print 'Sent {} questions for ranking.'.format(count)
    print 'Done.'
Esempio n. 9
0
            u'The increased odds ratios with African Americans was retained in post-menopausal women, while the protective odds ratios for pregnancy, smoking and oral contraceptives (OCs) became stronger in pre-menopausal women. The pattern by duration and timing of use does not suggest an etiologic role for OCs or hormone replacement therapy. ',
            u'beginSection': u'abstract',
            u'document': u'http://www.ncbi.nlm.nih.gov/pubmed/16570277',
            u'endSection': u'abstract'
        }, {
            u'offsetInBeginSection': 1044,
            u'offsetInEndSection': 1221,
            u'text':
            u'The use of hormone replacement therapy in symptomatic postmenopausal women either with previously treated disease or with dormant tumors is discussed, but remains controversial.',
            u'beginSection': u'abstract',
            u'document': u'http://www.ncbi.nlm.nih.gov/pubmed/15006250',
            u'endSection': u'abstract'
        }]
    }
    logger = logging.getLogger('main')
    message = Message(route=['tiler.concat', 'results'], body=input)
    json = Serializer.to_pretty_json(message)

    logger.info('publishing question')
    bus = MessageBus()
    bus.publish('mmr.core', json)
    # bus.publish('mmr.soft', json)
    # bus.publish('mmr.hard', json)

    # logger.info('Waiting for the thread to stop')
    # results.wait_for()
    #
    # logger.info('Killing the ranker services')
    # message = Message.Command('DIE', route=['mmr.hard', 'mmr.core'])
    # bus.publish('mmr.soft', Serializer.to_json(message))
    logger.info('Done')
Esempio n. 10
0
            for token in sentence:
                print token
            print ''


if __name__ == '__main__':
    splitter = Splitter()
    tokenizer = Tokenizer()
    printer = Printer()

    services = (splitter, tokenizer, printer)

    for service in services:
        print 'Staring service ' + str(type(service))
        service.start()

    print 'Sending the message to the splitter'
    message = Message(body="Goodbye cruel world. I am leaving you today.",
                      route=['tokenizer', 'printer'])
    bus = MessageBus()
    bus.publish('splitter', message)

    print 'Sleeping...'
    time.sleep(1)

    print 'Stopping all the services'
    for service in services:
        service.stop()

    print 'Done.'