Exemplo n.º 1
0
def get_config(num_features, num_epochs, debug=False):
    """ Retrieve model configurations from config.py """

    if debug:
        return c.TestConfig(num_features, num_epochs)
    else:
        return c.ProductionConfig(num_features, num_epochs)
Exemplo n.º 2
0
def get_configuration():
    if os.environ['ENVIRON'] == config.Environments.DEVELOPMENT.name:
        return config.DevelopmentConfig()
    elif os.environ['ENVIRON'] == config.Environments.PRODUCTION.name:
        return config.ProductionConfig()
    else:
        raise EnvironmentError('Unknown Environment')
Exemplo n.º 3
0
    def __init__(self, environment="dev"):
        super().__init__()
        reload(config)

        if environment == 'dev':
            self.config = config.DevelopmentConfig()
        elif environment == 'prod':
            self.config = config.ProductionConfig()

        if self.config.DISCORD_BOT_KEY:
            if self.config.DISCORD_BOT_KEY.endswith("TOKEN_GOES_HERE"):
                raise exception.HoloError(
                    "Bot key not updated from default value.")
            else:
                self.bot_token = self.config.DISCORD_BOT_KEY
        else:
            raise exception.HoloError(
                "Bot key blank or missing from configuration file.")

        self._logger = logging.getLogger('HoloPearl')
        log_handler = logging.StreamHandler()
        log_handler.setFormatter(
            logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
        self._logger.addHandler(log_handler)
        self._logger.setLevel(self.config.LOG_LEVEL)
        self.next_anime_host = None
        self.next_anime_date = None
Exemplo n.º 4
0
def info():
    environ = os.getenv('FLASK_CONFIG')
    server = os.getenv('SQL_SERVER_NAME')
    conn = config.ProductionConfig().connection_string
    info = 'config type = ' + environ \
        + '<br />sql_server_name = ' + server \
        + '<br />connection = ' + conn
    return info
Exemplo n.º 5
0
def create_app():
    try:
        cfg = config.ProductionConfig() if os.environ.get('ENV') == 'prod' else config.DevelopmentConfig()
    except KeyringError as e:
        print(e)
        quit(1)

    if all([cfg.MAIL_USERNAME, cfg.MAIL_PASSWORD, cfg.RECIPIENT]):
        app = Flask(__name__)
        app.config.from_object(cfg)
        return app
    else:
        print("Configure python-keyring variables MAIL_USER, MAIL_PASSWORD and RECIPIENT for 'scheduled_mail' service")
        quit(1)
Exemplo n.º 6
0
import authentication
import config

app = Flask(__name__, )

APP_ROOT = os.path.dirname(os.path.abspath(__file__))
UPLOAD_FOLDER = os.path.join(APP_ROOT, "files")
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER

# Load config
devEnvironment = os.environ.get('FLASK_ENV')
print("FLASK_ENV = ", devEnvironment)
if devEnvironment == "development":
    app.config.from_object(config.DevelopmentConfig())
elif devEnvironment == "production":
    app.config.from_object(config.ProductionConfig())


@app.route('/')
def hello_world():
    return render_template("home.html")


@app.route("/home")
def home_handler():
    return render_template("home.html")


@app.route("/signup", methods=['GET', 'POST'])
def signup():
    if request.method == "POST":
Exemplo n.º 7
0
def get_config(num_features, num_epochs, debug=False):
    return c.ProductionConfig(num_features,
                              num_epochs) if not debug else c.TestConfig(
                                  num_features, num_epochs)
Exemplo n.º 8
0
from flask import Flask, request
from os import environ, urandom
import config

app = Flask(__name__)
environment = environ.get("FLASK_ENV", default="development")
if environment == "development":
    cfg = config.DevelopmentConfig()
elif environment == "production":
    cfg = config.ProductionConfig()
app.config.from_object(cfg)
# API functions


@app.route('/', methods=['GET'])
def helloworld():
    return "<h1>Hello World</h1>", 200


if __name__ == "__main__":
    app.run(host='0.0.0.0')
Exemplo n.º 9
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""Downloads annotations in MySQL table format (as mysql user). """
import os
import sys
import pwd
import argparse

import config
import gwips_tools

# path to the configuration file
CONFIG = config.ProductionConfig()

if __name__ == '__main__':
    log = gwips_tools.setup_logging(CONFIG, file_name='annotations.log')

    gwips_tools.check_config_json(CONFIG.CONFIG_FILE)
    usage = """Update annotations for genomes on GWIPS.

        To list available genomes, do:

            python update_annotations.py -l

        To update all annotations, do:

            sudo python update_annotations.py -a

        [OR]

        To update annotation for a specific genome, do:
Exemplo n.º 10
0
import os

from dotenv import load_dotenv

import config
from dnsviz_api.app import create_app

load_dotenv()

if os.getenv('FLASK_ENV') == "development":
    app_config = config.DevelopmentConfig()
else:
    app_config = config.ProductionConfig()

app = create_app(app_config)

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=int(os.getenv("PORT", 5000)))
Exemplo n.º 11
0
from os import environ

import config
from server import create_app

if 'FLASK_ENV' not in environ or environ['FLASK_ENV'] == 'development':
    config_obj = config.DevelopmentConfig()
elif environ['FLASK_ENV'] == 'production':
    config_obj = config.ProductionConfig()
elif environ['FLASK_ENV'] == 'testing':
    config_obj = config.TestingConfig()
else:
    raise ValueError("Unknown FLASK_ENV")

app = create_app(config_obj)
Exemplo n.º 12
0
    return '<p>Hello %s!</p>\n' % username


# some bits of text for the page.
header_text = '''
    <html>\n<head> <title>EB Flask Test</title> </head>\n<body>'''
instructions = '''
    <p><em>Hint</em>: This is a RESTful web service! Append a username
    to the URL (for example: <code>/Thelonious</code>) to say hello to
    someone specific.</p>\n'''
home_link = '<p><a href="/">Back</a></p>\n'
footer_text = '</body>\n</html>'

# EB looks for an 'application' callable by default.
application = Flask(__name__)
application.config.from_object(config.ProductionConfig())
CORS(application)
engine = create_engine(URL(**application.config['DATABASE']))

# add a rule for the index page.
application.add_url_rule(
    '/', 'index',
    (lambda: header_text + say_hello() + instructions + footer_text))

# add a rule when the page is accessed with a name appended to the site
# URL.
application.add_url_rule('/<username>', 'hello',
                         (lambda username: header_text + say_hello(username) +
                          home_link + footer_text))

Exemplo n.º 13
0
            logger.setLevel(level=logging.INFO)
    return logger


if __name__ == '__main__':

    ENV = os.getenv('ENV', None)
    TF_LOGGER = setup_logger('tensorflow', False)
    LOGGER = setup_logger()
    APP = App()
    if ENV is None:
        LOGGER.info(
            "Environment variable 'ENV' not set, returning development configs."
        )
        ENV = 'DEV'
    if ENV == 'DEV':
        APP.config = config.DevelopmentConfig(LOGGER, ENV)
    elif ENV == 'TEST':
        APP.config = config.TestConfig(LOGGER, ENV)
    elif ENV == 'PROD':
        APP.config = config.ProductionConfig(LOGGER, ENV)
    else:
        raise ValueError('Invalid environment name')
    APP.ci_config = config.CIConfig
    OUTPUT_DIR = '/home/frans/Documents/tsprediction/model'
    LOGGER.info('Cleanning ouput directory')
    shutil.rmtree(OUTPUT_DIR, ignore_errors=True)  # start fresh each time

    LOGGER.info('Outpout directory clean')
    APP.experiment_fn(OUTPUT_DIR)