Skip to content

Commit

Permalink
Timeout member added to ehrclient class (#89)
Browse files Browse the repository at this point in the history
* Overflow and Type Errors added to concept.py . Required tests for quantity class added in tests.

* minor issues fixed

* code formatted

* python-version file removed

* Removed TypeError for None and updated tests

* test_cdaannotator updated

* cdaannotator updated with find various sections using codes functionality

* timeout member added to ehrclient class

* docstring updated!

* updated docstring

---------

Co-authored-by: Adam Kells <[email protected]>
  • Loading branch information
Vortex-21 and adamkells authored Oct 25, 2024
1 parent 378e6b2 commit ed7c69f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions healthchain/clients/ehrclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ def wrapper(self, *args: Any, **kwargs: Any) -> EHRClient:

class EHRClient(BaseClient):
def __init__(
self, func: Callable[..., Any], workflow: Workflow, strategy: BaseStrategy
self,
func: Callable[..., Any],
workflow: Workflow,
strategy: BaseStrategy,
timeout: Optional[float] = 10.0,
):
"""
Initializes the EHRClient with a data generator function and optional workflow and use case.
Expand All @@ -109,14 +113,17 @@ def __init__(
func (Callable[..., Any]): A function to generate data for requests.
workflow ([Workflow]): The workflow context to apply to the data generator.
strategy (BaseStrategy): The strategy object to construct requests based on the generated data.
timeout(Optional[float], default=10.0) : The maximum time in seconds to wait for a response from the server.
This parameter determines how long the client will wait before considering a request timed out.
A higher timeout value allows for longer-running operations, while a lower value prioritizes faster responses.
"""
# TODO: Add option to pass in different provider options
self.data_generator_func: Callable[..., Any] = func
self.workflow: Workflow = workflow
self.strategy: BaseStrategy = strategy
self.vendor = None
self.request_data: List[CDSRequest] = []
self.timeout = timeout

def set_vendor(self, name) -> None:
self.vendor = name
Expand Down Expand Up @@ -150,7 +157,7 @@ async def send_request(self, url: str) -> List[Dict]:
async with httpx.AsyncClient() as client:
responses: List[Dict] = []
# TODO: pass timeout as config
timeout = httpx.Timeout(10.0, read=None)
timeout = httpx.Timeout(self.timeout, read=None)
for request in self.request_data:
try:
if self.strategy.api_protocol == ApiProtocol.soap:
Expand Down

0 comments on commit ed7c69f

Please sign in to comment.