halib 0.1.80__py3-none-any.whl → 0.1.82__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.
@@ -9,6 +9,7 @@ from threading import Lock
9
9
  from plotly.subplots import make_subplots
10
10
  import plotly.graph_objects as go
11
11
  import plotly.express as px # for dynamic color scales
12
+ from ..common import ConsoleLog
12
13
 
13
14
  from loguru import logger
14
15
 
@@ -94,7 +95,7 @@ class zProfiler:
94
95
  │ }
95
96
  """
96
97
  assert (
97
- len(ctx_step_dict.keys()) > 1
98
+ len(ctx_step_dict.keys()) > 0
98
99
  ), "step_dict must have only one key (step_name) for detail."
99
100
 
100
101
  for step_name, time_list in ctx_step_dict.items():
@@ -190,13 +191,14 @@ class zProfiler:
190
191
  percent_times = summary["percent_time"]
191
192
 
192
193
  step_names = [s.replace("avg_", "") for s in avg_times.keys()]
193
- pprint(f'{step_names=}')
194
+ # pprint(f'{step_names=}')
194
195
  n_steps = len(step_names)
195
196
 
197
+ assert n_steps > 0, "No steps found for context: {}".format(ctx)
196
198
  # Generate dynamic colors
197
199
  colors = px.colors.sample_colorscale(
198
200
  "Viridis", [i / (n_steps - 1) for i in range(n_steps)]
199
- )
201
+ ) if n_steps > 1 else [px.colors.sample_colorscale("Viridis", [0])[0]]
200
202
  # pprint(f'{len(colors)} colors generated for {n_steps} steps')
201
203
  color_map = dict(zip(step_names, colors))
202
204
 
@@ -278,6 +280,16 @@ class zProfiler:
278
280
  return self.plot_formatted_data(
279
281
  report, outdir=outdir, file_format=file_format, do_show=do_show
280
282
  )
283
+ def meta_info(self):
284
+ """
285
+ Print the structure of the profiler's time dictionary.
286
+ Useful for debugging and understanding the profiler's internal state.
287
+ """
288
+ for ctx_name, ctx_dict in self.time_dict.items():
289
+ with ConsoleLog(f"Context: {ctx_name}"):
290
+ step_names = list(ctx_dict['step_dict'].keys())
291
+ for step_name in step_names:
292
+ pprint(f"Step: {step_name}")
281
293
 
282
294
  def save_report_dict(self, output_file, with_detail=False):
283
295
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: halib
3
- Version: 0.1.80
3
+ Version: 0.1.82
4
4
  Summary: Small library for common tasks
5
5
  Author: Hoang Van Ha
6
6
  Author-email: hoangvanhauit@gmail.com
@@ -52,7 +52,7 @@ Dynamic: summary
52
52
 
53
53
  Helper package for coding and automation
54
54
 
55
- **Version 0.1.80**
55
+ **Version 0.1.82**
56
56
 
57
57
  + `research/profiler`: add `zProfiler` class to measure execution time of contexts and steps, with support for dynamic color scales in plots.
58
58
 
@@ -36,7 +36,7 @@ halib/research/metrics.py,sha256=Xgv0GUGo-o-RJaBOmkRCRpQJaYijF_1xeKkyYU_Bv4U,524
36
36
  halib/research/perfcalc.py,sha256=qDa0sqfpWrwGZVJtjuUVFK7JX6j8xyXP9OnnfYmdamg,15898
37
37
  halib/research/perftb.py,sha256=FWg0b8wSgy4UwuvHSXwEqvTq1Rhi-z-HtAKuQg1lWc4,30989
38
38
  halib/research/plot.py,sha256=-pDUk4z3C_GnyJ5zWmf-mGMdT4gaipVJWzIgcpIPiRk,9448
39
- halib/research/profiler.py,sha256=4q2nRTr3OQRE_z6zsnb7k9epk66z_jlW1kgphykNmJ4,10937
39
+ halib/research/profiler.py,sha256=xlVAJ8mgPtC-Y1J-avuSZBloWFJgcvAjmTeOYjckvS8,11588
40
40
  halib/research/torchloader.py,sha256=yqUjcSiME6H5W210363HyRUrOi3ISpUFAFkTr1w4DCw,6503
41
41
  halib/research/wandb_op.py,sha256=YzLEqME5kIRxi3VvjFkW83wnFrsn92oYeqYuNwtYRkY,4188
42
42
  halib/sys/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -52,8 +52,8 @@ halib/utils/gpu_mon.py,sha256=vD41_ZnmPLKguuq9X44SB_vwd9JrblO4BDzHLXZhhFY,2233
52
52
  halib/utils/listop.py,sha256=Vpa8_2fI0wySpB2-8sfTBkyi_A4FhoFVVvFiuvW8N64,339
53
53
  halib/utils/tele_noti.py,sha256=-4WXZelCA4W9BroapkRyIdUu9cUVrcJJhegnMs_WpGU,5928
54
54
  halib/utils/video.py,sha256=ZqzNVPgc1RZr_T0OlHvZ6SzyBpL7O27LtB86JMbBuR0,3059
55
- halib-0.1.80.dist-info/licenses/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
56
- halib-0.1.80.dist-info/METADATA,sha256=6fPL11EXy7ahsWkxxUNf0jB4qAmH61ZLjHxejiLP7IA,5864
57
- halib-0.1.80.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
58
- halib-0.1.80.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
59
- halib-0.1.80.dist-info/RECORD,,
55
+ halib-0.1.82.dist-info/licenses/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
56
+ halib-0.1.82.dist-info/METADATA,sha256=FmbjEQLCE3jqJT6H2uyn6MfyZXsFhJwO80l93Be_zsE,5864
57
+ halib-0.1.82.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
58
+ halib-0.1.82.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
59
+ halib-0.1.82.dist-info/RECORD,,
File without changes