Beispiel #1
0
def extract(n: str):
    try:
        n = int(n)
    except ValueError:
        n = None

    application = Application()
    application.extract(n)
def cancelApplication(id):
    print(id)
    try:
        bearer = request.headers.get('Authorization')
        userEmail = decodeToken(bearer)
        Application.cancelApplication(userEmail, id)
        return jsonify(
            {'message':
             'Application #' + id + ' was successfully canceled'}), 200
    except DatabaseConnectionFailed as dcf:
        return jsonify({"message": "Something went wrong"}), 500
    except AuthorizationFailed as af:
        return jsonify({"message": af.message}), 401
def rejectApplication(id):
    try:
        bearer = request.headers.get('Authorization')
        motive = request.json.get('motive')
        filler = request.json.get('filler')
        decodeToken(bearer)
        Application.rejectApplication(filler, id, motive)
        return jsonify({'message':
                        'Application #' + id + ' was rejected'}), 200
    except DatabaseConnectionFailed as dcf:
        return jsonify({"message": "Something went wrong"}), 500
    except AuthorizationFailed as af:
        return jsonify({"message": af.message}), 401
Beispiel #4
0
    def test_instanceCreation(self):
        application = Application('*****@*****.**', 'Barbijos', 'Técnicos', None)

        self.assertEqual(application.filler, '*****@*****.**')
        self.assertEqual(application.supply, 'Barbijos')
        self.assertEqual(application.area, 'Técnicos')
        self.assertEqual(application.status, 'Pending')
def applications():
    try:
        bearer = request.headers.get('Authorization')
        userEmail = decodeToken(bearer)
        appls = Application.applicationsBy(userEmail)
        return jsonify(appls), 200
    except AuthorizationFailed as e:
        return jsonify({"message": e.message}), 401
    except DatabaseConnectionFailed as e:
        return jsonify({"Something went wrong"}), 500
Beispiel #6
0
def run():
    print('Loading data...')
    app = Application()
    with open(Application.model['app_data'], 'rb') as f:
        tokenizer_data, emb_matrix, word2tokenizer = pickle.load(f)
    train_set = tokenizer_data[0]
    dev_set = tokenizer_data[1]
    test_set = tokenizer_data[2]
    # style_models = ['bi_gru_multi_attention', 'multi_attention', 'bi_lstm', 'ap_bi_lstm', 'ap_bi_gru', 'bi_gru', 'cnn',
    #                 'ap_cnn']
    style_models = ['bi_gru_multi_attention']
    for i in range(100):
        for style_model in style_models:
            train = [train_set['q1'], train_set['q2'], train_set['q1_length'], train_set['q2_length']]
            dev = [dev_set['q1'], dev_set['q2'], dev_set['q1_length'], dev_set['q2_length']]
            test = [test_set['q1'], test_set['q2'], test_set['q1_length'], test_set['q2_length']]
            model = NeuralNetworksModels(emb_matrix, style_model).model()
            file_path = Application.directory['data'] + 'model-train-normal-' + style_model + '.h5'
            checkpoint = ModelCheckpoint(file_path, monitor='val_acc', save_best_only=True, mode='max', verbose=1,
                                         save_weights_only=True)
            hist = model.fit(train, train_set['y'], callbacks=[checkpoint],
                             validation_data=[dev, dev_set['y']],
                             epochs=app.model_params['epochs'],
                             batch_size=app.model_params['batch_size'])
            score_1, acc_1 = model.evaluate(x=test, y=test_set['y'], batch_size=app.model_params['batch_size'])
            predicts_1 = model.predict(test, batch_size=app.model_params['batch_size'])
            model = NeuralNetworksModels(emb_matrix, style_model).model(file_path)
            score, acc = model.evaluate(x=test, y=test_set['y'], batch_size=app.model_params['batch_size'])
            predicts = model.predict(test, batch_size=app.model_params['batch_size'])
            if acc_1 > acc:
                score = score_1
                acc = acc_1
                predicts = predicts_1
            print("current best acc:%s\t test score:%s" % (acc, score))
            if acc > app.learner[style_model]:
                app.learner[style_model] = acc
                print("save acc:%s\t test score:%s" % (acc_1, score_1))
                with open(Application.directory['model'] + style_model + Application.model['predict'],
                          'wb') as f:
                    pickle.dump(predicts, f)
                write_result_file(test_set, predicts, hist, score, style_model, acc)
Beispiel #7
0
def run():
    print('Loading data...')
    app = Application()
    with open(Application.model['app_data'], 'rb') as f:
        tokenizer_data, emb_matrix, word2tokenizer = pickle.load(f)
    train_set = tokenizer_data[0]
    dev_set = tokenizer_data[1]
    test_set = tokenizer_data[2]
    style_models = ['cnn', 'ap_cnn']
    for style_model in style_models:
        train = [train_set['q1'], train_set['q2'], train_set['q1_length'], train_set['q2_length']]
        dev = [dev_set['q1'], dev_set['q2'], dev_set['q1_length'], dev_set['q2_length']]
        test = [test_set['q1'], test_set['q2'], test_set['q1_length'], test_set['q2_length']]
        model = NeuralNetworksModels(emb_matrix, style_model).model()
        file_path = Application.directory['data'] + 'model-train-normal-' + style_model + '.h5'
        checkpoint = ModelCheckpoint(file_path, monitor='val_acc', save_best_only=True, mode='max', verbose=1,
                                     save_weights_only=True)
        hist = model.fit(train, train_set['y'], callbacks=[checkpoint],
                         validation_data=[dev, dev_set['y']],
                         epochs=app.model_params['epochs'],
                         batch_size=app.model_params['batch_size'])
        score_1, acc_1 = model.evaluate(x=test, y=test_set['y'], batch_size=app.model_params['batch_size'])
        predicts_1 = model.predict(test, batch_size=app.model_params['batch_size'])
        print("test acc:%s\t test score:%s" % (acc_1, score_1))
        model = NeuralNetworksModels(emb_matrix, style_model).model(file_path)
        score, acc = model.evaluate(x=test, y=test_set['y'], batch_size=app.model_params['batch_size'])
        predicts = model.predict(test, batch_size=app.model_params['batch_size'])
        print("test acc:%s\t test score:%s" % (acc, score))
        if acc_1 > acc:
            score = score_1
            acc = acc_1
            predicts = predicts_1
        with open(Application.directory['model'] + style_model + Application.model['predict'],
                  'wb') as f:
            pickle.dump(predicts, f)
        write_texts = []
        for j in range(len(test_set['y'])):
            write_texts.append("%.4g\t %s t1: %s\t t2: %s" %
                               (predicts[j], test_set['y'][j], " ".join(test_set['q1_text'][j]),
                                " ".join(test_set['q2_text'][j])))
        write_texts.append("test acc:%.4g\t test score:%s\t history acc:%s\t history score:%s" % (
            acc, score, max(hist.history['acc']), min(hist.history['loss'])))
        print("test acc:%s\t test score:%s\t history acc:%s\t history score:%s" % (
            acc, score, max(hist.history['acc']), min(hist.history['loss'])))
        write_result_file(write_texts, style_model, acc)
Beispiel #8
0
# -*- coding: utf-8 -*-

import sys
from src.application import Application

if __name__ == '__main__':
    """エントリポイント
    """
    args = sys.argv
    if len(args) >= 2:
        Application(params_path=args[1])
    else:
        Application()
Beispiel #9
0
def start():
    application = Application()
    application.start()
Beispiel #10
0
    if (args.iter):
        config.application.iter = args.iter
    if (args.result_dir):
        config.application.deblurring_result_dir = args.result_dir
    set_session_config(per_process_gpu_memory_fraction=1,
                       allow_growth=True,
                       device_list=args.gpu)
    gpus = args.gpu.split(",")
    config.trainer.gpu_num = len(gpus)
    if (args.train):
        #trainer
        from src.trainer import Trainer
        Trainer(config).start()
    elif (args.test):
        #tester
        from src.tester import Tester
        Tester(config).start()
    elif (args.apply):
        #application
        from src.application import Application
        Application(config).start()
    elif (args.verify):
        #verification
        from src.verification import Verification
        Verification(config).start()
    else:
        #info
        from src.model.model import DDModel
        model = DDModel(config)
        model.generator.summary(line_length=150)
Beispiel #11
0
def main():
    args = parse_args()
    with DBConnection(args.host, args.port, args.service, user=args.username, password=args.password) as db_connection:
        app = Application(db_connection)
        app.mainloop()
def createApplicationWith(bearer, supply, area, medicine):
    userEmail = decodeToken(bearer)
    application = Application(userEmail, supply, area, medicine)

    return application.addApplication()
Beispiel #13
0
import pygame
from pygame import Rect

from src.application import Application
from src.screen import Screen
from src.widgets.button import Button

screen = Screen((500, 500))
app = Application("My cute application", 30)

btn = Button(Rect(0, 0, 50, 50), screen)
btn.connect(pygame.MOUSEBUTTONUP, lambda e: print("Hello"))

app.set_screen(screen)

app.run()
Beispiel #14
0
from src.application import Application

app = Application()
app.mainloop()
Beispiel #15
0
def main(stdscr):
  application = Application(config)
  application.run(stdscr)
Beispiel #16
0
from src.application import Application

app = Application()
app.bootstrap()
Beispiel #17
0
 def test_FieldsNotEmpty(self):
     with self.assertRaises(InstanceCreationFailed):
         Application('*****@*****.**', 'Barbijos', None, None)
Beispiel #18
0
    def test_canceledApplicationCannotBeApproved(self):
        application = Application('*****@*****.**', 'Barbijos', 'Técnicos', None)
        application.cancel()

        with self.assertRaises(StatusTransitionFailed):
            application.approve()
Beispiel #19
0
    def test_approveApplication(self):
        application = Application('*****@*****.**', 'Barbijos', 'Técnicos', None)
        application.approve()

        self.assertEqual(application.status, 'Approved')
Beispiel #20
0
    def test_cancelApplication(self):
        application = Application('*****@*****.**', 'Barbijos', 'Técnicos', None)
        application.cancel()

        self.assertEqual(application.status, 'Canceled')
Beispiel #21
0
def get_rich_slowly(total_capitol, number_of_days_to_spend, output_location):
    Application(total_capitol, number_of_days_to_spend, output_location).run()
Beispiel #22
0
 def test_application(self):
     app = Application(self.config)
     self.assertEqual([], app.states)
Beispiel #23
0
#!/bin/python2

from src.application import Application

app = Application()
app.run()
Beispiel #24
0
from gevent import monkey

monkey.patch_all()

import sys

from config.active import config
from src.application import Application
from packages.args import Args

Application(Args.parse(sys.argv), config).run()
import builtins
import time

from src.application import Application

application = Application()
builtins.application = application

# NOTE: These must be imported after inserting application into the global namespace, because those
# modules reference the applicationo. This is a little unorthodox, but allows for splitting the code
# up in a more logical way, which should make maintenance easier
#
# Putting these in an if block prevents IDEs from auto-moving them to an earlier location as part of
# code autoformatting
if True:
    import src.bot
    import src.oauth_server

if __name__ == '__main__':
    # Start the web server which will handle oauth redirects
    application.start_flask()

    # Connect the Twitch bot to the channel chat and request, then wait for, oauth approval
    application.start_bot()

    # Bot actions occur asynchronously, so wait here as well for oauth approval
    application.wait_for_oauth_approval()

    while True:
        time.sleep(1)
Beispiel #26
0
                message = create_data(data)

            self.write(message)

            await y_(self.flush())
        except iostream.StreamClosedError:
            pass

    async def get(self):
        res = await self.application.redis.subscribe('channel:test')
        ch = res[0]
        while await ch.wait_message():
            try:
                data = await ch.get_json()
                await y_(
                    self.publish(json.dumps(data), 'test-event', time.time()))
            except json.JSONDecodeError:
                pass


if __name__ == "__main__":
    application = Application([
        (r'/', MainHandler),
        (r'/events', EventSource),
    ],
                              debug=True)
    application.listen(8888)
    loop = asyncio.get_event_loop()
    application.init_with_loop(loop)
    loop.run_forever()