halib 0.1.90__tar.gz → 0.1.91__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.90 → halib-0.1.91}/PKG-INFO +4 -1
- {halib-0.1.90 → halib-0.1.91}/README.md +3 -0
- halib-0.1.91/halib/research/params_gen.py +108 -0
- {halib-0.1.90 → halib-0.1.91}/halib.egg-info/PKG-INFO +4 -1
- {halib-0.1.90 → halib-0.1.91}/halib.egg-info/SOURCES.txt +1 -0
- {halib-0.1.90 → halib-0.1.91}/setup.py +1 -1
- {halib-0.1.90 → halib-0.1.91}/.gitignore +0 -0
- {halib-0.1.90 → halib-0.1.91}/GDriveFolder.txt +0 -0
- {halib-0.1.90 → halib-0.1.91}/LICENSE.txt +0 -0
- {halib-0.1.90 → halib-0.1.91}/MANIFEST.in +0 -0
- {halib-0.1.90 → halib-0.1.91}/guide_publish_pip.pdf +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/__init__.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/common.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/cuda.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/filetype/__init__.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/filetype/csvfile.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/filetype/jsonfile.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/filetype/textfile.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/filetype/videofile.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/filetype/yamlfile.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/online/__init__.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/online/gdrive.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/online/gdrive_mkdir.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/online/gdrive_test.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/online/projectmake.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/__init__.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/base_config.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/base_exp.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/dataset.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/metrics.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/mics.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/perfcalc.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/perftb.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/plot.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/profiler.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/torchloader.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/research/wandb_op.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/rich_color.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/system/__init__.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/system/cmd.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/system/filesys.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/utils/__init__.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/utils/dataclass_util.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/utils/dict_op.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/utils/gpu_mon.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/utils/listop.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/utils/tele_noti.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib/utils/video.py +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib.egg-info/dependency_links.txt +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib.egg-info/requires.txt +0 -0
- {halib-0.1.90 → halib-0.1.91}/halib.egg-info/top_level.txt +0 -0
- {halib-0.1.90 → halib-0.1.91}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: halib
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.91
|
4
4
|
Summary: Small library for common tasks
|
5
5
|
Author: Hoang Van Ha
|
6
6
|
Author-email: hoangvanhauit@gmail.com
|
@@ -52,6 +52,9 @@ Dynamic: summary
|
|
52
52
|
|
53
53
|
Helper package for coding and automation
|
54
54
|
|
55
|
+
**Version 0.1.91**
|
56
|
+
+ `research/param_gen`: add `ParamGen` class to generate parameter list from yaml file for hyperparameter search (grid search, random search, etc.)
|
57
|
+
|
55
58
|
**Version 0.1.90**
|
56
59
|
|
57
60
|
+ `research/profiler`: add `zProfiler` class to measure execution time of contexts and steps, with support for dynamic color scales in plots.
|
@@ -1,5 +1,8 @@
|
|
1
1
|
Helper package for coding and automation
|
2
2
|
|
3
|
+
**Version 0.1.91**
|
4
|
+
+ `research/param_gen`: add `ParamGen` class to generate parameter list from yaml file for hyperparameter search (grid search, random search, etc.)
|
5
|
+
|
3
6
|
**Version 0.1.90**
|
4
7
|
|
5
8
|
+ `research/profiler`: add `zProfiler` class to measure execution time of contexts and steps, with support for dynamic color scales in plots.
|
@@ -0,0 +1,108 @@
|
|
1
|
+
from typing import Dict, Any, List
|
2
|
+
import numpy as np
|
3
|
+
from ..common import *
|
4
|
+
from ..filetype import yamlfile
|
5
|
+
import yaml
|
6
|
+
import os
|
7
|
+
|
8
|
+
class ParamGen:
|
9
|
+
|
10
|
+
@staticmethod
|
11
|
+
def build_from_file(params_file):
|
12
|
+
builder = ParamGen(params_file)
|
13
|
+
return builder.params
|
14
|
+
|
15
|
+
def __init__(self, params_file=None):
|
16
|
+
self.params = {}
|
17
|
+
assert os.path.isfile(params_file), f"params_file not found: {params_file}"
|
18
|
+
self.params = self._build(params_file)
|
19
|
+
|
20
|
+
def _expand_param(self, param_name: str, config: Dict[str, Any]) -> List[Any]:
|
21
|
+
"""
|
22
|
+
Validates and expands the values for a single parameter configuration.
|
23
|
+
|
24
|
+
Args:
|
25
|
+
param_name: The name of the parameter being processed.
|
26
|
+
config: The configuration dictionary for this parameter.
|
27
|
+
|
28
|
+
Returns:
|
29
|
+
A list of the expanded values for the parameter.
|
30
|
+
|
31
|
+
Raises:
|
32
|
+
TypeError: If the configuration or its values have an incorrect type.
|
33
|
+
ValueError: If the configuration is missing keys or has an invalid structure.
|
34
|
+
"""
|
35
|
+
# 1. Validate the configuration structure
|
36
|
+
if not isinstance(config, dict):
|
37
|
+
raise TypeError(f"Config for '{param_name}' must be a dictionary.")
|
38
|
+
|
39
|
+
if "type" not in config or "values" not in config:
|
40
|
+
raise ValueError(
|
41
|
+
f"Config for '{param_name}' must contain 'type' and 'values' keys."
|
42
|
+
)
|
43
|
+
|
44
|
+
gen_type = config["type"]
|
45
|
+
values = config["values"]
|
46
|
+
|
47
|
+
# 2. Handle the generation based on type
|
48
|
+
if gen_type == "list":
|
49
|
+
# Ensure values are returned as a list, even if a single item was provided
|
50
|
+
return values if isinstance(values, list) else [values]
|
51
|
+
|
52
|
+
elif gen_type == "range":
|
53
|
+
if not isinstance(values, list) or len(values) != 3:
|
54
|
+
raise ValueError(
|
55
|
+
f"For 'range' type on '{param_name}', 'values' must be a list of 3 numbers "
|
56
|
+
f"[start, end, step], but got: {values}"
|
57
|
+
)
|
58
|
+
|
59
|
+
start, end, step = values
|
60
|
+
if all(isinstance(v, int) for v in values):
|
61
|
+
return list(range(start, end, step))
|
62
|
+
elif all(isinstance(v, (int, float)) for v in values):
|
63
|
+
# Use numpy for floating point ranges
|
64
|
+
temp_list = list(np.arange(start, end, step))
|
65
|
+
# convert to float (not np.float)
|
66
|
+
return [float(v) for v in temp_list]
|
67
|
+
else:
|
68
|
+
raise TypeError(
|
69
|
+
f"All 'values' for 'range' on '{param_name}' must be numbers."
|
70
|
+
)
|
71
|
+
|
72
|
+
else:
|
73
|
+
raise ValueError(
|
74
|
+
f"Invalid 'type' for '{param_name}': '{gen_type}'. Must be 'list' or 'range'."
|
75
|
+
)
|
76
|
+
|
77
|
+
def _build(self, params_file):
|
78
|
+
"""
|
79
|
+
Builds a full optimization configuration by expanding parameter values based on their type.
|
80
|
+
|
81
|
+
This function processes a dictionary where each key is a parameter name and each value
|
82
|
+
is a config dict specifying the 'type' ('list' or 'range') and 'values' for generation.
|
83
|
+
|
84
|
+
Args:
|
85
|
+
opt_cfg: The input configuration dictionary.
|
86
|
+
Example:
|
87
|
+
{
|
88
|
+
"learning_rate": {"type": "range", "values": [0.01, 0.1, 0.01]},
|
89
|
+
"optimizer": {"type": "list", "values": ["adam", "sgd"]},
|
90
|
+
"epochs": {"type": "list", "values": 100}
|
91
|
+
}
|
92
|
+
|
93
|
+
Returns:
|
94
|
+
A dictionary with parameter names mapped to their fully expanded list of values.
|
95
|
+
"""
|
96
|
+
cfg_raw_dict = yamlfile.load_yaml(params_file, to_dict=True)
|
97
|
+
if not isinstance(cfg_raw_dict, dict):
|
98
|
+
raise TypeError("The entire opt_cfg must be a dictionary.")
|
99
|
+
|
100
|
+
# Use a dictionary comprehension for a clean and efficient build
|
101
|
+
return {
|
102
|
+
param_name: self._expand_param(param_name, config)
|
103
|
+
for param_name, config in cfg_raw_dict.items()
|
104
|
+
}
|
105
|
+
|
106
|
+
def save(self, outfile):
|
107
|
+
with open(outfile, "w") as f:
|
108
|
+
yaml.dump(self.params, f)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: halib
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.91
|
4
4
|
Summary: Small library for common tasks
|
5
5
|
Author: Hoang Van Ha
|
6
6
|
Author-email: hoangvanhauit@gmail.com
|
@@ -52,6 +52,9 @@ Dynamic: summary
|
|
52
52
|
|
53
53
|
Helper package for coding and automation
|
54
54
|
|
55
|
+
**Version 0.1.91**
|
56
|
+
+ `research/param_gen`: add `ParamGen` class to generate parameter list from yaml file for hyperparameter search (grid search, random search, etc.)
|
57
|
+
|
55
58
|
**Version 0.1.90**
|
56
59
|
|
57
60
|
+ `research/profiler`: add `zProfiler` class to measure execution time of contexts and steps, with support for dynamic color scales in plots.
|
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
|
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
|