@@ -20,7 +20,10 @@ dependencies:
2020 - htcondor
2121 - pip
2222 - pip :
23- - ncsa-htcdaskgateway>=1.0.2
23+ - ncsa-htcdaskgateway>=1.0.4
24+ - dask==2025.2.0
25+ - distributed==2025.2.0
26+ - tornado==6.4.2
2427` ` `
2528
2629From a Jupyter terminal window create the conda environment with:
@@ -30,6 +33,10 @@ conda env create -f conda.yaml
3033conda activate dask-gateway
3134```
3235
36+ _ Note:_ Depending on your conda setup, the ` conda activate ` command may not be
37+ available you can also activate the environment with the command
38+ ` source activate dask-gateway ` .
39+
3340Now you can use the ` setup_condor ` script to set up the HTCondor tools. This
3441will request your Illinois password and attempt to log into the HTCondor login
3542node and execute a command that generates a token file. This token file is used
4653condor_q
4754```
4855
56+ ## Use in Jupyter Notebook
57+
58+ In your Jupyter notebook first thing you need to do is activate the conda
59+ environment:
60+
61+ ``` shell
62+ ! source activate dask-gateway
63+ ```
64+
65+ Now you can pip install any additional dependencies. For objects that are sent
66+ to dask or received as return values, you must have the exact same versions.
67+
68+ ``` shell
69+ ! python -m pip install numpy==2.2.4
70+ ```
71+
72+ ### Providing Path to Condor Tools
73+
74+ There are some interesting interactions between conda and Jupyter. Conda has
75+ installed the condor binaries, but doesn't update PATH in the notebook kernel.
76+ We use an environment variable to tell the htcdaskgateway client how to find the
77+ binaries.
78+
79+ In a terminal window:
80+
81+ ``` shell
82+ source activate dask-gateway
83+ which condor_q
84+ ```
85+
86+ Back in your notebook:
87+
88+ ``` python
89+ import os
90+
91+ os.environ[" CONDOR_BIN_DIR" ] = " /home/myhome/.conda/envs/dask-gateway/bin"
92+ ```
93+
94+ ### Setting up a dotenv file
95+
96+ It is good practice to keep passwords out of your notebooks. Create a ` .env `
97+ file that contains an entry for ` DASK_GATEWAY_PASSWORD `
98+
99+ Add ` python-dotenv ` to your pip installed dependencies and add this line to your
100+ notebook:
101+
102+ ``` python
103+ from dotenv import load_dotenv
104+
105+ load_dotenv() # take environment variables from .env.
106+ ```
107+
108+ ### Connecting to the Gateway and Scaling up Cluster
109+
110+ Now we can finally start up a cluster!
111+
112+ ``` python
113+ from htcdaskgateway import HTCGateway
114+ from dask_gateway.auth import BasicAuth
115+ import os
116+
117+ gateway = HTCGateway(
118+ address = " https://dask.software-dev.ncsa.illinois.edu" ,
119+ proxy_address = 8786 ,
120+ auth = BasicAuth(username = None , password = os.environ[" DASK_GATEWAY_PASSWORD" ]),
121+ )
122+
123+ cluster = gateway.new_cluster(
124+ image = " ncsa/dask-public-health:latest" ,
125+ container_image = " /u/bengal1/condor/PublicHealth.sif" ,
126+ )
127+ cluster.scale(2 )
128+ client = cluster.get_client()
129+ client
130+ ```
131+
132+ This will display the URL to access the cluster dashboard
133+
49134## How it Works
50135
51136This is a drop-in replacement for the official Dask Gateway client. It keeps the
0 commit comments