Skip to content

Commit e3f9773

Browse files
authored
Merge pull request #151 from NYU-RTS/xdmod-usage-fix
xdmod usage fix
2 parents 84b4a6e + 25c7e3f commit e3f9773

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

Containerfile.debugpy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ EXPOSE 5678
2828
RUN echo "yes" | uv run manage.py initial_setup
2929
RUN uv run manage.py load_test_data
3030

31-
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"]
31+
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"]

coldfront/core/allocation/templates/allocation/allocation_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

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

1010
<!-- Skeleton -->

coldfront/plugins/xdmod/utils.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77

88
logger = logging.getLogger(__name__)
99

10+
1011
class XDMoDConnectivityError(Exception):
1112
pass
1213

14+
1315
class XDMoDFetchError(Exception):
1416
pass
1517

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

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

62+
5863
def check_connectivity(url: str, timeout: float = 5.0) -> None:
5964
from urllib.parse import urlparse
6065
import requests
@@ -72,22 +77,15 @@ def check_connectivity(url: str, timeout: float = 5.0) -> None:
7277
except requests.exceptions.RequestException as e:
7378
raise XDMoDConnectivityError(str(e)) from e
7479

80+
7581
def get_usage_data(_metric: str, _slurm_acccount_name: str):
7682
logger.info(
77-
f"attempting to fetch usage \
83+
f"attempting to fetch {_metric} data \
7884
associated with {_slurm_acccount_name}"
7985
)
8086
try:
8187
check_connectivity(XDMOD_API_URL)
82-
dw = DataWarehouse(XDMOD_API_URL)
83-
with dw:
84-
data = fetch_xdmod_with_timeout(
85-
XDMOD_API_URL,
86-
metric=_metric,
87-
account=_slurm_acccount_name,
88-
timeout_s=15.0
89-
)
90-
return data
88+
return fetch_xdmod_with_timeout(XDMOD_API_URL, metric=_metric, account=_slurm_acccount_name, timeout_s=15.0)
9189
except XDMoDConnectivityError as e:
9290
logger.error("XDMOD connectivity error: %s", e)
9391
raise XDMoDConnectivityError(str(e)) from e

0 commit comments

Comments
 (0)