## Proxy Web Apps You can host many web applications by running them on the command line and then accessing them through the jupyter-proxy plugin. Underneath the hood we are using the [Jupyterhub Proxy Plugin](https://jupyter-server-proxy.readthedocs.io/en/latest/arbitrary-ports-hosts.html) in order to access web applications through jupyterhub. Before we start you'll need your: 1. Jupyterhub URL - copy and paste this from the browser 2. The service prefix, if any 3. Your username ``` env |grep JUPYTERHUB_SERVICE_PREFIX env |grep JUPYTERHUB_BASE_URL ``` ### Proxy URLs The official [docs](https://jupyter-server-proxy.readthedocs.io/en/latest/arbitrary-ports-hosts.html). Many docs are embedded directly from the source docs. ### Starting and Proxying Processes [Starting and Proxying Processes](https://jupyter-server-proxy.readthedocs.io/en/latest/server-process.html) ### Accessing Arbitrary Ports [Accessing Arbitrary Ports](https://jupyter-server-proxy.readthedocs.io/en/latest/arbitrary-ports-hosts.html) ### More Examples Typically, you can grab the url from your browser. For example, the URL for this browser is: ``` https://jhub1.bioanalyzedev.io/user/jillian/lab/tree/bioanalyze-hpc/docs/web-apps/proxy-web-apps.md ``` The base jupyterhub url is: ``` https://jhub1.bioanalyzedev.io/user/jillian/ ``` The proxy path is: ``` https://jhub1.bioanalyzedev.io/user/jillian/proxy/${PORT}/ ``` ### Gotchas You always want to make sure that you're serving your application from `0.0.0.0`, *not* localhost. Usually this option is available through the CLI to run the program either as `--host` or `--ip`. ### Example - ExCellxGene Let's proxy the ExCellxGene in Jupyterhub. Excellxgene needs to be installed to it's own conda environment because it doesn't play nice with the existing conda env. * Grab the `excellxgene-environment.yaml` from this repo. * Create the excellxgene environment * Register the excellxgene environment as a Python Kernel. ```bash git clone https://github.com/dabble-of-devops-bioanalyze/single-cell-saturn-cloud git clone https://github.com/scverse/scanpy-tutorials cd single-cell-saturn-cloud mamba env create -f ./excellxgene-environment.yaml -p ~/.conda/envs/excellxgene source activate conda activate excellxgene ``` If you are running on a local system or [BioAnalyze HPC](https://hpc.bioanalyze.io) I recommend using [these](https://hpc.bioanalyze.io/software/install-software.html) settings. Now that we have some data let's visualize some clusters! ```bash git clone https://github.com/czbiohub/excellxgene cd excellxgene cd example-dataset wget https://raw.githubusercontent.com/dabble-of-devops-bioanalyze/single-cell-saturn-cloud/main/prepare.py source activate excellxgene python ./prepare.py pbmc3k.h5ad --output ./pbmc3k-preprocessed.h5ad --overwrite ``` ### Launch the ExCellxGene Web App ```bash excellxgene launch --host 0.0.0.0 --port 8000 ./pbmc3k-preprocessed.h5ad ``` The proxy path is: ``` https://{JHUB_URL}/user/${USERNAME}/proxy/${PORT}/ ```