steer-core 0.1.15__py3-none-any.whl → 0.1.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,10 +5,14 @@ from typing import List, Dict
5
5
 
6
6
 
7
7
  @contextmanager
8
- def capture_warnings(existing_warnings: List[Dict] = None, source: str = None, clear_source_warnings: bool = True):
8
+ def capture_warnings(
9
+ existing_warnings: List[Dict] = None,
10
+ source: str = None,
11
+ clear_source_warnings: bool = True,
12
+ ):
9
13
  """
10
14
  Context manager to capture warnings and format them for Dash.
11
-
15
+
12
16
  Parameters
13
17
  ----------
14
18
  existing_warnings : List[Dict], optional
@@ -17,7 +21,7 @@ def capture_warnings(existing_warnings: List[Dict] = None, source: str = None, c
17
21
  Source identifier for the warnings
18
22
  clear_source_warnings : bool, optional
19
23
  Whether to clear existing warnings from the same source before adding new ones
20
-
24
+
21
25
  Yields
22
26
  ------
23
27
  List[Dict]
@@ -25,31 +29,33 @@ def capture_warnings(existing_warnings: List[Dict] = None, source: str = None, c
25
29
  """
26
30
  if existing_warnings is None:
27
31
  existing_warnings = []
28
-
32
+
29
33
  # Clear existing warnings from the same source if requested
30
34
  if clear_source_warnings and source:
31
- existing_warnings = [w for w in existing_warnings if w.get('source') != source]
32
-
35
+ existing_warnings = [w for w in existing_warnings if w.get("source") != source]
36
+
33
37
  with warnings.catch_warnings(record=True) as warnings_list:
34
38
  warnings.simplefilter("always")
35
-
39
+
36
40
  # Yield the cleaned warnings list
37
41
  yield existing_warnings
38
-
42
+
39
43
  # Process any new warnings after the operation
40
44
  new_warnings = []
41
45
  for w in warnings_list:
42
-
43
- new_warnings.append({
44
- 'message': str(w.message),
45
- 'category': w.category.__name__,
46
- 'filename': w.filename,
47
- 'lineno': w.lineno,
48
- 'timestamp': time.time(),
49
- 'source': source or 'unknown',
50
- 'id': f"{source}_{int(time.time())}" if source else f"warning_{int(time.time())}"
51
- })
52
-
46
+ new_warnings.append(
47
+ {
48
+ "message": str(w.message),
49
+ "category": w.category.__name__,
50
+ "filename": w.filename,
51
+ "lineno": w.lineno,
52
+ "timestamp": time.time(),
53
+ "source": source or "unknown",
54
+ "id": f"{source}_{int(time.time())}"
55
+ if source
56
+ else f"warning_{int(time.time())}",
57
+ }
58
+ )
59
+
53
60
  # Add new warnings
54
61
  existing_warnings.extend(new_warnings)
55
-
@@ -4,6 +4,7 @@ import time
4
4
 
5
5
  def timed_callback(func):
6
6
  """Time callback execution for optimization."""
7
+
7
8
  @wraps(func)
8
9
  def wrapper(*args, **kwargs):
9
10
  start = time.time()
@@ -11,7 +12,7 @@ def timed_callback(func):
11
12
  duration = time.time() - start
12
13
 
13
14
  print(f"CALLBACK: {func.__name__} took {duration:.2f}s")
14
-
15
+
15
16
  return result
16
- return wrapper
17
17
 
18
+ return wrapper