halib 0.1.57__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.
- {halib-0.1.57 → halib-0.1.59}/PKG-INFO +2 -2
- {halib-0.1.57 → halib-0.1.59}/README.md +1 -1
- {halib-0.1.57 → halib-0.1.59}/halib/research/perfcalc.py +36 -16
- halib-0.1.59/halib/utils/dict_op.py +9 -0
- {halib-0.1.57 → halib-0.1.59}/halib.egg-info/PKG-INFO +2 -2
- {halib-0.1.57 → halib-0.1.59}/halib.egg-info/SOURCES.txt +1 -0
- {halib-0.1.57 → halib-0.1.59}/setup.py +1 -1
- {halib-0.1.57 → halib-0.1.59}/.gitignore +0 -0
- {halib-0.1.57 → halib-0.1.59}/GDriveFolder.txt +0 -0
- {halib-0.1.57 → halib-0.1.59}/LICENSE.txt +0 -0
- {halib-0.1.57 → halib-0.1.59}/MANIFEST.in +0 -0
- {halib-0.1.57 → halib-0.1.59}/guide_publish_pip.pdf +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/__init__.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/common.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/cuda.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/filetype/__init__.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/filetype/csvfile.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/filetype/jsonfile.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/filetype/textfile.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/filetype/videofile.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/filetype/yamlfile.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/online/__init__.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/online/gdrive.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/online/gdrive_mkdir.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/online/gdrive_test.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/online/projectmake.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/research/__init__.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/research/dataset.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/research/perftb.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/research/plot.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/research/torchloader.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/research/wandb_op.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/rich_color.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/system/__init__.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/system/cmd.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/system/filesys.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/utils/__init__.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/utils/dataclass_util.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/utils/listop.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib/utils/tele_noti.py +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib.egg-info/dependency_links.txt +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib.egg-info/requires.txt +0 -0
- {halib-0.1.57 → halib-0.1.59}/halib.egg-info/top_level.txt +0 -0
- {halib-0.1.57 → 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.
|
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.
|
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
|
|
@@ -59,7 +59,7 @@ def valid_custom_fields(fn):
|
|
59
59
|
return wrapper
|
60
60
|
|
61
61
|
REQUIRED_COLS = ["experiment", "dataset"]
|
62
|
-
CSV_FILE_POSTFIX = "__perf
|
62
|
+
CSV_FILE_POSTFIX = "__perf"
|
63
63
|
|
64
64
|
class PerfCalc(ABC): # Abstract base class for performance calculation
|
65
65
|
@abstractmethod
|
@@ -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
|
-
|
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
|
-
|
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
|
-
#
|
160
|
-
|
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 +
|
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
|
-
|
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
|
-
|
287
|
-
|
288
|
-
|
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)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: halib
|
3
|
-
Version: 0.1.
|
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.
|
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
|
|
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
|
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
|