How to use the gear.setup_aiohttp_session function in gear

To help you get started, we’ve selected a few gear examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hail-is / hail / apiserver / apiserver / apiserver.py View on Github external
import os
import uvloop
from aiohttp import web
import hail as hl
from hail.utils import FatalError
from hail.utils.java import Env, info, scala_object
from hailtop.auth import rest_authenticated_users_only
from gear import setup_aiohttp_session

uvloop.install()

master = os.environ.get('HAIL_APISERVER_SPARK_MASTER')
hl.init(master=master, min_block_size=0)

app = web.Application()
setup_aiohttp_session(app)

routes = web.RouteTableDef()


def status_response(status):
    return web.Response(status=status)


executor = concurrent.futures.ThreadPoolExecutor(max_workers=16)


async def run(f, *args):
    loop = asyncio.get_event_loop()
    return await loop.run_in_executor(executor, f, *args)
github hail-is / hail / ci / ci / ci.py View on Github external
def run():
    app = web.Application()
    setup_aiohttp_jinja2(app, 'ci')
    setup_aiohttp_session(app)

    app.on_startup.append(on_startup)
    app.on_cleanup.append(on_cleanup)

    setup_common_static_routes(routes)
    app.add_routes(routes)

    web.run_app(deploy_config.prefix_application(app, 'ci'), host='0.0.0.0', port=5000)
github hail-is / hail / auth / auth / auth.py View on Github external
def run():
    app = web.Application()

    setup_aiohttp_jinja2(app, 'auth')
    setup_aiohttp_session(app)

    setup_common_static_routes(routes)
    app.add_routes(routes)
    app.on_startup.append(on_startup)
    app.on_cleanup.append(on_cleanup)

    web.run_app(deploy_config.prefix_application(app, 'auth'), host='0.0.0.0', port=5000)
github hail-is / hail / notebook / notebook / notebook.py View on Github external
def run():
    sass_compile('notebook')
    root = os.path.dirname(os.path.abspath(__file__))

    # notebook
    notebook_app = web.Application()

    notebook_app.on_startup.append(on_startup)

    setup_aiohttp_jinja2(notebook_app, 'notebook')
    setup_aiohttp_session(notebook_app)

    routes.static('/static', f'{root}/static')
    setup_common_static_routes(routes)
    notebook_app.add_routes(routes)

    # workshop
    workshop_app = web.Application()

    workshop_app.on_startup.append(on_startup)

    setup_aiohttp_jinja2(workshop_app, 'notebook')
    setup_aiohttp_session(workshop_app)

    workshop_routes.static('/static', f'{root}/static')
    setup_common_static_routes(workshop_routes)
    workshop_app.add_routes(workshop_routes)
github hail-is / hail / batch / batch / front_end / front_end.py View on Github external
def run():
    app = web.Application(client_max_size=None)
    setup_aiohttp_session(app)

    setup_aiohttp_jinja2(app, 'batch.front_end')
    setup_common_static_routes(routes)
    app.add_routes(routes)
    app.router.add_get("/metrics", server_stats)

    app.on_startup.append(on_startup)
    app.on_cleanup.append(on_cleanup)

    web.run_app(deploy_config.prefix_application(app, 'batch'), host='0.0.0.0', port=5000)
github hail-is / hail / notebook2 / notebook / notebook.py View on Github external
def run():
    app = web.Application()

    setup_aiohttp_jinja2(app, 'notebook')
    setup_aiohttp_session(app)

    sass_compile('notebook')
    root = os.path.dirname(os.path.abspath(__file__))
    routes.static('/static', f'{root}/static')
    setup_common_static_routes(routes)
    app.add_routes(routes)

    app.on_startup.append(on_startup)
    web.run_app(deploy_config.prefix_application(app, 'notebook2'), host='0.0.0.0', port=5000)
github hail-is / hail / batch / batch / batch.py View on Github external
log.info(f'BATCH_IMAGE = {BATCH_IMAGE}')
log.info(f'MAX_PODS = {MAX_PODS}')
log.info(f'QUEUE_SIZE = {QUEUE_SIZE}')

deploy_config = get_deploy_config()

STORAGE_CLASS_NAME = 'batch'

if 'BATCH_USE_KUBE_CONFIG' in os.environ:
    kube.config.load_kube_config()
else:
    kube.config.load_incluster_config()
v1 = kube.client.CoreV1Api()

app = web.Application(client_max_size=None)
setup_aiohttp_session(app)

routes = web.RouteTableDef()

db = BatchDatabase.create_synchronous('/batch-user-secret/sql-config.json')

tasks = ('setup', 'main', 'cleanup')


def abort(code, reason=None):
    if code == 400:
        raise web.HTTPBadRequest(reason=reason)
    if code == 404:
        raise web.HTTPNotFound(reason=reason)
    raise web.HTTPException(reason=reason)
github hail-is / hail / scorecard / scorecard / scorecard.py View on Github external
def run():
    app = web.Application()
    app.on_startup.append(on_startup)

    setup_aiohttp_jinja2(app, 'scorecard')
    setup_aiohttp_session(app)

    setup_common_static_routes(routes)

    app.add_routes(routes)

    web.run_app(deploy_config.prefix_application(app, 'scorecard'), host='0.0.0.0', port=5000)
github hail-is / hail / router-resolver / router_resolver / router_resolver.py View on Github external
from aiohttp import web
import aiohttp_session
from kubernetes_asyncio import client, config
import logging
from hailtop.config import get_deploy_config
from gear import configure_logging, setup_aiohttp_session

uvloop.install()

configure_logging()
log = logging.getLogger('router-resolver')

deploy_config = get_deploy_config()

app = web.Application()
setup_aiohttp_session(app)

routes = web.RouteTableDef()


@routes.get('/auth/{namespace}')
async def auth(request):
    app = request.app
    k8s_client = app['k8s_client']
    namespace = request.match_info['namespace']

    headers = {}
    if 'X-Hail-Internal-Authorization' in request.headers:
        headers['Authorization'] = request.headers['X-Hail-Internal-Authorization']
    elif 'Authorization' in request.headers:
        headers['Authorization'] = request.headers['Authorization']
    else:
github hail-is / hail / batch / batch / driver / main.py View on Github external
def run():
    app = web.Application()
    setup_aiohttp_session(app)

    setup_aiohttp_jinja2(app, 'batch.driver')
    setup_common_static_routes(routes)
    app.add_routes(routes)
    app.router.add_get("/metrics", server_stats)

    app.on_startup.append(on_startup)
    app.on_cleanup.append(on_cleanup)

    web.run_app(deploy_config.prefix_application(app, 'batch-driver'), host='0.0.0.0', port=5000)