halib 0.2.30__py3-none-any.whl → 0.2.32__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.
halib/common/common.py CHANGED
@@ -1,3 +1,4 @@
1
+ from fiftyone.brain.internal.core.lancedb import pa
1
2
  import os
2
3
  import sys
3
4
  import re
@@ -261,39 +262,55 @@ def pprint_local_path(
261
262
 
262
263
 
263
264
  def log_func(
264
- func: Optional[Callable] = None, *, log_time: bool = False, log_args: bool = False
265
+ func: Optional[Callable] = None,
266
+ *,
267
+ log_time: bool = False,
268
+ log_args: bool = False,
269
+ skip_idxs: Optional[List[int]] = None, # New parameter
265
270
  ):
266
271
  """
267
- A decorator that logs the start/end of a function.
268
- Supports both @log_func and @log_func(log_time=True) usage.
272
+ Enhanced decorator that logs arguments line-by-line and allows skipping indices.
269
273
  """
270
- # 1. HANDLE ARGUMENTS: If called as @log_func(log_time=True), func is None.
271
- # We return a 'partial' function that remembers the args and waits for the func.
272
274
  if func is None:
273
- return functools.partial(log_func, log_time=log_time, log_args=log_args)
275
+ return functools.partial(
276
+ log_func, log_time=log_time, log_args=log_args, skip_idxs=skip_idxs
277
+ )
274
278
 
275
- # 2. HANDLE DECORATION: If called as @log_func, func is the actual function.
276
279
  @functools.wraps(func)
277
280
  def wrapper(*args, **kwargs):
278
- # Safe way to get name (handles partials/lambdas)
279
281
  func_name = getattr(func, "__name__", "Unknown_Func")
282
+ skip_list = skip_idxs or []
283
+
284
+ SUMMARY_WIDTH = 80
285
+ SUB_SUMMARY_WIDTH = 50
280
286
 
281
- # Note: Ensure 'ConsoleLog' context manager is available in your scope
282
287
  with ConsoleLog(func_name):
283
288
  start = time.perf_counter()
284
289
  try:
285
290
  result = func(*args, **kwargs)
286
291
  finally:
287
- # We use finally to ensure logging happens even if func crashes
288
292
  end = time.perf_counter()
289
293
 
290
294
  if log_time or log_args:
295
+ console.print(
296
+ pad_string(f"Func <{func_name}> summary", SUMMARY_WIDTH)
297
+ )
298
+
299
+ if log_args:
300
+ console.print(pad_string(f"Args Summary", SUMMARY_WIDTH))
301
+ # Log Positional Args line-by-line
302
+ for i, val in enumerate(args):
303
+ val = "SKIPPED" if i in skip_list else val
304
+ console.print(pad_string(f"arg[{i}]", SUB_SUMMARY_WIDTH))
305
+ pprint(val)
306
+ # Log Keyword Args line-by-line
307
+ for k, v in kwargs.items():
308
+ console.print(pad_string(f"{k}", SUB_SUMMARY_WIDTH))
309
+ pprint(v)
291
310
 
292
- console.print(pad_string(f"Func <{func_name}> summary", 80))
293
311
  if log_time:
312
+ console.print(pad_string(f"Time Summary", SUMMARY_WIDTH))
294
313
  console.print(f"{func_name} took {end - start:.6f} seconds")
295
- if log_args:
296
- console.print(f"Args: {args}, Kwargs: {kwargs}")
297
314
 
298
315
  return result
299
316
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: halib
3
- Version: 0.2.30
3
+ Version: 0.2.32
4
4
  Summary: Small library for common tasks
5
5
  Author: Hoang Van Ha
6
6
  Author-email: hoangvanhauit@gmail.com
@@ -57,7 +57,7 @@ Dynamic: summary
57
57
 
58
58
  ## v0.2.x (Experiment & Core Updates)
59
59
 
60
- ### **v0.2.30**
60
+ ### **v0.2.32**
61
61
 
62
62
  - ✨ **New Feature:**: add `common.common.log_func` as decorator to log function entry, exit, with execution time and arguments.
63
63
 
@@ -17,7 +17,7 @@ halib/textfile.py,sha256=EhVFrit-nRBJx18e6rtIqcE1cSbgsLnMXe_kdhi1EPI,399
17
17
  halib/torchloader.py,sha256=-q9YE-AoHZE1xQX2dgNxdqtucEXYs4sQ22WXdl6EGfI,6500
18
18
  halib/videofile.py,sha256=NTLTZ-j6YD47duw2LN2p-lDQDglYFP1LpEU_0gzHLdI,4737
19
19
  halib/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- halib/common/common.py,sha256=Ta_4w1k1RUnIXMxvKhsrE5TadRpB9rwqf5qEZcU1oPM,10046
20
+ halib/common/common.py,sha256=sGfL03cg3lsp6rfpWSltpfDWV7vNI_0lh6pMFmAli4I,10516
21
21
  halib/common/rich_color.py,sha256=tyK5fl3Dtv1tKsfFzt_5Rco4Fj72QliA-w5aGXaVuqQ,6392
22
22
  halib/exp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  halib/exp/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -103,8 +103,8 @@ halib/utils/listop.py,sha256=Vpa8_2fI0wySpB2-8sfTBkyi_A4FhoFVVvFiuvW8N64,339
103
103
  halib/utils/slack.py,sha256=2ugWE_eJ0s479ObACJbx7iEu3kjMPD4Rt2hEwuMpuNQ,3099
104
104
  halib/utils/tele_noti.py,sha256=-4WXZelCA4W9BroapkRyIdUu9cUVrcJJhegnMs_WpGU,5928
105
105
  halib/utils/video.py,sha256=zLoj5EHk4SmP9OnoHjO8mLbzPdtq6gQPzTQisOEDdO8,3261
106
- halib-0.2.30.dist-info/licenses/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
107
- halib-0.2.30.dist-info/METADATA,sha256=mI_TeedvIuVaUTlHo9pZDRiLUZpYLJWLG7e8ru1Wt90,8183
108
- halib-0.2.30.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
109
- halib-0.2.30.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
110
- halib-0.2.30.dist-info/RECORD,,
106
+ halib-0.2.32.dist-info/licenses/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
107
+ halib-0.2.32.dist-info/METADATA,sha256=nNZlX11Q-7O3QWNeUooBUbYCicmwJnJC-4ue44mVYA4,8183
108
+ halib-0.2.32.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
109
+ halib-0.2.32.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
110
+ halib-0.2.32.dist-info/RECORD,,
File without changes