halib 0.1.48__py3-none-any.whl → 0.1.49__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.
@@ -0,0 +1,116 @@
1
+ import glob
2
+ from rich.pretty import pprint
3
+ import os
4
+ import subprocess
5
+ import argparse
6
+ import wandb
7
+ from tqdm import tqdm
8
+ from rich.console import Console
9
+ console = Console()
10
+
11
+ def sync_runs(outdir):
12
+ outdir = os.path.abspath(outdir)
13
+ assert os.path.exists(outdir), f"Output directory {outdir} does not exist."
14
+ sub_dirs = [name for name in os.listdir(outdir) if os.path.isdir(os.path.join(outdir, name))]
15
+ assert len(sub_dirs) > 0, f"No subdirectories found in {outdir}."
16
+ console.rule("Parent Directory")
17
+ console.print(f"[yellow]{outdir}[/yellow]")
18
+
19
+ exp_dirs = [os.path.join(outdir, sub_dir) for sub_dir in sub_dirs]
20
+ wandb_dirs = []
21
+ for exp_dir in exp_dirs:
22
+ wandb_dirs.extend(glob.glob(f"{exp_dir}/wandb/*run-*"))
23
+ if len(wandb_dirs) == 0:
24
+ console.print(f"No wandb runs found in {outdir}.")
25
+ return
26
+ else:
27
+ console.print(f"Found [bold]{len(wandb_dirs)}[/bold] wandb runs in {outdir}.")
28
+ for i, wandb_dir in enumerate(wandb_dirs):
29
+ console.rule(f"Syncing wandb run {i + 1}/{len(wandb_dirs)}")
30
+ console.print(f"Syncing: {wandb_dir}")
31
+ process = subprocess.Popen(
32
+ ["wandb", "sync", wandb_dir],
33
+ stdout=subprocess.PIPE,
34
+ stderr=subprocess.STDOUT,
35
+ text=True,
36
+ )
37
+
38
+ for line in process.stdout:
39
+ console.print(line.strip())
40
+ if " ERROR Error while calling W&B API" in line:
41
+ break
42
+ process.stdout.close()
43
+ process.wait()
44
+ if process.returncode != 0:
45
+ console.print(f"[red]Error syncing {wandb_dir}. Return code: {process.returncode}[/red]")
46
+ else:
47
+ console.print(f"Successfully synced {wandb_dir}.")
48
+
49
+ def delete_runs(project, pattern=None):
50
+ console.rule("Delete W&B Runs")
51
+ confirm_msg = f"Are you sure you want to delete all runs in"
52
+ confirm_msg += f" \n\tproject: [red]{project}[/red]"
53
+ if pattern:
54
+ confirm_msg += f"\n\tpattern: [blue]{pattern}[/blue]"
55
+
56
+ console.print(confirm_msg)
57
+ confirmation = input(f"This action cannot be undone. [y/N]: ").strip().lower()
58
+ if confirmation != "y":
59
+ print("Cancelled.")
60
+ return
61
+
62
+ print("Confirmed. Proceeding...")
63
+ api = wandb.Api()
64
+ runs = api.runs(project)
65
+
66
+ deleted = 0
67
+ console.rule("Deleting W&B Runs")
68
+ if len(runs) == 0:
69
+ print("No runs found in the project.")
70
+ return
71
+ for run in tqdm(runs):
72
+ if pattern is None or pattern in run.name:
73
+ run.delete()
74
+ console.print(f"Deleted run: [red]{run.name}[/red]")
75
+ deleted += 1
76
+
77
+ console.print(f"Total runs deleted: {deleted}")
78
+
79
+
80
+ def valid_argument(args):
81
+ if args.op == "sync":
82
+ assert os.path.exists(args.outdir), f"Output directory {args.outdir} does not exist."
83
+ elif args.op == "delete":
84
+ assert isinstance(args.project, str) and len(args.project.strip()) > 0, "Project name must be a non-empty string."
85
+ else:
86
+ raise ValueError(f"Unknown operation: {args.op}")
87
+
88
+ def parse_args():
89
+ parser = argparse.ArgumentParser(description="Operations on W&B runs")
90
+ parser.add_argument("-op", "--op", type=str, help="Operation to perform", default="sync", choices=["delete", "sync"])
91
+ parser.add_argument("-prj", "--project", type=str, default="fire-paper2-2025", help="W&B project name")
92
+ parser.add_argument("-outdir", "--outdir", type=str, help="arg1 description", default="./zout/train")
93
+ parser.add_argument("-pt", "--pattern",
94
+ type=str,
95
+ default=None,
96
+ help="Run name pattern to match for deletion",
97
+ )
98
+
99
+ return parser.parse_args()
100
+
101
+
102
+ def main():
103
+ args = parse_args()
104
+ # Validate arguments, stop if invalid
105
+ valid_argument(args)
106
+
107
+ op = args.op
108
+ if op == "sync":
109
+ sync_runs(args.outdir)
110
+ elif op == "delete":
111
+ delete_runs(args.project, args.pattern)
112
+ else:
113
+ raise ValueError(f"Unknown operation: {op}")
114
+
115
+ if __name__ == "__main__":
116
+ main()
@@ -1,158 +1,156 @@
1
- Metadata-Version: 2.1
2
- Name: halib
3
- Version: 0.1.48
4
- Summary: Small library for common tasks
5
- Author: Hoang Van Ha
6
- Author-email: hoangvanhauit@gmail.com
7
- License: UNKNOWN
8
- Platform: UNKNOWN
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.8
13
- Description-Content-Type: text/markdown
14
- License-File: LICENSE.txt
15
- Requires-Dist: arrow
16
- Requires-Dist: click
17
- Requires-Dist: enlighten
18
- Requires-Dist: kaleido (==0.1.*)
19
- Requires-Dist: loguru
20
- Requires-Dist: more-itertools
21
- Requires-Dist: moviepy
22
- Requires-Dist: networkx
23
- Requires-Dist: numpy
24
- Requires-Dist: omegaconf
25
- Requires-Dist: opencv-python
26
- Requires-Dist: pandas
27
- Requires-Dist: Pillow
28
- Requires-Dist: Pyarrow
29
- Requires-Dist: pycurl
30
- Requires-Dist: python-telegram-bot
31
- Requires-Dist: requests
32
- Requires-Dist: rich
33
- Requires-Dist: scikit-learn
34
- Requires-Dist: matplotlib
35
- Requires-Dist: seaborn
36
- Requires-Dist: plotly
37
- Requires-Dist: pygwalker
38
- Requires-Dist: tabulate
39
- Requires-Dist: itables
40
- Requires-Dist: timebudget
41
- Requires-Dist: tqdm
42
- Requires-Dist: tube-dl
43
-
44
- Helper package for coding and automation
45
-
46
- **Version 0.1.48**
47
-
48
- + add `research` module to help with research tasks, including `benchquery` for benchmarking queries from dataframe
49
-
50
- **Version 0.1.47**
51
- + add `pprint_box` to print object/string in a box frame (like in `inspect`)
52
-
53
- **Version 0.1.46**
54
- + filter the warning message of `UserWarning: Unable to import Axes3D.`
55
- + auto_wrap_text for `fn_display_df` to avoid long text in the table
56
-
57
- **Version 0.1.42**
58
- + add <rich_color.py>: add basic color list (for easy usage)
59
-
60
- **Version 0.1.41**
61
- + add <rich_color.py> to display rich color information in <rich> python package (rcolor_str, rcolor_pallet_all, etc.)
62
-
63
- **Version 0.1.40**
64
-
65
- + update <csvfile.py> to use `itables` and `pygwalker` to display dataframe in jupyter notebook.
66
-
67
- **Version 0.1.38**
68
-
69
- + add <torchloader.py> to search for best cfg for torch dataloader (num_workers, batch_size, pin_memory, et.)
70
-
71
- **Version 0.1.37**
72
-
73
- + add <dataset.py> to help split classification dataset into train/val(test)
74
- ---
75
- **Version 0.1.33**
76
-
77
- + add `plot.py` module to plot DL model training history (with columlns: epoch, train_accuracy, val_accuracy, train_loss, val_loss) using `seaborn` and `matplotlib`
78
- ---
79
- **Version 0.1.29**
80
-
81
- + for `tele_noti` module, `kaleido==0.1.*` is required for plotly since `kaleido 0.2.*` is not working (taking for ever to generate image)
82
- ---
83
- **Version 0.1.24**
84
-
85
- + rename `sys` to `system` to avoid conflict with built-in `sys` module
86
- + add `tele_noti` module to send notification to telegram after a specific interval for training progress monitoring
87
- ---
88
- **Version 0.1.22**
89
-
90
- + add `cuda.py` module to check CUDA availability (for both pytorch and tensorflow)
91
- ---
92
- **Version 0.1.21**
93
-
94
- + using `networkx` and `omegaconf` to allow yaml file inheritance and override
95
- ---
96
- **Version 0.1.15**
97
-
98
- + `__init__.py`: add common logging library; also `console_log` decorator to log function (start and end)
99
-
100
- ---
101
-
102
- **Version 0.1.10**
103
-
104
- + filesys: fix typo on "is_exit" to "is_exist"
105
- + gdrive: now support uploading file to folder and return direct link (shareable link)
106
-
107
- **Version 0.1.9**
108
-
109
- + add dependencies requirement.txt
110
-
111
- **Version 0.1.8**
112
-
113
- Fix bugs:
114
-
115
- + [performance] instead of inserting directly new rows into table dataframe, first insert it into in-memory `row_pool_dict`, that fill data in that dict into the actual dataframe when needed.
116
-
117
- ---
118
-
119
- **Version 0.1.7**
120
-
121
- Fix bugs:
122
-
123
- + fix insert into table so slow by allowing insert multiple rows at once
124
-
125
- ---
126
-
127
- **Version 0.1.6**
128
-
129
- New features:
130
-
131
- + add DFCreator for manipulating table (DataFrame) - create, insert row, display, write to file
132
-
133
- ---
134
-
135
- **Version 0.1.5**
136
-
137
- New Features
138
-
139
- + add cmd module
140
- + new package structure
141
-
142
- ---
143
-
144
- **Version 0.1.4**
145
-
146
- New Features
147
-
148
- + add support to create Bitbucket Project from template
149
-
150
- ---
151
-
152
- **Version 0.1.2**
153
-
154
- New Features
155
-
156
- + add support to upload local to google drive.
157
-
158
-
1
+ Metadata-Version: 2.1
2
+ Name: halib
3
+ Version: 0.1.49
4
+ Summary: Small library for common tasks
5
+ Author: Hoang Van Ha
6
+ Author-email: hoangvanhauit@gmail.com
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE.txt
13
+ Requires-Dist: arrow
14
+ Requires-Dist: click
15
+ Requires-Dist: enlighten
16
+ Requires-Dist: kaleido ==0.1.*
17
+ Requires-Dist: loguru
18
+ Requires-Dist: more-itertools
19
+ Requires-Dist: moviepy
20
+ Requires-Dist: networkx
21
+ Requires-Dist: numpy
22
+ Requires-Dist: omegaconf
23
+ Requires-Dist: opencv-python
24
+ Requires-Dist: pandas
25
+ Requires-Dist: Pillow
26
+ Requires-Dist: Pyarrow
27
+ Requires-Dist: pycurl
28
+ Requires-Dist: python-telegram-bot
29
+ Requires-Dist: requests
30
+ Requires-Dist: rich
31
+ Requires-Dist: scikit-learn
32
+ Requires-Dist: matplotlib
33
+ Requires-Dist: seaborn
34
+ Requires-Dist: plotly
35
+ Requires-Dist: pygwalker
36
+ Requires-Dist: tabulate
37
+ Requires-Dist: itables
38
+ Requires-Dist: timebudget
39
+ Requires-Dist: tqdm
40
+ Requires-Dist: tube-dl
41
+ Requires-Dist: wandb
42
+
43
+ Helper package for coding and automation
44
+
45
+ **Version 0.1.49**
46
+
47
+ + add `research` package to help with research tasks, including `benchquery` for benchmarking queries from dataframe
48
+ + add `wandb` module to allow easy sync offline data to Weights & Biases (wandb) and batch clear wandb runs.
49
+
50
+ **Version 0.1.47**
51
+ + add `pprint_box` to print object/string in a box frame (like in `inspect`)
52
+
53
+ **Version 0.1.46**
54
+ + filter the warning message of `UserWarning: Unable to import Axes3D.`
55
+ + auto_wrap_text for `fn_display_df` to avoid long text in the table
56
+
57
+ **Version 0.1.42**
58
+ + add <rich_color.py>: add basic color list (for easy usage)
59
+
60
+ **Version 0.1.41**
61
+ + add <rich_color.py> to display rich color information in <rich> python package (rcolor_str, rcolor_pallet_all, etc.)
62
+
63
+ **Version 0.1.40**
64
+
65
+ + update <csvfile.py> to use `itables` and `pygwalker` to display dataframe in jupyter notebook.
66
+
67
+ **Version 0.1.38**
68
+
69
+ + add <torchloader.py> to search for best cfg for torch dataloader (num_workers, batch_size, pin_memory, et.)
70
+
71
+ **Version 0.1.37**
72
+
73
+ + add <dataset.py> to help split classification dataset into train/val(test)
74
+ ---
75
+ **Version 0.1.33**
76
+
77
+ + add `plot.py` module to plot DL model training history (with columlns: epoch, train_accuracy, val_accuracy, train_loss, val_loss) using `seaborn` and `matplotlib`
78
+ ---
79
+ **Version 0.1.29**
80
+
81
+ + for `tele_noti` module, `kaleido==0.1.*` is required for plotly since `kaleido 0.2.*` is not working (taking for ever to generate image)
82
+ ---
83
+ **Version 0.1.24**
84
+
85
+ + rename `sys` to `system` to avoid conflict with built-in `sys` module
86
+ + add `tele_noti` module to send notification to telegram after a specific interval for training progress monitoring
87
+ ---
88
+ **Version 0.1.22**
89
+
90
+ + add `cuda.py` module to check CUDA availability (for both pytorch and tensorflow)
91
+ ---
92
+ **Version 0.1.21**
93
+
94
+ + using `networkx` and `omegaconf` to allow yaml file inheritance and override
95
+ ---
96
+ **Version 0.1.15**
97
+
98
+ + `__init__.py`: add common logging library; also `console_log` decorator to log function (start and end)
99
+
100
+ ---
101
+
102
+ **Version 0.1.10**
103
+
104
+ + filesys: fix typo on "is_exit" to "is_exist"
105
+ + gdrive: now support uploading file to folder and return direct link (shareable link)
106
+
107
+ **Version 0.1.9**
108
+
109
+ + add dependencies requirement.txt
110
+
111
+ **Version 0.1.8**
112
+
113
+ Fix bugs:
114
+
115
+ + [performance] instead of inserting directly new rows into table dataframe, first insert it into in-memory `row_pool_dict`, that fill data in that dict into the actual dataframe when needed.
116
+
117
+ ---
118
+
119
+ **Version 0.1.7**
120
+
121
+ Fix bugs:
122
+
123
+ + fix insert into table so slow by allowing insert multiple rows at once
124
+
125
+ ---
126
+
127
+ **Version 0.1.6**
128
+
129
+ New features:
130
+
131
+ + add DFCreator for manipulating table (DataFrame) - create, insert row, display, write to file
132
+
133
+ ---
134
+
135
+ **Version 0.1.5**
136
+
137
+ New Features
138
+
139
+ + add cmd module
140
+ + new package structure
141
+
142
+ ---
143
+
144
+ **Version 0.1.4**
145
+
146
+ New Features
147
+
148
+ + add support to create Bitbucket Project from template
149
+
150
+ ---
151
+
152
+ **Version 0.1.2**
153
+
154
+ New Features
155
+
156
+ + add support to upload local to google drive.
@@ -32,6 +32,7 @@ halib/research/benchquery.py,sha256=FuKnbWQtCEoRRtJAfN-zaN-jPiO_EzsakmTOMiqi7GQ,
32
32
  halib/research/dataset.py,sha256=QU0Hr5QFb8_XlvnOMgC9QJGIpwXAZ9lDd0RdQi_QRec,6743
33
33
  halib/research/plot.py,sha256=-pDUk4z3C_GnyJ5zWmf-mGMdT4gaipVJWzIgcpIPiRk,9448
34
34
  halib/research/torchloader.py,sha256=yqUjcSiME6H5W210363HyRUrOi3ISpUFAFkTr1w4DCw,6503
35
+ halib/research/wandb_op.py,sha256=YzLEqME5kIRxi3VvjFkW83wnFrsn92oYeqYuNwtYRkY,4188
35
36
  halib/sys/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
37
  halib/sys/cmd.py,sha256=b2x7JPcNnFjLGheIESVYvqAb-w2UwBM1PAwYxMZ5YjA,228
37
38
  halib/sys/filesys.py,sha256=ERpnELLDKJoTIIKf-AajgkY62nID4qmqmX5TkE95APU,2931
@@ -41,8 +42,8 @@ halib/system/filesys.py,sha256=ERpnELLDKJoTIIKf-AajgkY62nID4qmqmX5TkE95APU,2931
41
42
  halib/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
43
  halib/utils/listop.py,sha256=Vpa8_2fI0wySpB2-8sfTBkyi_A4FhoFVVvFiuvW8N64,339
43
44
  halib/utils/tele_noti.py,sha256=-4WXZelCA4W9BroapkRyIdUu9cUVrcJJhegnMs_WpGU,5928
44
- halib-0.1.48.dist-info/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
45
- halib-0.1.48.dist-info/METADATA,sha256=iaGDSmQyhQWr6hLkyRpK6ZpkW6tuoAoGOrPNuK3CQp8,3960
46
- halib-0.1.48.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
47
- halib-0.1.48.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
48
- halib-0.1.48.dist-info/RECORD,,
45
+ halib-0.1.49.dist-info/LICENSE.txt,sha256=qZssdna4aETiR8znYsShUjidu-U4jUT9Q-EWNlZ9yBQ,1100
46
+ halib-0.1.49.dist-info/METADATA,sha256=G3MPTsD8-W3o1MptmTpzCvslPuQg6uVISpkSwRoLJqw,4208
47
+ halib-0.1.49.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
48
+ halib-0.1.49.dist-info/top_level.txt,sha256=7AD6PLaQTreE0Fn44mdZsoHBe_Zdd7GUmjsWPyQ7I-k,6
49
+ halib-0.1.49.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.1)
2
+ Generator: setuptools (70.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5