Repository: dapr/python-sdk

Issue:
[BUG] DAPR_HEALTH_TIMEOUT as environment variable is not converted to numerical value
## Expected Behavior

When passing `DAPR_HEALTH_TIMEOUT` as environment variable it should be converted to a numerical value.


## Actual Behavior

docker container with env `DAPR_HEALTH_TIMEOUT=30` 

```timestamp="2024-03-22T11:03:26" level=ERROR message="Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/starlette/routing.py", line 705, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/usr/local/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/proxy/proxy_app.py", line 35, in lifespan
    DaprClient()
  File "/usr/local/lib/python3.11/site-packages/dapr/clients/__init__.py", line 81, in __init__
    super().__init__(address, interceptors, max_grpc_message_length)
  File "/usr/local/lib/python3.11/site-packages/dapr/clients/grpc/client.py", line 131, in __init__
    DaprHealth.wait_until_ready()
  File "/usr/local/lib/python3.11/site-packages/dapr/clients/health.py", line 45, in wait_until_ready
    remaining = (start + timeout) - time.time()
                 ~~~~~~^~~~~~~~~
TypeError: unsupported operand type(s) for +: 'float' and 'str'
```


## Steps to Reproduce the Problem

Start a docker container with an example env variable value `DAPR_HEALTH_TIMEOUT=30` and initialize `DaprClient()`


Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/dapr/python-sdk/pull/692?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dapr) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 86.28%. Comparing base [(`fc0e9d1`)](https://app.codecov.io/gh/dapr/python-sdk/commit/fc0e9d1cf917a0edc06405095f1f298514673612?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dapr) to head [(`2243cbe`)](https://app.codecov.io/gh/dapr/python-sdk/pull/692?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dapr).
> Report is 14 commits behind head on main.


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main     #692      +/-   ##
==========================================
- Coverage   86.37%   86.28%   -0.09%     
==========================================
  Files          79       82       +3     
  Lines        4094     4172      +78     
==========================================
+ Hits         3536     3600      +64     
- Misses        558      572      +14     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/dapr/python-sdk/pull/692?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dapr).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dapr).

elena-kolevska: Thanks for the contribution @KentHsu, and for reporting @PhilBug.
This problem is fixed in [this PR](https://github.com/dapr/python-sdk/pull/679/files#diff-bcd316f26f7228d016d43b5d1d6db67ecbad464c33efc674704db907ba26effb), but that would make the value an int, not a float. 

Just a small nit about updating the test to a float value, so it's more explicit.
KentHsu: Thank you for reviewing this PR @elena-kolevska 
I update the timeout value to 2.5 and also update the assertion to match this change.
Please let me know if there's anything you think we need to update. Thanks!

Patch:
diff --git a/dapr/clients/health.py b/dapr/clients/health.py
index 120b559..e3daec7 100644
--- a/dapr/clients/health.py
+++ b/dapr/clients/health.py
@@ -28,7 +28,7 @@ class DaprHealth:
         headers = {USER_AGENT_HEADER: DAPR_USER_AGENT}
         if settings.DAPR_API_TOKEN is not None:
             headers[DAPR_API_TOKEN_HEADER] = settings.DAPR_API_TOKEN
-        timeout = settings.DAPR_HEALTH_TIMEOUT
+        timeout = float(settings.DAPR_HEALTH_TIMEOUT)
 
         start = time.time()
         while True:


Test patch:
diff --git a/tests/clients/test_heatlhcheck.py b/tests/clients/test_heatlhcheck.py
index 5c67c2c..f3be8a4 100644
--- a/tests/clients/test_heatlhcheck.py
+++ b/tests/clients/test_heatlhcheck.py
@@ -62,7 +62,7 @@ class DaprHealthCheckTests(unittest.TestCase):
         self.assertIn('Dapr-api-token', headers)
         self.assertEqual(headers['Dapr-api-token'], 'mytoken')
 
-    @patch.object(settings, 'DAPR_HEALTH_TIMEOUT', 2)
+    @patch.object(settings, 'DAPR_HEALTH_TIMEOUT', '2.5')
     @patch('urllib.request.urlopen')
     def test_wait_until_ready_timeout(self, mock_urlopen):
         mock_urlopen.return_value.__enter__.return_value = MagicMock(status=500)
@@ -72,5 +72,5 @@ class DaprHealthCheckTests(unittest.TestCase):
         with self.assertRaises(TimeoutError):
             DaprHealth.wait_until_ready()
 
-        self.assertGreaterEqual(time.time() - start, 2)
+        self.assertGreaterEqual(time.time() - start, 2.5)
         self.assertGreater(mock_urlopen.call_count, 1)