@@ -214,6 +214,11 @@ def get_progress_bar_url(self):
214214 ################
215215 # BASIC METHODS
216216 ################
217+ @property
218+ def has_api_key (self ) -> bool :
219+ """True if a non-empty API key is set (constructor arg, class default, or env/config)."""
220+ return bool (self .api_key )
221+
217222 @property
218223 def headers (self ) -> dict :
219224 """
@@ -260,9 +265,9 @@ def _send_server_request(
260265 if "json_string" in log_payload and log_payload ["json_string" ]:
261266 json_str = log_payload ["json_string" ]
262267 if len (json_str ) > 200 :
263- log_payload [
264- "json_string "
265- ] = f" { json_str [: 200 ] } ... (truncated, total length: { len ( json_str ) } )"
268+ log_payload ["json_string" ] = (
269+ f" { json_str [: 200 ] } ... (truncated, total length: { len ( json_str ) } ) "
270+ )
266271 self ._logger .info (f"Request payload: { log_payload } " )
267272
268273 try :
@@ -3632,15 +3637,11 @@ def _collect_filestores(d: dict, path: str = ""):
36323637 else :
36333638 for key , value in d .items ():
36343639 if isinstance (value , dict ):
3635- _collect_filestores (
3636- value , f"{ path } .{ key } " if path else key
3637- )
3640+ _collect_filestores (value , f"{ path } .{ key } " if path else key )
36383641 elif isinstance (value , list ):
36393642 for i , item in enumerate (value ):
36403643 if isinstance (item , dict ):
3641- _collect_filestores (
3642- item , f"{ path } .{ key } [{ i } ]"
3643- )
3644+ _collect_filestores (item , f"{ path } .{ key } [{ i } ]" )
36443645
36453646 _collect_filestores (modified_dict )
36463647
@@ -3741,11 +3742,7 @@ def _upload_one(d: dict) -> dict | None:
37413742 if original_object is not None and path :
37423743 try :
37433744 clean_path = path .lstrip ("." )
3744- keys = (
3745- clean_path .split ("." )
3746- if "." in clean_path
3747- else [clean_path ]
3748- )
3745+ keys = clean_path .split ("." ) if "." in clean_path else [clean_path ]
37493746 keys = [k for k in keys if k ]
37503747 current_obj = original_object
37513748
@@ -3765,7 +3762,9 @@ def _upload_one(d: dict) -> dict | None:
37653762 idx_val = int (idx_str .rstrip ("]" ))
37663763 if key_name :
37673764 if hasattr (current_obj , key_name ):
3768- current_obj = getattr (current_obj , key_name )[idx_val ]
3765+ current_obj = getattr (current_obj , key_name )[
3766+ idx_val
3767+ ]
37693768 else :
37703769 current_obj = current_obj [key_name ][idx_val ]
37713770 else :
@@ -4012,9 +4011,7 @@ def push(
40124011 value_type = (
40134012 "inf"
40144013 if math .isinf (value )
4015- else "nan"
4016- if math .isnan (value )
4017- else "invalid"
4014+ else "nan" if math .isnan (value ) else "invalid"
40184015 )
40194016 error_msg += f" • { path } : { value } ({ value_type } )\n "
40204017
@@ -4462,6 +4459,7 @@ async def report_error(self, error: Exception) -> None:
44624459 This method provides a non-blocking way to report errors that occur during
44634460 EDSL operations. It sends error reports to the server for monitoring and
44644461 debugging purposes, while also printing to stderr for immediate feedback.
4462+ If no API key is configured, returns immediately without contacting the server.
44654463
44664464 Duplicate errors (same error type and message) are not reported if they
44674465 occurred within the past minute to prevent spam.
@@ -4476,6 +4474,9 @@ async def report_error(self, error: Exception) -> None:
44764474 ... except Exception as e:
44774475 ... await coop.report_error(e)
44784476 """
4477+ if not self .has_api_key :
4478+ return
4479+
44794480 import sys
44804481 import traceback
44814482 import httpx
0 commit comments