CoolFace
Apppublic

Arts-of-coding/testazurectrl

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
main.py78 linesDownload Raw Back to root
1import uvicorn2from fastapi import FastAPI3from fastapi.middleware.wsgi import WSGIMiddleware4from dash_plotly_QC_scRNA import app as dashboard15#from app2 import app as dashboard26 7#########################################################8import dash9from dash import dcc, html, Output, Input10import plotly.express as px11import dash_callback_chain12import yaml13import polars as pl14import os15pl.enable_string_cache(False)16 17config_fig = {18  'toImageButtonOptions': {19    'format': 'svg',20    'filename': 'custom_image',21    'height': 600,22    'width': 700,23    'scale': 1,24  }25}26from adlfs import AzureBlobFileSystem27mountpount=os.environ['AZURE_MOUNT_POINT'],28AZURE_STORAGE_ACCESS_KEY=os.getenv('AZURE_STORAGE_ACCESS_KEY')29AZURE_STORAGE_ACCOUNT=os.getenv('AZURE_STORAGE_ACCOUNT')30 31# Load in config file32config_path = "./data/config.yaml"33 34# Add the read-in data from the yaml file35def read_config(filename):36    with open(filename, 'r') as yaml_file:37        config = yaml.safe_load(yaml_file)38    return config39 40config = read_config(config_path)41path_parquet = config.get("path_parquet")42conditions = config.get("conditions")43col_features = config.get("col_features")44col_counts = config.get("col_counts")45col_mt = config.get("col_mt")46 47filepath = f"az://{path_parquet}"48 49storage_options={'account_name': AZURE_STORAGE_ACCOUNT, 'account_key': AZURE_STORAGE_ACCESS_KEY,'anon': False}50#azfs = AzureBlobFileSystem(**storage_options )51 52df = pl.read_parquet(filepath,storage_options=storage_options)53#abfs = AzureBlobFileSystem(account_name=accountname,account_key=accountkey)54 55# Setup the app56external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']57 58######################################################################59# Define the FastAPI server60# Mount the Dash app as a sub-application in the FastAPI server61#app.mount("/dashboard2", WSGIMiddleware(dashboard2.server))62 63app = FastAPI()64 65@app.get("/")66async def root():67    return {"message": "Hello World"}68 69app.mount("/dashboard1", WSGIMiddleware(dashboard1.server))70# Added the following lines to demonstrate the usage of the /dashboard1 endpoint71@app.get("/dashboard1")72def serve_dashboard1():73    # Return an index.html file as response content74    return HTMLResponse(open('static/index.html', 'r').read())75 76# Start the FastAPI server77if __name__ == "__main__":78    uvicorn.run(dashboard1, host="0.0.0.0", port=5000)