File size: 2,433 Bytes
56dc3ca
 
 
 
 
 
 
 
 
 
 
 
 
411395e
56dc3ca
 
 
 
 
 
 
 
 
 
 
 
 
901b6e3
 
5d0c8c3
 
901b6e3
33272b7
3fed58d
d732146
e772d53
3fed58d
 
901b6e3
06c672d
 
56dc3ca
 
06c672d
 
 
 
901b6e3
06c672d
901b6e3
06c672d
 
 
 
56dc3ca
 
 
 
 
 
 
 
 
 
e567830
33821ef
 
 
 
 
1f94bf5
 
 
 
 
 
 
56dc3ca
 
4375951
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.wsgi import WSGIMiddleware
from dash_plotly_QC_scRNA import app as dashboard1
#from app2 import app as dashboard2

#########################################################
import dash
from dash import dcc, html, Output, Input
import plotly.express as px
import dash_callback_chain
import yaml
import polars as pl
import os
pl.enable_string_cache(False)

# Set custom resolution for plots:
config_fig = {
  'toImageButtonOptions': {
    'format': 'svg',
    'filename': 'custom_image',
    'height': 600,
    'width': 700,
    'scale': 1,
  }
}

from adlfs import AzureBlobFileSystem
mountpount=os.environ['AZURE_MOUNT_POINT'],
AZURE_STORAGE_ACCESS_KEY=os.getenv('AZURE_STORAGE_ACCESS_KEY')
AZURE_STORAGE_ACCOUNT=os.getenv('AZURE_STORAGE_ACCOUNT')

filepath = 'az://dataliu/sc_liu_umap_clusres_ctrl_03102023.parquet'

storage_options={'account_name': AZURE_STORAGE_ACCOUNT, 'account_key': AZURE_STORAGE_ACCESS_KEY,'anon': False}
#azfs = AzureBlobFileSystem(**storage_options )

df = pl.read_parquet(filepath,storage_options=storage_options)

# Load in config file
config_path = "./data/config.yaml"

# Add the read-in data from the yaml file
def read_config(filename):
    with open(filename, 'r') as yaml_file:
        config = yaml.safe_load(yaml_file)
    return config

config = read_config(config_path)
#path_parquet = config.get("path_parquet")
conditions = config.get("conditions")
col_features = config.get("col_features")
col_counts = config.get("col_counts")
col_mt = config.get("col_mt")
#df = df.rename({"__index_level_0__": "Unnamed: 0"})

# Setup the app
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

######################################################################
# Define the FastAPI server
# Mount the Dash app as a sub-application in the FastAPI server
#app.mount("/dashboard2", WSGIMiddleware(dashboard2.server))

app = FastAPI()

@app.get("/")
async def root():
    return {"message": "Hello World"}

app.mount("/dashboard1", WSGIMiddleware(dashboard1.server))
# Added the following lines to demonstrate the usage of the /dashboard1 endpoint
@app.get("/dashboard1")
def serve_dashboard1():
    # Return an index.html file as response content
    return HTMLResponse(open('static/index.html', 'r').read())

# Start the FastAPI server
if __name__ == "__main__":
    uvicorn.run(dashboard1, host="0.0.0.0", port=5000)