Skip to content

Commit

Permalink
refactor: active endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnacioHeredia committed Nov 18, 2024
1 parent 2c6f2f8 commit d2805eb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ai4papi/nomad/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,13 @@ def get_deployment(
info['active_endpoints'] = []
for k, v in info['endpoints'].items():
try:
# We use GET and not HEAD, because HEAD is not returning the correct status_codes (even with "allow_redirects=True")
# Anyway, both latencies are almost the same when using "allow_redirects=True"
# * IDE deployed: GET (200), HEAD (405) | latency: ~90 ms
# * API not deployed: GET (502), HEAD (502) | latency: ~40 ms
# * Non existing domain: GET (404), HEAD (404) | latency: ~40 ms
r = session.get(v, timeout=2)
if r.status_code == 200:
if r.ok:
info['active_endpoints'].append(k)
except (requests.exceptions.Timeout, requests.exceptions.ConnectionError):
continue
Expand Down

0 comments on commit d2805eb

Please sign in to comment.