halib 0.1.46__tar.gz → 0.1.48__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.46/halib.egg-info → halib-0.1.48}/PKG-INFO +8 -1
- {halib-0.1.46 → halib-0.1.48}/README.md +7 -0
- {halib-0.1.46 → halib-0.1.48}/halib/__init__.py +3 -2
- {halib-0.1.46 → halib-0.1.48}/halib/common.py +13 -1
- halib-0.1.48/halib/research/benchquery.py +131 -0
- {halib-0.1.46/halib → halib-0.1.48/halib/research}/plot.py +3 -3
- {halib-0.1.46/halib → halib-0.1.48/halib/research}/torchloader.py +3 -3
- halib-0.1.48/halib/system/__init__.py +0 -0
- halib-0.1.48/halib/utils/__init__.py +0 -0
- {halib-0.1.46/halib → halib-0.1.48/halib/utils}/tele_noti.py +2 -2
- {halib-0.1.46 → halib-0.1.48/halib.egg-info}/PKG-INFO +8 -1
- {halib-0.1.46 → halib-0.1.48}/halib.egg-info/SOURCES.txt +8 -5
- {halib-0.1.46 → halib-0.1.48}/setup.py +1 -1
- {halib-0.1.46 → halib-0.1.48}/.gitignore +0 -0
- {halib-0.1.46 → halib-0.1.48}/GDriveFolder.txt +0 -0
- {halib-0.1.46 → halib-0.1.48}/LICENSE.txt +0 -0
- {halib-0.1.46 → halib-0.1.48}/guide_publish_pip.pdf +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/cuda.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/filetype/__init__.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/filetype/csvfile.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/filetype/jsonfile.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/filetype/textfile.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/filetype/videofile.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/filetype/yamlfile.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/online/__init__.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/online/gdrive.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/online/gdrive_mkdir.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/online/gdrive_test.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/online/projectmake.py +0 -0
- {halib-0.1.46/halib/system → halib-0.1.48/halib/research}/__init__.py +0 -0
- {halib-0.1.46/halib → halib-0.1.48/halib/research}/dataset.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/rich_color.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/system/cmd.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib/system/filesys.py +0 -0
- {halib-0.1.46/halib → halib-0.1.48/halib/utils}/listop.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib.egg-info/dependency_links.txt +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib.egg-info/requires.txt +0 -0
- {halib-0.1.46 → halib-0.1.48}/halib.egg-info/top_level.txt +0 -0
- {halib-0.1.46 → halib-0.1.48}/setup.cfg +0 -0
- {halib-0.1.46 → halib-0.1.48}/test/test15.py +0 -0
- {halib-0.1.46 → halib-0.1.48}/test/test_df_creator.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: halib
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.48
|
4
4
|
Summary: Small library for common tasks
|
5
5
|
Author: Hoang Van Ha
|
6
6
|
Author-email: hoangvanhauit@gmail.com
|
@@ -15,6 +15,13 @@ License-File: LICENSE.txt
|
|
15
15
|
|
16
16
|
Helper package for coding and automation
|
17
17
|
|
18
|
+
**Version 0.1.48**
|
19
|
+
|
20
|
+
+ add `research` module to help with research tasks, including `benchquery` for benchmarking queries from dataframe
|
21
|
+
|
22
|
+
**Version 0.1.47**
|
23
|
+
+ add `pprint_box` to print object/string in a box frame (like in `inspect`)
|
24
|
+
|
18
25
|
**Version 0.1.46**
|
19
26
|
+ filter the warning message of `UserWarning: Unable to import Axes3D.`
|
20
27
|
+ auto_wrap_text for `fn_display_df` to avoid long text in the table
|
@@ -1,5 +1,12 @@
|
|
1
1
|
Helper package for coding and automation
|
2
2
|
|
3
|
+
**Version 0.1.48**
|
4
|
+
|
5
|
+
+ add `research` module to help with research tasks, including `benchquery` for benchmarking queries from dataframe
|
6
|
+
|
7
|
+
**Version 0.1.47**
|
8
|
+
+ add `pprint_box` to print object/string in a box frame (like in `inspect`)
|
9
|
+
|
3
10
|
**Version 0.1.46**
|
4
11
|
+ filter the warning message of `UserWarning: Unable to import Axes3D.`
|
5
12
|
+ auto_wrap_text for `fn_display_df` to avoid long text in the table
|
@@ -20,6 +20,7 @@ __all__ = [
|
|
20
20
|
"pd",
|
21
21
|
"plt",
|
22
22
|
"pprint",
|
23
|
+
"pprint_box",
|
23
24
|
"px",
|
24
25
|
"rcolor_all_str",
|
25
26
|
"rcolor_palette_all",
|
@@ -32,7 +33,7 @@ __all__ = [
|
|
32
33
|
"timebudget",
|
33
34
|
"tqdm",
|
34
35
|
"warnings",
|
35
|
-
"time"
|
36
|
+
"time",
|
36
37
|
]
|
37
38
|
import warnings
|
38
39
|
warnings.filterwarnings("ignore", message="Unable to import Axes3D")
|
@@ -53,7 +54,7 @@ from .system import cmd
|
|
53
54
|
from .system import filesys as fs
|
54
55
|
from .filetype import csvfile
|
55
56
|
from .cuda import tcuda
|
56
|
-
from .common import console, console_log, ConsoleLog, now_str, norm_str
|
57
|
+
from .common import console, console_log, ConsoleLog, now_str, norm_str, pprint_box
|
57
58
|
|
58
59
|
# for log
|
59
60
|
from loguru import logger
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import arrow
|
2
2
|
import re
|
3
3
|
from rich.console import Console
|
4
|
-
from rich.pretty import pprint
|
4
|
+
from rich.pretty import pprint, Pretty
|
5
|
+
from rich.panel import Panel
|
6
|
+
import rich
|
5
7
|
|
6
8
|
console = Console()
|
7
9
|
|
@@ -43,6 +45,16 @@ def norm_str(in_str):
|
|
43
45
|
norm_string = norm_string.strip()
|
44
46
|
return norm_string
|
45
47
|
|
48
|
+
|
49
|
+
def pprint_box(obj, title="", border_style="green"):
|
50
|
+
"""
|
51
|
+
Pretty print an object in a box.
|
52
|
+
"""
|
53
|
+
rich.print(
|
54
|
+
Panel(Pretty(obj, expand_all=True), title=title, border_style=border_style)
|
55
|
+
)
|
56
|
+
|
57
|
+
|
46
58
|
def console_rule(msg, do_norm_msg=True, is_end_tag=False):
|
47
59
|
msg = norm_str(msg) if do_norm_msg else msg
|
48
60
|
if is_end_tag:
|
@@ -0,0 +1,131 @@
|
|
1
|
+
import pandas as pd
|
2
|
+
from rich.pretty import pprint
|
3
|
+
from argparse import ArgumentParser
|
4
|
+
|
5
|
+
def cols_to_col_groups(df):
|
6
|
+
columns = list(df.columns)
|
7
|
+
# pprint(columns)
|
8
|
+
|
9
|
+
col_groups = []
|
10
|
+
current_group = []
|
11
|
+
|
12
|
+
def have_unnamed(col_group):
|
13
|
+
return any("unnamed" in col.lower() for col in col_group)
|
14
|
+
|
15
|
+
for i, col in enumerate(columns):
|
16
|
+
# Add the first column to the current group
|
17
|
+
if not current_group:
|
18
|
+
current_group.append(col)
|
19
|
+
continue
|
20
|
+
|
21
|
+
prev_col = columns[i - 1]
|
22
|
+
# Check if current column is "unnamed" or shares base name with previous
|
23
|
+
# Assuming "equal" means same base name (before any suffix like '_1')
|
24
|
+
base_prev = (
|
25
|
+
prev_col.split("_")[0].lower() if "_" in prev_col else prev_col.lower()
|
26
|
+
)
|
27
|
+
base_col = col.split("_")[0].lower() if "_" in col else col.lower()
|
28
|
+
is_unnamed = "unnamed" in col.lower()
|
29
|
+
is_equal = base_col == base_prev
|
30
|
+
|
31
|
+
if is_unnamed or is_equal:
|
32
|
+
# Add to current group
|
33
|
+
current_group.append(col)
|
34
|
+
else:
|
35
|
+
# Start a new group
|
36
|
+
col_groups.append(current_group)
|
37
|
+
current_group = [col]
|
38
|
+
# Append the last group
|
39
|
+
if current_group:
|
40
|
+
col_groups.append(current_group)
|
41
|
+
meta_dict = {"common_cols": [], "db_cols": []}
|
42
|
+
for group in col_groups:
|
43
|
+
if not have_unnamed(group):
|
44
|
+
meta_dict["common_cols"].extend(group)
|
45
|
+
else:
|
46
|
+
# find the first unnamed column
|
47
|
+
named_col = next(
|
48
|
+
(col for col in group if "unnamed" not in col.lower()), None
|
49
|
+
)
|
50
|
+
group_cols = [f"{named_col}_{i}" for i in range(len(group))]
|
51
|
+
meta_dict["db_cols"].extend(group_cols)
|
52
|
+
return meta_dict
|
53
|
+
|
54
|
+
# def bech_by_db_name(df, db_list="db1, db2", key_metrics="p, r, f1, acc"):
|
55
|
+
|
56
|
+
|
57
|
+
def str_2_list(input_str, sep=","):
|
58
|
+
out_ls = []
|
59
|
+
if len(input_str.strip()) == 0:
|
60
|
+
return out_ls
|
61
|
+
if sep not in input_str:
|
62
|
+
out_ls.append(input_str.strip())
|
63
|
+
return out_ls
|
64
|
+
else:
|
65
|
+
out_ls = [item.strip() for item in input_str.split(sep) if item.strip()]
|
66
|
+
return out_ls
|
67
|
+
|
68
|
+
|
69
|
+
def filter_bech_df_by_db_and_metrics(df, db_list="", key_metrics=""):
|
70
|
+
meta_cols_dict = cols_to_col_groups(df)
|
71
|
+
op_df = df.copy()
|
72
|
+
op_df.columns = (
|
73
|
+
meta_cols_dict["common_cols"].copy() + meta_cols_dict["db_cols"].copy()
|
74
|
+
)
|
75
|
+
filterd_cols = []
|
76
|
+
filterd_cols.extend(meta_cols_dict["common_cols"])
|
77
|
+
|
78
|
+
selected_db_list = str_2_list(db_list)
|
79
|
+
db_filted_cols = []
|
80
|
+
if len(selected_db_list) > 0:
|
81
|
+
for db_name in db_list.split(","):
|
82
|
+
db_name = db_name.strip()
|
83
|
+
for col_name in meta_cols_dict["db_cols"]:
|
84
|
+
if db_name.lower() in col_name.lower():
|
85
|
+
db_filted_cols.append(col_name)
|
86
|
+
else:
|
87
|
+
db_filted_cols = meta_cols_dict["db_cols"]
|
88
|
+
|
89
|
+
filterd_cols.extend(db_filted_cols)
|
90
|
+
df_filtered = op_df[filterd_cols].copy()
|
91
|
+
df_filtered
|
92
|
+
|
93
|
+
selected_metrics_ls = str_2_list(key_metrics)
|
94
|
+
if len(selected_metrics_ls) > 0:
|
95
|
+
# get the second row as metrics row (header)
|
96
|
+
metrics_row = df_filtered.iloc[0].copy()
|
97
|
+
# only get the values in columns in (db_filterd_cols)
|
98
|
+
metrics_values = metrics_row[db_filted_cols].values
|
99
|
+
keep_metrics_cols = []
|
100
|
+
# create a zip of db_filted_cols and metrics_values (in that metrics_row)
|
101
|
+
metrics_list = list(zip(metrics_values, db_filted_cols))
|
102
|
+
selected_metrics_ls = [metric.strip().lower() for metric in selected_metrics_ls]
|
103
|
+
for metric, col_name in metrics_list:
|
104
|
+
if metric.lower() in selected_metrics_ls:
|
105
|
+
keep_metrics_cols.append(col_name)
|
106
|
+
|
107
|
+
else:
|
108
|
+
pprint("No metrics selected, keeping all db columns")
|
109
|
+
keep_metrics_cols = db_filted_cols
|
110
|
+
|
111
|
+
final_filterd_cols = meta_cols_dict["common_cols"].copy() + keep_metrics_cols
|
112
|
+
df_final = df_filtered[final_filterd_cols].copy()
|
113
|
+
return df_final
|
114
|
+
|
115
|
+
|
116
|
+
def parse_args():
|
117
|
+
parser = ArgumentParser(
|
118
|
+
description="desc text")
|
119
|
+
parser.add_argument('-csv', '--csv', type=str, help='CSV file path', default=r"E:\Dev\__halib\test\bench.csv")
|
120
|
+
return parser.parse_args()
|
121
|
+
|
122
|
+
|
123
|
+
def main():
|
124
|
+
args = parse_args()
|
125
|
+
csv_file = args.csv
|
126
|
+
df = pd.read_csv(csv_file, sep=";", encoding="utf-8")
|
127
|
+
filtered_df = filter_bech_df_by_db_and_metrics(df, "bowfire", "acc")
|
128
|
+
print(filtered_df)
|
129
|
+
|
130
|
+
if __name__ == "__main__":
|
131
|
+
main()
|
@@ -1,6 +1,6 @@
|
|
1
|
-
from
|
2
|
-
from
|
3
|
-
from
|
1
|
+
from ..common import now_str, norm_str, ConsoleLog
|
2
|
+
from ..filetype import csvfile
|
3
|
+
from ..system import filesys as fs
|
4
4
|
from functools import partial
|
5
5
|
from rich.console import Console
|
6
6
|
from rich.pretty import pprint
|
@@ -6,9 +6,9 @@
|
|
6
6
|
* @desc this module works as a utility tools for finding the best configuration for dataloader (num_workers, batch_size, pin_menory, etc.) that fits your hardware.
|
7
7
|
"""
|
8
8
|
from argparse import ArgumentParser
|
9
|
-
from
|
10
|
-
from
|
11
|
-
from
|
9
|
+
from ..common import *
|
10
|
+
from ..filetype import csvfile
|
11
|
+
from ..filetype.yamlfile import load_yaml
|
12
12
|
from rich import inspect
|
13
13
|
from torch.utils.data import DataLoader
|
14
14
|
from torchvision import datasets, transforms
|
File without changes
|
File without changes
|
@@ -10,8 +10,8 @@ from rich.pretty import pprint
|
|
10
10
|
from rich.console import Console
|
11
11
|
import plotly.graph_objects as go
|
12
12
|
|
13
|
-
from
|
14
|
-
from
|
13
|
+
from ..system import filesys as fs
|
14
|
+
from ..filetype import textfile, csvfile
|
15
15
|
|
16
16
|
from argparse import ArgumentParser
|
17
17
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: halib
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.48
|
4
4
|
Summary: Small library for common tasks
|
5
5
|
Author: Hoang Van Ha
|
6
6
|
Author-email: hoangvanhauit@gmail.com
|
@@ -15,6 +15,13 @@ License-File: LICENSE.txt
|
|
15
15
|
|
16
16
|
Helper package for coding and automation
|
17
17
|
|
18
|
+
**Version 0.1.48**
|
19
|
+
|
20
|
+
+ add `research` module to help with research tasks, including `benchquery` for benchmarking queries from dataframe
|
21
|
+
|
22
|
+
**Version 0.1.47**
|
23
|
+
+ add `pprint_box` to print object/string in a box frame (like in `inspect`)
|
24
|
+
|
18
25
|
**Version 0.1.46**
|
19
26
|
+ filter the warning message of `UserWarning: Unable to import Axes3D.`
|
20
27
|
+ auto_wrap_text for `fn_display_df` to avoid long text in the table
|
@@ -7,12 +7,7 @@ setup.py
|
|
7
7
|
halib/__init__.py
|
8
8
|
halib/common.py
|
9
9
|
halib/cuda.py
|
10
|
-
halib/dataset.py
|
11
|
-
halib/listop.py
|
12
|
-
halib/plot.py
|
13
10
|
halib/rich_color.py
|
14
|
-
halib/tele_noti.py
|
15
|
-
halib/torchloader.py
|
16
11
|
halib.egg-info/PKG-INFO
|
17
12
|
halib.egg-info/SOURCES.txt
|
18
13
|
halib.egg-info/dependency_links.txt
|
@@ -29,8 +24,16 @@ halib/online/gdrive.py
|
|
29
24
|
halib/online/gdrive_mkdir.py
|
30
25
|
halib/online/gdrive_test.py
|
31
26
|
halib/online/projectmake.py
|
27
|
+
halib/research/__init__.py
|
28
|
+
halib/research/benchquery.py
|
29
|
+
halib/research/dataset.py
|
30
|
+
halib/research/plot.py
|
31
|
+
halib/research/torchloader.py
|
32
32
|
halib/system/__init__.py
|
33
33
|
halib/system/cmd.py
|
34
34
|
halib/system/filesys.py
|
35
|
+
halib/utils/__init__.py
|
36
|
+
halib/utils/listop.py
|
37
|
+
halib/utils/tele_noti.py
|
35
38
|
test/test15.py
|
36
39
|
test/test_df_creator.py
|
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
|