|
4 | 4 |
|
5 | 5 | from azure.core.credentials import AccessToken |
6 | 6 | from azure.identity import ClientSecretCredential |
7 | | -from fastapi import APIRouter, Depends, Path, Query, status |
| 7 | +from fastapi import APIRouter, Path, Query, status |
8 | 8 | from fastapi_cache.decorator import cache |
9 | 9 | from httpx import AsyncClient |
10 | 10 |
|
11 | | -from aind_tars_service_server.configs import Settings, get_settings |
| 11 | +from aind_tars_service_server.configs import settings |
12 | 12 | from aind_tars_service_server.handler import SessionHandler |
13 | 13 | from aind_tars_service_server.models import ( |
14 | 14 | HealthCheck, |
@@ -39,13 +39,10 @@ async def get_health() -> HealthCheck: |
39 | 39 |
|
40 | 40 |
|
41 | 41 | @cache(expire=3500) |
42 | | -async def get_access_token(settings: Settings) -> str: |
| 42 | +async def get_access_token() -> str: |
43 | 43 | """ |
44 | 44 | Get access token from either Azure or cache. Token is valid for 60 minutes. |
45 | 45 | We set cache ttl to 3500 seconds. |
46 | | - Parameters |
47 | | - ---------- |
48 | | - settings : Settings |
49 | 46 |
|
50 | 47 | Returns |
51 | 48 | ------- |
@@ -100,13 +97,12 @@ async def get_viral_prep_lots( |
100 | 97 | } |
101 | 98 | }, |
102 | 99 | ), |
103 | | - settings: Settings = Depends(get_settings), |
104 | 100 | ): |
105 | 101 | """ |
106 | 102 | ## TARS Endpoint to retrieve viral prep lot data. |
107 | 103 | Retrieves viral prep lot information from TARS for a prep_lot_id. |
108 | 104 | """ |
109 | | - bearer_token = await get_access_token(settings=settings) |
| 105 | + bearer_token = await get_access_token() |
110 | 106 | headers = { |
111 | 107 | "Authorization": f"Bearer {bearer_token}", |
112 | 108 | "Content-Type": "application/json", |
@@ -169,12 +165,11 @@ async def get_molecules( |
169 | 165 | } |
170 | 166 | }, |
171 | 167 | ), |
172 | | - settings: Settings = Depends(get_settings), |
173 | 168 | ): |
174 | 169 | """ |
175 | 170 | ## TARS Endpoint to molecule data. |
176 | 171 | """ |
177 | | - bearer_token = await get_access_token(settings=settings) |
| 172 | + bearer_token = await get_access_token() |
178 | 173 | headers = { |
179 | 174 | "Authorization": f"Bearer {bearer_token}", |
180 | 175 | "Content-Type": "application/json", |
@@ -237,12 +232,11 @@ async def get_viruses( |
237 | 232 | } |
238 | 233 | }, |
239 | 234 | ), |
240 | | - settings: Settings = Depends(get_settings), |
241 | 235 | ): |
242 | 236 | """ |
243 | 237 | ## TARS Endpoint to virus data. |
244 | 238 | """ |
245 | | - bearer_token = await get_access_token(settings=settings) |
| 239 | + bearer_token = await get_access_token() |
246 | 240 | headers = { |
247 | 241 | "Authorization": f"Bearer {bearer_token}", |
248 | 242 | "Content-Type": "application/json", |
|
0 commit comments