Skip to content

Commit a6b1428

Browse files
Cleanup, logging, python version upgrage for docker, exception handling
1 parent 6267df8 commit a6b1428

5 files changed

Lines changed: 19 additions & 6 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-slim
1+
FROM python:3.13-slim
22

33
WORKDIR /app
44

app/services/epmc_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
import logging
12
import requests
23
import pandas as pd
34
import json
45
import app.constants.api as api_constants
56

7+
logger = logging.getLogger(__name__)
8+
69

710
def get_json(endpoint):
811
"""
912
Generic GET → JSON helper (same as pypi_client.get_json).
1013
"""
11-
print(f"Calling API: {endpoint}")
14+
logger.debug("Calling API: %s", endpoint)
1215
resp = requests.get(endpoint, timeout=30)
1316
resp.raise_for_status()
1417
return resp.json()
@@ -25,7 +28,7 @@ def get_all_paginated(endpoint, limit=1000):
2528

2629
while True:
2730
params = {"limit": limit, "skip": skip}
28-
print(f"Calling API: {endpoint} params={params}")
31+
logger.debug("Calling API: %s params=%s", endpoint, params)
2932
resp = requests.get(endpoint, params=params, timeout=30)
3033
resp.raise_for_status()
3134
data = resp.json()

app/services/github_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import requests
23
import pandas as pd
34
import numpy as np
@@ -6,13 +7,15 @@
67

78
import app.constants.api as api_constants
89

10+
logger = logging.getLogger(__name__)
11+
912

1013
def get_json(endpoint: str, token: Optional[str] = None):
1114
headers = {}
1215
if token:
1316
headers["Authorization"] = f"token {token}"
1417

15-
print(f"Calling API: {endpoint}")
18+
logger.debug("Calling API: %s", endpoint)
1619
resp = requests.get(endpoint, headers=headers, timeout=30)
1720
resp.raise_for_status()
1821
return resp.json()

app/services/pypi_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import logging
12
import requests
23
import app.constants.api as api_constants
34
import pandas as pd
45

6+
logger = logging.getLogger(__name__)
7+
8+
59
def get_json(endpoint):
610
"""
711
Function to get JSON response from API for get_json
@@ -10,7 +14,7 @@ def get_json(endpoint):
1014
Returns:
1115
dict: JSON response from the API
1216
"""
13-
print(f"Calling API: {endpoint}")
17+
logger.debug("Calling API: %s", endpoint)
1418
resp = requests.get(endpoint, timeout=30)
1519
resp.raise_for_status()
1620
return resp.json()

app/services/service_map_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import logging
12
import requests
23
import pandas as pd
34
from typing import Optional
45

6+
logger = logging.getLogger(__name__)
7+
58
BASE_URL = "https://implementation-registry.ga4gh.org/api"
69
STANDARDS_ENDPOINT = f"{BASE_URL}/standards"
710
SERVICES_ENDPOINT = f"{BASE_URL}/services"
@@ -12,7 +15,7 @@ def get_json(endpoint: str, token: Optional[str] = None):
1215
if token:
1316
headers["Authorization"] = f"token {token}"
1417

15-
print(f"Calling API: {endpoint}")
18+
logger.debug("Calling API: %s", endpoint)
1619
resp = requests.get(endpoint, headers=headers, timeout=30)
1720
resp.raise_for_status()
1821
return resp.json()

0 commit comments

Comments
 (0)