import os
import logging
from dask.distributed import Client
from dask_jobqueue import SLURMCluster
try:
project = os.environ['SLURM_JOB_ACCOUNT']
except KeyError:
logging.error("SLURM_JOB_ACCOUNT is not set in the active environment. Are you on the login node? You should not be running this there.")
raise
cluster = SLURMCluster(
account='hytest',
processes=1,
cores=1,
memory='8GB',
interface='ib0',
walltime='01:00:00',
shared_temp_directory='/home/asnyder/tmp'
)
cluster.adapt(minimum=2, maximum=30)
client = Client(cluster)
if os.environ['SLURM_CLUSTER_NAME']=='hovenweep':
ood_pre = 'hw'
elif os.environ['SLURM_CLUSTER_NAME']=='tallgrass':
ood_pre = 'tg'
ood_dashboard_link = f"https://{ood_pre}-ood.cr.usgs.gov/node/{os.environ['JUPYTER_SERVER_NODE']}/{os.environ['JUPYTER_SERVER_PORT']}/proxy/{client.dashboard_link.split(':')[2]}"
print(f'Dask Dashboard for OnDemand is available at: {ood_dashboard_link}')