halib 0.1.94__py3-none-any.whl → 0.1.95__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.
@@ -6,6 +6,8 @@ from omegaconf import OmegaConf
6
6
  from rich.console import Console
7
7
  from argparse import ArgumentParser
8
8
 
9
+ from ..research.mics import *
10
+
9
11
  console = Console()
10
12
 
11
13
 
@@ -51,6 +53,27 @@ def load_yaml(yaml_file, to_dict=False, log_info=False):
51
53
  else:
52
54
  return omgconf
53
55
 
56
+ def load_yaml_with_PC_abbr(
57
+ yaml_file, pc_abbr_to_working_disk=DEFAULT_ABBR_WORKING_DISK
58
+ ):
59
+ # current PC abbreviation
60
+ pc_abbr = get_PC_abbr_name()
61
+
62
+ # current plaftform: windows or linux
63
+ current_platform = platform.system().lower()
64
+
65
+ assert pc_abbr in pc_abbr_to_working_disk, f"The is no mapping for {pc_abbr} to <working_disk>"
66
+
67
+ # working disk
68
+ working_disk = pc_abbr_to_working_disk.get(pc_abbr)
69
+
70
+ # load yaml file
71
+ data_dict = load_yaml(yaml_file=yaml_file, to_dict=True)
72
+
73
+ # Normalize paths in the loaded data
74
+ data_dict = normalize_paths(data_dict, working_disk, current_platform)
75
+ return data_dict
76
+
54
77
 
55
78
  def parse_args():
56
79
  parser = ArgumentParser(description="desc text")
halib/research/mics.py CHANGED
@@ -1,5 +1,9 @@
1
+ from ..common import *
2
+ from ..filetype import csvfile
3
+ import pandas as pd
1
4
  import platform
2
5
 
6
+
3
7
  PC_NAME_TO_ABBR = {
4
8
  "DESKTOP-JQD9K01": "MainPC",
5
9
  "DESKTOP-5IRHU87": "MSI_Laptop",
@@ -8,9 +12,55 @@ PC_NAME_TO_ABBR = {
8
12
  "DESKTOP-QNS3DNF": "1GPU_SV"
9
13
  }
10
14
 
15
+ DEFAULT_ABBR_WORKING_DISK = {
16
+ "MainPC": "E:",
17
+ "MSI_Laptop": "D:",
18
+ "4090_SV": "E:",
19
+ "4GPU_SV": "D:",
20
+ }
21
+
22
+ def list_PCs():
23
+ df = pd.DataFrame(list(PC_NAME_TO_ABBR.items()), columns=["PC Name", "Abbreviation"])
24
+ csvfile.showdf(df)
25
+
11
26
  def get_PC_name():
12
27
  return platform.node()
13
28
 
14
29
  def get_PC_abbr_name():
15
30
  pc_name = get_PC_name()
16
31
  return PC_NAME_TO_ABBR.get(pc_name, "Unknown")
32
+
33
+ # ! This funcction search for full paths in the obj and normalize them according to the current platform and working disk
34
+ # ! E.g: "E:/zdataset/DFire", but working_disk: "D:", current_platform: "windows" => "D:/zdataset/DFire"
35
+ # ! E.g: "E:/zdataset/DFire", but working_disk: "D:", current_platform: "linux" => "/mnt/d/zdataset/DFire"
36
+ def normalize_paths(obj, working_disk, current_platform):
37
+ if isinstance(obj, dict):
38
+ for key, value in obj.items():
39
+ obj[key] = normalize_paths(value, working_disk, current_platform)
40
+ return obj
41
+ elif isinstance(obj, list):
42
+ for i, item in enumerate(obj):
43
+ obj[i] = normalize_paths(item, working_disk, current_platform)
44
+ return obj
45
+ elif isinstance(obj, str):
46
+ # Normalize backslashes to forward slashes for consistency
47
+ obj = obj.replace("\\", "/")
48
+ # Regex for Windows-style path: e.g., "E:/zdataset/DFire"
49
+ win_match = re.match(r"^([A-Z]):/(.*)$", obj)
50
+ # Regex for Linux-style path: e.g., "/mnt/e/zdataset/DFire"
51
+ lin_match = re.match(r"^/mnt/([a-z])/(.*)$", obj)
52
+ if win_match or lin_match:
53
+ rest = win_match.group(2) if win_match else lin_match.group(2)
54
+ if current_platform == "windows":
55
+ # working_disk is like "D:", so "D:/" + rest
56
+ new_path = working_disk + "/" + rest
57
+ elif current_platform == "linux":
58
+ # Extract drive letter from working_disk (e.g., "D:" -> "d")
59
+ drive_letter = working_disk[0].lower()
60
+ new_path = "/mnt/" + drive_letter + "/" + rest
61
+ else:
62
+ # Unknown platform, return original
63
+ return obj
64
+ return new_path
65
+ # For non-strings or non-path strings, return as is
66
+ return obj
@@ -227,9 +227,9 @@ class PerfCalc(ABC): # Abstract base class for performance calculation
227
227
  ), "No metric columns found in the DataFrame. Ensure that the CSV files contain metric columns starting with 'metric_'."
228
228
  final_cols = sticky_cols + metric_cols
229
229
  df = df[final_cols]
230
- # !hahv debug
231
- pprint("------ Final DataFrame Columns ------")
232
- csvfile.fn_display_df(df)
230
+ # # !hahv debug
231
+ # pprint("------ Final DataFrame Columns ------")
232
+ # csvfile.fn_display_df(df)
233
233
  # ! validate all rows in df before returning
234
234
  # make sure all rows will have at least values for REQUIRED_COLS and at least one metric column
235
235
  for index, row in df.iterrows():
halib/research/perftb.py CHANGED
@@ -308,7 +308,8 @@ class PerfTB:
308
308
  if save_path:
309
309
  export_success = False
310
310
  try:
311
- fig.write_image(save_path, engine="kaleido")
311
+ # fig.write_image(save_path, engine="kaleido")
312
+ fig.write_image(save_path, engine="kaleido", width=width, height=height * len(metric_list))
312
313
  export_success = True
313
314
  # pprint(f"Saved: {os.path.abspath(save_path)}")
314
315
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: halib
3
- Version: 0.1.94
3
+ Version: 0.1.95
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.94**
55
+ **Version 0.1.95**
56
56
  + `research/plot': add `PlotHelper` class to plot train history + plot grid of images (e.g., image samples from dataset or model outputs)
57
57
 
58
58
 
@@ -21,7 +21,7 @@ halib/filetype/csvfile.py,sha256=4Klf8YNzY1MaCD3o5Wp5GG3KMfQIBOEVzHV_7DO5XBo,660
21
21
  halib/filetype/jsonfile.py,sha256=9LBdM7LV9QgJA1bzJRkq69qpWOP22HDXPGirqXTgSCw,480
22
22
  halib/filetype/textfile.py,sha256=QtuI5PdLxu4hAqSeafr3S8vCXwtvgipWV4Nkl7AzDYM,399
23
23
  halib/filetype/videofile.py,sha256=4nfVAYYtoT76y8P4WYyxNna4Iv1o2iV6xaMcUzNPC4s,4736
24
- halib/filetype/yamlfile.py,sha256=CqYqWtWSysQm_KBmcLjU-FXSXY4TYLPDGP4IqtnPPF4,2037
24
+ halib/filetype/yamlfile.py,sha256=59P9cdqTx655XXeQtkmAJoR_UhhVN4L8Tro-kd8Ri5g,2741
25
25
  halib/online/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  halib/online/gdrive.py,sha256=RmF4y6UPxektkKIctmfT-pKWZsBM9FVUeld6zZmJkp0,7787
27
27
  halib/online/gdrive_mkdir.py,sha256=wSJkQMJCDuS1gxQ2lHQHq_IrJ4xR_SEoPSo9n_2WNFU,1474
@@ -33,10 +33,10 @@ halib/research/base_exp.py,sha256=hiO2flt_I0iJJ4bWcQwyh2ISezoC8t2k3PtxHeVr0eI,32
33
33
  halib/research/benchquery.py,sha256=FuKnbWQtCEoRRtJAfN-zaN-jPiO_EzsakmTOMiqi7GQ,4626
34
34
  halib/research/dataset.py,sha256=QU0Hr5QFb8_XlvnOMgC9QJGIpwXAZ9lDd0RdQi_QRec,6743
35
35
  halib/research/metrics.py,sha256=PXPCy8r1_0lpMKfjc5SjIpRHnX80gHmeZ1C4eVj9U_s,5200
36
- halib/research/mics.py,sha256=uX17AGrBGER-OFMqUULE_A9YPPbn1RpQ4o5-omrmqZ8,377
36
+ halib/research/mics.py,sha256=BzRM7ZF5o9-Ass-5K7lJzu5CQJvzBXMsw601V9kVFI0,2563
37
37
  halib/research/params_gen.py,sha256=GcTMlniL0iE3HalJY-gVRiYa8Qy8u6nX4LkKZeMkct8,4262
38
- halib/research/perfcalc.py,sha256=qDa0sqfpWrwGZVJtjuUVFK7JX6j8xyXP9OnnfYmdamg,15898
39
- halib/research/perftb.py,sha256=FWg0b8wSgy4UwuvHSXwEqvTq1Rhi-z-HtAKuQg1lWc4,30989
38
+ halib/research/perfcalc.py,sha256=G8WpGB95AY5KQCt0__bPK1yUa2M1onNhXLM7twkElxg,15904
39
+ halib/research/perftb.py,sha256=YlBXMeWn8S0LhsgxONEQZrKomRTju2T8QGGspUOy_6Y,31100
40
40
  halib/research/plot.py,sha256=4xMGJuP1lGN1wF27XFM5eMFb73Gu9qB582VZhTdcCSA,38418
41
41
  halib/research/profiler.py,sha256=GRAewTo0jGkOputjmRwtYVfJYBze_ivsOnrW9exWkPQ,11772
42
42
  halib/research/torchloader.py,sha256=yqUjcSiME6H5W210363HyRUrOi3ISpUFAFkTr1w4DCw,6503
@@ -54,8 +54,8 @@ halib/utils/gpu_mon.py,sha256=vD41_ZnmPLKguuq9X44SB_vwd9JrblO4BDzHLXZhhFY,2233
54
54
  halib/utils/listop.py,sha256=Vpa8_2fI0wySpB2-8sfTBkyi_A4FhoFVVvFiuvW8N64,339
55
55
  halib/utils/tele_noti.py,sha256=-4WXZelCA4W9BroapkRyIdUu9cUVrcJJhegnMs_WpGU,5928
56
56
  halib/utils/video.py,sha256=zLoj5EHk4SmP9OnoHjO8mLbzPdtq6gQPzTQisOEDdO8,3261
57
- halib-0.1.94.dist-info/licenses/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
58
- halib-0.1.94.dist-info/METADATA,sha256=5R20faqnHeXHEoRWO4_LumYsz4_HIG5LnfpfrXoR5Y0,6200
59
- halib-0.1.94.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
60
- halib-0.1.94.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
61
- halib-0.1.94.dist-info/RECORD,,
57
+ halib-0.1.95.dist-info/licenses/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
58
+ halib-0.1.95.dist-info/METADATA,sha256=UbWqWzqFToHBXcPzV7kJirz68PnPopa6ia_iot6SSwE,6200
59
+ halib-0.1.95.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
60
+ halib-0.1.95.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
61
+ halib-0.1.95.dist-info/RECORD,,
File without changes