Skip to content

Commit 4b2017e

Browse files
committed
py: remove default timeouts
Signed-off-by: Abhinav Gyawali <22275402+abhizer@users.noreply.github.com>
1 parent 542b605 commit 4b2017e

File tree

5 files changed

+69
-79
lines changed

5 files changed

+69
-79
lines changed

python/feldera/pipeline.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def foreach_chunk(
300300
handler.start()
301301

302302
def wait_for_completion(
303-
self, force_stop: bool = False, timeout_s: Optional[float] = None
303+
self, force_stop: bool = False, timeout_s: float | None = None
304304
):
305305
"""
306306
Block until the pipeline has completed processing all input records.
@@ -376,7 +376,7 @@ def is_complete(self) -> bool:
376376
def wait_for_idle(
377377
self,
378378
idle_interval_s: float = 5.0,
379-
timeout_s: float = 600.0,
379+
timeout_s: float | None = None,
380380
poll_interval_s: float = 0.2,
381381
):
382382
"""
@@ -396,12 +396,12 @@ def wait_for_idle(
396396
:raises RuntimeError: If the metrics are missing or the timeout was
397397
reached.
398398
"""
399-
if idle_interval_s > timeout_s:
399+
if timeout_s is not None and idle_interval_s > timeout_s:
400400
raise ValueError(
401401
f"idle interval ({idle_interval_s}s) cannot be larger than"
402402
f" timeout ({timeout_s}s)"
403403
)
404-
if poll_interval_s > timeout_s:
404+
if timeout_s is not None and poll_interval_s > timeout_s:
405405
raise ValueError(
406406
f"poll interval ({poll_interval_s}s) cannot be larger than"
407407
f" timeout ({timeout_s}s)"
@@ -447,7 +447,7 @@ def wait_for_idle(
447447
return
448448

449449
# Timeout
450-
if now_s - start_time_s >= timeout_s:
450+
if timeout_s is not None and now_s - start_time_s >= timeout_s:
451451
raise RuntimeError(f"waiting for idle reached timeout ({timeout_s}s)")
452452
time.sleep(poll_interval_s)
453453

@@ -696,7 +696,7 @@ def get(name: str, client: FelderaClient) -> "Pipeline":
696696
err.message = f"Pipeline with name {name} not found"
697697
raise err
698698

699-
def checkpoint(self, wait: bool = False, timeout_s=300) -> int:
699+
def checkpoint(self, wait: bool = False, timeout_s: Optional[float] = None) -> int:
700700
"""
701701
Checkpoints this pipeline.
702702
@@ -718,7 +718,7 @@ def checkpoint(self, wait: bool = False, timeout_s=300) -> int:
718718

719719
while True:
720720
elapsed = time.monotonic() - start
721-
if elapsed > timeout_s:
721+
if timeout_s is not None and elapsed > timeout_s:
722722
raise TimeoutError(
723723
f"""timeout ({timeout_s}s) reached while waiting for \
724724
pipeline '{self.name}' to make checkpoint '{seq}'"""
@@ -754,7 +754,9 @@ def checkpoint_status(self, seq: int) -> CheckpointStatus:
754754
if seq < success:
755755
return CheckpointStatus.Unknown
756756

757-
def sync_checkpoint(self, wait: bool = False, timeout_s=300) -> str:
757+
def sync_checkpoint(
758+
self, wait: bool = False, timeout_s: Optional[float] = None
759+
) -> str:
758760
"""
759761
Syncs this checkpoint to object store.
760762
@@ -776,7 +778,7 @@ def sync_checkpoint(self, wait: bool = False, timeout_s=300) -> str:
776778

777779
while True:
778780
elapsed = time.monotonic() - start
779-
if elapsed > timeout_s:
781+
if timeout_s is not None and elapsed > timeout_s:
780782
raise TimeoutError(
781783
f"""timeout ({timeout_s}s) reached while waiting for \
782784
pipeline '{self.name}' to sync checkpoint '{uuid}'"""

python/feldera/rest/_helpers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ def requests_verify_from_env() -> str | bool:
2020
if env_feldera_tls_insecure is not None and FELDERA_HTTPS_TLS_CERT is not None:
2121
logging.warning(
2222
"environment variables FELDERA_HTTPS_TLS_CERT and "
23-
"FELDERA_TLS_INSECURE both are set."
24-
"\nFELDERA_HTTPS_TLS_CERT takes priority."
23+
+ "FELDERA_TLS_INSECURE both are set."
24+
+ "\nFELDERA_HTTPS_TLS_CERT takes priority."
2525
)
2626

2727
if env_feldera_tls_insecure is None:
28-
FELDERA_TLS_INSECURE = False
28+
feldera_tls_insecure = False
2929
else:
30-
FELDERA_TLS_INSECURE = env_feldera_tls_insecure.strip().lower() in (
30+
feldera_tls_insecure = env_feldera_tls_insecure.strip().lower() in (
3131
"1",
3232
"true",
3333
"yes",
3434
)
3535

36-
requests_verify = not FELDERA_TLS_INSECURE
36+
requests_verify = not feldera_tls_insecure
3737
if FELDERA_HTTPS_TLS_CERT is not None:
3838
requests_verify = FELDERA_HTTPS_TLS_CERT
3939

python/feldera/rest/_httprequests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def send_request(
5656
"""
5757
self.headers["Content-Type"] = content_type
5858

59-
prev_resp: Optional[requests.Response] = None
59+
prev_resp: requests.Response | None = None
6060

6161
try:
6262
conn_timeout = self.config.connection_timeout
@@ -156,7 +156,7 @@ def post(
156156
body: Optional[
157157
Union[Mapping[str, Any], Sequence[Mapping[str, Any]], List[str], str]
158158
] = None,
159-
content_type: Optional[str] = "application/json",
159+
content_type: str = "application/json",
160160
params: Optional[Mapping[str, Any]] = None,
161161
stream: bool = False,
162162
serialize: bool = True,
@@ -177,7 +177,7 @@ def patch(
177177
body: Optional[
178178
Union[Mapping[str, Any], Sequence[Mapping[str, Any]], List[str], str]
179179
] = None,
180-
content_type: Optional[str] = "application/json",
180+
content_type: str = "application/json",
181181
params: Optional[Mapping[str, Any]] = None,
182182
) -> Any:
183183
return self.send_request(requests.patch, path, body, content_type, params)
@@ -188,7 +188,7 @@ def put(
188188
body: Optional[
189189
Union[Mapping[str, Any], Sequence[Mapping[str, Any]], List[str], str]
190190
] = None,
191-
content_type: Optional[str] = "application/json",
191+
content_type: str = "application/json",
192192
params: Optional[Mapping[str, Any]] = None,
193193
) -> Any:
194194
return self.send_request(requests.put, path, body, content_type, params)

python/feldera/rest/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __init__(
3939
)
4040
self.url: str = BASE_URL
4141
self.api_key: Optional[str] = os.environ.get("FELDERA_API_KEY", api_key)
42-
self.version: Optional[str] = version or "v0"
42+
self.version: str = version or "v0"
4343
self.timeout: Optional[float] = timeout
4444
self.connection_timeout: Optional[float] = connection_timeout
4545
env_verify = requests_verify_from_env()

0 commit comments

Comments
 (0)