Beispiel #1
0
def test_init_checkpoint():
    src.main(FREQ=1)
    checkpoint = "checkpoint_name.pkl"
    with open(checkpoint, "r") as cp_file:
        cp = pickle.load(cp_file)

    start_gen = cp["generation"]
    assert (start_gen) == 2
Beispiel #2
0
def main():
    if use_psyco:
        psyco.full()
    if psyco_log:
        psyco.log()

    global src
    import src

    if profile:
        cProfile.run("src.main()", "stats")
    else:
        src.main()
Beispiel #3
0
def main():
    if use_psyco:
        psyco.full()
    if psyco_log:
        psyco.log()
    
    global src
    import src
    
    if profile:
        cProfile.run("src.main()", "stats")
    else:
        src.main()
Beispiel #4
0
def get_data(n_clicks, symbol, function, interval, no_api):
    """Get the data from main
    """
    if (('INTRADAY' in function) & (interval is None)) | \
            (n_clicks == 0) | \
            (symbol is None) | \
            (function is None):
        return {'prices': pd.DataFrame({'datetime': [],
                                        'open': [],
                                        'high': [],
                                        'low': [],
                                        'close': [],
                                        'volume': []}),
                'dividends': pd.DataFrame({'symbol': [],
                                           'datetime': [],
                                           'dividend_amount': []})}

    return main(
        {'function': [function],
         'symbol': [symbol.upper()],
         'interval': [interval],
         'config': None,
         'get_all': False,
         'force_update': False,
         'no_return': False,
         'data_status': False,
         'get_symbols': False,
         'no_api': no_api})
Beispiel #5
0
def get_data_status(n_clicks):
    """Get the data from main
    """
    if (n_clicks == 0):
        return pd.DataFrame(
            columns=['symbol', 'function', 'interval', 'datetime'])

    return main({
        'function': None,
        'symbol': None,
        'interval': None,
        'config': None,
        'force_update': False,
        'get_symbols': None,
        'data_status': True,
        'no_api': False
    }).sort_values('symbol')
    def setUp(self):
        self.tmpfilename = "tmpfile.txt"
        self.tmpfilepath = os.path.join(tempfile.gettempdir(), self.tmpfilename)
        with open(self.tmpfilepath, "wb") as f:
            f.write("Upload me and delete me!")

        from src import main

        settings = {
            "pyramid.includes": ["pyramid_celery", "pyramid_redis_sessions", "pyramid_jinja2"],
            "jinja2.directories": "../templates",
            "redis.sessions.secret": "my_session_secret_for_testing_only",
            "redis.session.timeout": 30,
        }
        app = main({"__file__": "development.ini"}, **settings)

        self.testapp = TestApp(app)
    def setUp(self):
        self.tmpfilename = "tmpfile.txt"
        self.tmpfilepath = os.path.join(tempfile.gettempdir(),
                                        self.tmpfilename)
        with open(self.tmpfilepath, "w") as f:
            f.write("Upload me and delete me!")

        from src import main
        settings = {
            'pyramid.includes': ['pyramid_redis_sessions', 'pyramid_jinja2'],
            'jinja2.directories': "../templates",
            'redis.sessions.secret': 'my_session_secret_for_testing_only',
            'redis.session.timeout': 30
        }
        app = main({'__file__': 'development.ini'}, **settings)

        self.testapp = TestApp(app)
Beispiel #8
0
def get_market_symbols(n_clicks, refresh, view_tracked_only=False):
    """Get the data from main
    """
    if (n_clicks == 0):
        return pd.DataFrame(columns=COLS)

    return main({
        'function': None,
        'symbol': None,
        'interval': None,
        'config': None,
        'get_all': None,
        'get_symbols': True,
        'refresh': refresh,
        'no_return': None,
        'data_status': None,
        'only_tracked': view_tracked_only
    })
Beispiel #9
0
    def get_tracked_symbol_by_function(n_clicks, function):
        """Return true if the function is intraday, else false
        """
        if n_clicks == 0:
            return None

        df = main({
            'function': None,
            'symbol': None,
            'interval': None,
            'config': None,
            'get_all': False,
            'no_return': False,
            'force_update': False,
            'data_status': True,
            'get_symbols': False,
            'refresh': False,
            'no_api': True
        })

        df = df.loc[df['function'] == FUNCTION_LOOKUP[function], :]
        if function >= 4:
            df = df.loc[df['interval'] == INTERVAL_LOOKUP[function], :]
        return ' '.join(sorted(list(df['symbol'].values)))
Beispiel #10
0
#!usr/bin/python
# -*- coding: utf-8 -*-
# Coded by mrb-in and MikhailKhromov

# checking if the python version is 2.7.x
import sys
if not (sys.version_info.major == 2 and sys.version_info.minor == 7):
    exit(
        '%s[Critical] %sPython version you are using is not 2.7, install the right one. ("pkg install python2" if you are on termux).'
        % ('\033[1;31m', '\033[1;37m'))

# checking if user installed all reqiured libs
try:
    import requests, mechanize, bs4
except ImportError:
    exit(
        '%s[Critical] %sInstall reqiured libs or program won\'t work (pip2 install requests mechanize bs4)'
        % ('\033[1;31m', '\033[1;37m'))

# starting program
import src
try:
    src.main()
except KeyboardInterrupt:
    exit("%s[Critical] %sKey interrupt" % ('\033[1;31m', '\033[1;37m'))
except Exception as e:
    exit("%s[Critical] %sThis error (please contact developers): " %
         ('\033[1;31m', '\033[1;37m') + str(e))

print("%s[!] Done%s" % ('\033[1;34m', '\033[1;37m'))
def test_read_lines():
    link = "http://claritytrec.ucd.ie/~alawlor/comp30670/input_assign3.txt"
    read_file(link)
    buffer = main().buffer
    eq_((type(buffer) is str),True,"Error")
Beispiel #12
0
from src import main


if __name__ == "__main__":
    main('src/data.json')
Beispiel #13
0
  # task_list = ["cola", "mnli", "mrpc", "sst-2",
  #               "sts-b", "qqp", "qnli", "rte", "wnli"]
  task_list = ["cola", ]
  data_dir = './data/glue_data/'
  output_dir = "./result/output/"
  cache_dir = "./result/cache/"
  log_dir = "./result/log/"

  # bert-base
  bert_vocab_file = "/Data/wuhaiming/data/bert_pretrain_base_cased/vocab.txt"
  bert_model_dir = "/Data/wuhaiming/data/bert_pretrain_base_cased"

  if model_name == "FPNLU":
    from src.FPNLU import args
  elif model_name == "BertOrigin":
    from src.BertOrigin import args
  elif model_name == "BertATT":
        from src.BertATT import args
  elif model_name == "FPNLUs":
    from src.FPNLUs import args

  config = args.get_args(data_dir, output_dir, cache_dir,
                          bert_vocab_file, bert_model_dir, log_dir)
  
  config.task_list = task_list

  # train
  config.do_train = True

  main(config, config.save_name)
Beispiel #14
0
# from flask import Flask, request
# import requests
# app = Flask(__name__)
# scrapping_url = "https://embed.ly/docs/explore/extract?url="
# apikey = "1934f519a63e142e0d3c893e59cc37fe0172e98a"

# @app.route('/result', methods = ['GET', 'POST'])
# def result():
#     if request.method == 'GET':
#         url = request.args.get('url', None)
#         print(request.args)
#         if url:
#             print("here",url)
#             r = requests.get(url)
#             return r.text
#         return "No url information is given"

# if __name__ == '__main__':
#     app.run(debug = True)
import src

app = src.main()

if __name__ == '__main__':
    app.run(host="127.0.0.1")
Beispiel #15
0
from src import main

app = main()
app.debug = True
app.run(host='0.0.0.0')
Beispiel #16
0
    # New Output
    testfile = open('output/' + targets[0] + 'data.txt', 'a')
    testfile.write('Data: ' + targets[0] + '| Epochs: ' + str(targets[1]) +
                   '| Normalize A: ' + str(targets[2]) + '| Learning Rate: ' +
                   str(targets[3]) + '\n')

    print('Targets: ', targets)

    src.main.GCN_Train_Tester(data=targets[0],
                              epoch=targets[1],
                              norm=targets[2],
                              lr=targets[3],
                              output_path=testfile)

    src.main.GCN_LPA_Train_Tester(data=targets[0],
                                  epoch=targets[1],
                                  norm=targets[2],
                                  lr=targets[3],
                                  output_path=testfile)

    src.main.GS_Train_Tester(data=targets[0],
                             epoch=targets[1],
                             norm=targets[2],
                             lr=targets[3],
                             output_path=testfile)


if __name__ == '__main__':
    targets = sys.argv[1:]
    main(targets)
Beispiel #17
0
from src import main;

main();
Beispiel #18
0
def test_ini_checkpoint():
    population, logbook = src.main(checkpoint="checkpoint_name.pkl", FREQ=1)
    assert (logbook[-1]['gen']) == 2
Beispiel #19
0
from src import main

run = True
while run:
    run = main()
Beispiel #20
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''A todolist manager.'''

# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

from sys import argv as _argv
# begin modules imports
from src.main import *
# end modules imports

__author__ = 'Louis Royer'
__credits__ = '🅬 2018, Louis Royer - CC0-1.0'
__date__ = '2018-09-15'
__version__ = '0.0.1'

try:
    main(_argv[1] + ' ' + _argv[2])
except IndexError:
    try:
        main(_argv[1])
    except IndexError:
        main()
Beispiel #21
0
try:
    import setproctitle
except ImportError:
    pass
else:
    project = src.settings.project
    setproctitle.setproctitle('python' + ':' + project.name + ':' + project.version)


def echo_duration():
    origin = datetime.datetime.utcnow()

    def wrapper():
        duration = datetime.datetime.utcnow() - origin
        days = duration.days
        hours = int(duration.seconds / 3600)
        minutes = int((duration.seconds - 3600 * hours) / 60)
        seconds = int(duration.seconds - 3600 * hours - minutes * 60)
        msg = 'Shut Down.The program takes {days}D {hours}H {minutes}M {seconds}S'
        src.log.info(msg.format(days=days, hours=hours, minutes=minutes, seconds=seconds))

    return wrapper

atexit.register(echo_duration())

if __name__ == '__main__':
    try:
        sys.exit(src.main())
    except KeyboardInterrupt:
        sys.exit()
Beispiel #22
0
def main_handler(event: Dict, context: Dict):
    is_cloud_function = os.environ.get("TENCENTCLOUD_RUNENV") is not None
    return main(not is_cloud_function)
Beispiel #23
0
        uuid = uuid[:8]
        target.addChildTarget(PrepareData(paths, ilp_config, uuid, query_string))


def main():
    parser = build_parser()
    Stack.addJobTreeOptions(parser)
    args = parser.parse_args()
    setLoggingFromOptions(args)

    ilp_config = ilp_tuple(args.breakpoint_penalty, args.data_penalty, args.expected_value_penalty, args.trash_penalty,
                           args.kmer_size)
    paths = paths_tuple(args.out_dir, args.aln_index, args.whitelist, args.masked_ref, args.unmasked_ref,
                        args.bad_kmers, args.normalizing, args.key_file)
    try:
        cgquery_dict = pickle.load(open(args.cgquery_file))
    except IOError:
        raise IOError("Cgquery dict does not exist.")

    if not os.path.exists(paths.out_dir):
        os.makedirs(paths.out_dir)

    i = Stack(Target.makeTargetFn(build_analyses, args=(paths, ilp_config, cgquery_dict))).startJobTree(args)

    if i != 0:
        raise RuntimeError("Got failed jobs")

if __name__ == "__main__":
    from src.main import *
    main()
Beispiel #24
0
 def test_arrow(self, inpDir, outDir):
     main(inpDir, self.convert.filePattern.arrow, outDir)
     self.assertTrue(self.fileExists(outDir))
Beispiel #25
0
 def test_parquet(self, inpDir, outDir):
     main(inpDir, self.convert.filePattern.parquet, outDir)
     self.assertTrue(self.fileExists(outDir))
Beispiel #26
0
Datei: rpm.py Projekt: le717/rpm
#! /usr/bin/env python3
# -*- coding: utf-8 -*
"""rpm - LEGO Racers package manager.

Created 2015-2018 Caleb Ely
<https://CodeTri.net/>

Licensed under The MIT License
<http://opensource.org/licenses/MIT/>

"""


if __name__ == "__main__":
    import src
    src.main()
Beispiel #27
0
from src import main

main()
Beispiel #28
0
import os
import sys
root = os.path.dirname(os.path.realpath(__file__))
import src

if __name__ == '__main__':
    src.main(root)
Beispiel #29
0
from src import ModelOptions, main

options = ModelOptions().parse()
options.mode = 2
main(options)
Beispiel #30
0
 def test_hdf5(self, inpDir, outDir):
     main(inpDir, self.convert.filePattern.hdf5, outDir)
     self.assertTrue(self.fileExists(outDir))