Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Containerfile.debugpy
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ EXPOSE 5678
RUN echo "yes" | uv run manage.py initial_setup
RUN uv run manage.py load_test_data

CMD ["uv", "run", "python3", "-m", "debugpy", "--listen", "0.0.0.0:5678", "-m", "gunicorn", "-w", "1", "--capture-output","--enable-stdio-inheritance", "coldfront.config.wsgi","--bind", "0.0.0.0:8000"]
CMD ["uv", "run", "python3", "-m", "debugpy", "--listen", "0.0.0.0:5678", "-m", "gunicorn", "-w", "1", "--capture-output","--enable-stdio-inheritance", "coldfront.config.wsgi","--bind", "0.0.0.0:8000", "--timeout", "0"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% block extra_head %}
<!-- Plotly & HTMX -->
<script defer src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="https://cdn.plot.ly/plotly-3.4.0.min.js" charset="utf-8"></script>
<script defer src="https://unpkg.com/htmx.org@2.0.0"></script>

<!-- Skeleton -->
Expand Down
18 changes: 8 additions & 10 deletions coldfront/plugins/xdmod/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@

logger = logging.getLogger(__name__)


class XDMoDConnectivityError(Exception):
pass


class XDMoDFetchError(Exception):
pass


def _worker(q: Queue, url: str, metric: str, account: str) -> None:
try:
# Construct inside the worker so we don't share sockets across processes
Expand All @@ -29,6 +32,7 @@ def _worker(q: Queue, url: str, metric: str, account: str) -> None:
# Send back a lightweight, picklable error payload
q.put(("err", (e.__class__.__name__, str(e))))


def fetch_xdmod_with_timeout(url: str, metric: str, account: str, timeout_s: float = 15.0):
q: Queue = Queue()
p = Process(target=_worker, args=(q, url, metric, account))
Expand All @@ -55,6 +59,7 @@ def fetch_xdmod_with_timeout(url: str, metric: str, account: str, timeout_s: flo
raise XDMoDConnectivityError(f"XDMoD get_data timeout: {exc_msg}")
raise XDMoDFetchError(f"XDMoD get_data error: {exc_name}: {exc_msg}")


def check_connectivity(url: str, timeout: float = 5.0) -> None:
from urllib.parse import urlparse
import requests
Expand All @@ -72,22 +77,15 @@ def check_connectivity(url: str, timeout: float = 5.0) -> None:
except requests.exceptions.RequestException as e:
raise XDMoDConnectivityError(str(e)) from e


def get_usage_data(_metric: str, _slurm_acccount_name: str):
logger.info(
f"attempting to fetch usage \
f"attempting to fetch {_metric} data \
associated with {_slurm_acccount_name}"
)
try:
check_connectivity(XDMOD_API_URL)
dw = DataWarehouse(XDMOD_API_URL)
with dw:
data = fetch_xdmod_with_timeout(
XDMOD_API_URL,
metric=_metric,
account=_slurm_acccount_name,
timeout_s=15.0
)
return data
return fetch_xdmod_with_timeout(XDMOD_API_URL, metric=_metric, account=_slurm_acccount_name, timeout_s=15.0)
except XDMoDConnectivityError as e:
logger.error("XDMOD connectivity error: %s", e)
raise XDMoDConnectivityError(str(e)) from e
Expand Down
Loading