halib 0.1.58__tar.gz → 0.1.59__tar.gz

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.
Files changed (44) hide show
  1. {halib-0.1.58 → halib-0.1.59}/PKG-INFO +2 -2
  2. {halib-0.1.58 → halib-0.1.59}/README.md +1 -1
  3. {halib-0.1.58 → halib-0.1.59}/halib/research/perfcalc.py +35 -15
  4. halib-0.1.59/halib/utils/dict_op.py +9 -0
  5. {halib-0.1.58 → halib-0.1.59}/halib.egg-info/PKG-INFO +2 -2
  6. {halib-0.1.58 → halib-0.1.59}/halib.egg-info/SOURCES.txt +1 -0
  7. {halib-0.1.58 → halib-0.1.59}/setup.py +1 -1
  8. {halib-0.1.58 → halib-0.1.59}/.gitignore +0 -0
  9. {halib-0.1.58 → halib-0.1.59}/GDriveFolder.txt +0 -0
  10. {halib-0.1.58 → halib-0.1.59}/LICENSE.txt +0 -0
  11. {halib-0.1.58 → halib-0.1.59}/MANIFEST.in +0 -0
  12. {halib-0.1.58 → halib-0.1.59}/guide_publish_pip.pdf +0 -0
  13. {halib-0.1.58 → halib-0.1.59}/halib/__init__.py +0 -0
  14. {halib-0.1.58 → halib-0.1.59}/halib/common.py +0 -0
  15. {halib-0.1.58 → halib-0.1.59}/halib/cuda.py +0 -0
  16. {halib-0.1.58 → halib-0.1.59}/halib/filetype/__init__.py +0 -0
  17. {halib-0.1.58 → halib-0.1.59}/halib/filetype/csvfile.py +0 -0
  18. {halib-0.1.58 → halib-0.1.59}/halib/filetype/jsonfile.py +0 -0
  19. {halib-0.1.58 → halib-0.1.59}/halib/filetype/textfile.py +0 -0
  20. {halib-0.1.58 → halib-0.1.59}/halib/filetype/videofile.py +0 -0
  21. {halib-0.1.58 → halib-0.1.59}/halib/filetype/yamlfile.py +0 -0
  22. {halib-0.1.58 → halib-0.1.59}/halib/online/__init__.py +0 -0
  23. {halib-0.1.58 → halib-0.1.59}/halib/online/gdrive.py +0 -0
  24. {halib-0.1.58 → halib-0.1.59}/halib/online/gdrive_mkdir.py +0 -0
  25. {halib-0.1.58 → halib-0.1.59}/halib/online/gdrive_test.py +0 -0
  26. {halib-0.1.58 → halib-0.1.59}/halib/online/projectmake.py +0 -0
  27. {halib-0.1.58 → halib-0.1.59}/halib/research/__init__.py +0 -0
  28. {halib-0.1.58 → halib-0.1.59}/halib/research/dataset.py +0 -0
  29. {halib-0.1.58 → halib-0.1.59}/halib/research/perftb.py +0 -0
  30. {halib-0.1.58 → halib-0.1.59}/halib/research/plot.py +0 -0
  31. {halib-0.1.58 → halib-0.1.59}/halib/research/torchloader.py +0 -0
  32. {halib-0.1.58 → halib-0.1.59}/halib/research/wandb_op.py +0 -0
  33. {halib-0.1.58 → halib-0.1.59}/halib/rich_color.py +0 -0
  34. {halib-0.1.58 → halib-0.1.59}/halib/system/__init__.py +0 -0
  35. {halib-0.1.58 → halib-0.1.59}/halib/system/cmd.py +0 -0
  36. {halib-0.1.58 → halib-0.1.59}/halib/system/filesys.py +0 -0
  37. {halib-0.1.58 → halib-0.1.59}/halib/utils/__init__.py +0 -0
  38. {halib-0.1.58 → halib-0.1.59}/halib/utils/dataclass_util.py +0 -0
  39. {halib-0.1.58 → halib-0.1.59}/halib/utils/listop.py +0 -0
  40. {halib-0.1.58 → halib-0.1.59}/halib/utils/tele_noti.py +0 -0
  41. {halib-0.1.58 → halib-0.1.59}/halib.egg-info/dependency_links.txt +0 -0
  42. {halib-0.1.58 → halib-0.1.59}/halib.egg-info/requires.txt +0 -0
  43. {halib-0.1.58 → halib-0.1.59}/halib.egg-info/top_level.txt +0 -0
  44. {halib-0.1.58 → halib-0.1.59}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: halib
3
- Version: 0.1.58
3
+ Version: 0.1.59
4
4
  Summary: Small library for common tasks
5
5
  Author: Hoang Van Ha
6
6
  Author-email: hoangvanhauit@gmail.com
@@ -15,7 +15,7 @@ License-File: LICENSE.txt
15
15
 
16
16
  Helper package for coding and automation
17
17
 
18
- **Version 0.1.58**
18
+ **Version 0.1.59**
19
19
 
20
20
  + add `util/perfcalc`: abstract class for performance calculation. This class need to be inherited and implemented with specific performance calculation logic.
21
21
 
@@ -1,6 +1,6 @@
1
1
  Helper package for coding and automation
2
2
 
3
- **Version 0.1.58**
3
+ **Version 0.1.59**
4
4
 
5
5
  + add `util/perfcalc`: abstract class for performance calculation. This class need to be inherited and implemented with specific performance calculation logic.
6
6
 
@@ -124,6 +124,7 @@ class PerfCalc(ABC): # Abstract base class for performance calculation
124
124
  all_metric_data = self.prepare_exp_data_for_metrics(
125
125
  metric_names, *args, **kwargs
126
126
  )
127
+ metric_col_names = []
127
128
  for metric in metric_names:
128
129
  if metric not in all_metric_data:
129
130
  raise ValueError(f"Metric '{metric}' not found in provided data.")
@@ -140,8 +141,12 @@ class PerfCalc(ABC): # Abstract base class for performance calculation
140
141
  args = metric_data
141
142
  else:
142
143
  raise TypeError(f"Unsupported data format for metric '{metric}'")
144
+
143
145
  # Call update and compute
144
- tmetric.update(*args)
146
+ if len(expected_args) == 1:
147
+ tmetric.update(args) # pass as single argument
148
+ else:
149
+ tmetric.update(*args) # unpack multiple arguments
145
150
  computed_value = tmetric.compute()
146
151
  # ensure the computed value converted to a scala value or list array
147
152
  if isinstance(computed_value, torch.Tensor):
@@ -149,16 +154,16 @@ class PerfCalc(ABC): # Abstract base class for performance calculation
149
154
  computed_value = computed_value.item()
150
155
  else:
151
156
  computed_value = computed_value.tolist()
152
- out_dict[metric] = computed_value
157
+ col_name = f"metric_{metric}" if 'metric_' not in metric else metric
158
+ metric_col_names.append(col_name)
159
+ out_dict[col_name] = computed_value
153
160
 
154
161
  # check if any kwargs named "outfile"
155
162
  csv_outfile = kwargs.get("outfile", None)
156
163
  if csv_outfile is not None:
157
- # get the file path without the extension
158
164
  filePathNoExt, _ = os.path.splitext(csv_outfile)
159
- # add the postfix to the file path
160
- csvfilename = f"{now_str()}_{filePathNoExt}{CSV_FILE_POSTFIX}.csv"
161
- csv_outfile = os.path.join(os.path.dirname(csv_outfile), csvfilename)
165
+ # pprint(f"CSV Outfile Path (No Ext): {filePathNoExt}")
166
+ csv_outfile = f'{filePathNoExt}{CSV_FILE_POSTFIX}.csv'
162
167
  elif "outdir" in kwargs:
163
168
  csvoutdir = kwargs["outdir"]
164
169
  csvfilename = f"{now_str()}_{self.get_dataset_name()}_{self.get_experiment_name()}_{CSV_FILE_POSTFIX}.csv"
@@ -166,7 +171,7 @@ class PerfCalc(ABC): # Abstract base class for performance calculation
166
171
 
167
172
  # convert out_dict to a DataFrame
168
173
  df = pd.DataFrame([out_dict])
169
- ordered_cols = REQUIRED_COLS + custom_fields + metric_names
174
+ ordered_cols = REQUIRED_COLS + custom_fields + metric_col_names
170
175
  df = df[ordered_cols] # reorder columns
171
176
 
172
177
  if csv_outfile:
@@ -208,7 +213,7 @@ class PerfCalc(ABC): # Abstract base class for performance calculation
208
213
  temp_df[col] = None # fill missing columns with None
209
214
  df = pd.concat([df, temp_df], ignore_index=True)
210
215
  # assert that REQUIRED_COLS are present in the DataFrame
211
- pprint(df.columns.tolist())
216
+ # pprint(df.columns.tolist())
212
217
  for col in REQUIRED_COLS:
213
218
  if col not in df.columns:
214
219
  raise ValueError(f"Required column '{col}' is missing from the DataFrame. REQUIRED_COLS = {REQUIRED_COLS}")
@@ -275,21 +280,36 @@ class PerfCalc(ABC): # Abstract base class for performance calculation
275
280
 
276
281
  assert os.path.exists(indir), f"Input directory {indir} does not exist."
277
282
 
283
+ csv_perf_files = []
278
284
  # Find experiment subdirectories
279
285
  exp_dirs = [
280
286
  os.path.join(indir, d)
281
287
  for d in os.listdir(indir)
282
288
  if os.path.isdir(os.path.join(indir, d))
283
289
  ]
284
- assert exp_dirs, f"No experiment directories found in {indir}."
290
+ if len(exp_dirs) == 0:
291
+ csv_perf_files = glob.glob(
292
+ os.path.join(indir, f"*{exp_perf_csv_pattern}*.csv")
293
+ )
294
+ csv_perf_files = [
295
+ file_item
296
+ for file_item in csv_perf_files
297
+ if exp_perf_csv_pattern in file_item
298
+ ]
299
+ else:
300
+ # multiple experiment directories found
301
+ # Collect all matching CSV files in those subdirs
302
+ for exp_dir in exp_dirs:
303
+ # pprint(f"Searching in experiment directory: {exp_dir}")
304
+ matched = glob.glob(
305
+ os.path.join(exp_dir, f"*{exp_perf_csv_pattern}*.csv")
306
+ )
307
+ csv_perf_files.extend(matched)
285
308
 
286
- # Collect all matching CSV files in those subdirs
287
- csv_perf_files = []
288
- for exp_dir in exp_dirs:
289
- pprint(f"Searching in experiment directory: {exp_dir}")
290
- matched = glob.glob(os.path.join(exp_dir, f"*{exp_perf_csv_pattern}*.csv"))
309
+ assert (
310
+ len(csv_perf_files) > 0
311
+ ), f"No CSV files matching pattern '{exp_perf_csv_pattern}' found in the experiment directories."
291
312
 
292
- csv_perf_files.extend(matched)
293
313
  assert len(csv_perf_files) > 0, f"No CSV files matching pattern '{exp_perf_csv_pattern}' found in the experiment directories."
294
314
 
295
315
  all_exp_perf_df = get_df_for_all_exp_perf(csv_perf_files, csv_sep=csv_sep)
@@ -0,0 +1,9 @@
1
+ def flatten_dict(d, parent_key="", sep="."):
2
+ items = {}
3
+ for k, v in d.items():
4
+ key = f"{parent_key}{sep}{k}" if parent_key else k
5
+ if isinstance(v, dict):
6
+ items.update(flatten_dict(v, key, sep=sep))
7
+ else:
8
+ items[key] = v
9
+ return items
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: halib
3
- Version: 0.1.58
3
+ Version: 0.1.59
4
4
  Summary: Small library for common tasks
5
5
  Author: Hoang Van Ha
6
6
  Author-email: hoangvanhauit@gmail.com
@@ -15,7 +15,7 @@ License-File: LICENSE.txt
15
15
 
16
16
  Helper package for coding and automation
17
17
 
18
- **Version 0.1.58**
18
+ **Version 0.1.59**
19
19
 
20
20
  + add `util/perfcalc`: abstract class for performance calculation. This class need to be inherited and implemented with specific performance calculation logic.
21
21
 
@@ -37,5 +37,6 @@ halib/system/cmd.py
37
37
  halib/system/filesys.py
38
38
  halib/utils/__init__.py
39
39
  halib/utils/dataclass_util.py
40
+ halib/utils/dict_op.py
40
41
  halib/utils/listop.py
41
42
  halib/utils/tele_noti.py
@@ -8,7 +8,7 @@ with open("requirements.txt") as f:
8
8
 
9
9
  setuptools.setup(
10
10
  name="halib",
11
- version="0.1.58",
11
+ version="0.1.59",
12
12
  author="Hoang Van Ha",
13
13
  author_email="hoangvanhauit@gmail.com",
14
14
  description="Small library for common tasks",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes