halib 0.1.67__tar.gz → 0.1.73__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 (49) hide show
  1. {halib-0.1.67 → halib-0.1.73}/PKG-INFO +10 -41
  2. {halib-0.1.67 → halib-0.1.73}/README.md +4 -0
  3. halib-0.1.73/halib/research/base_config.py +100 -0
  4. halib-0.1.73/halib/research/base_exp.py +99 -0
  5. {halib-0.1.67 → halib-0.1.73}/halib.egg-info/PKG-INFO +10 -41
  6. {halib-0.1.67 → halib-0.1.73}/halib.egg-info/SOURCES.txt +2 -0
  7. {halib-0.1.67 → halib-0.1.73}/setup.py +1 -1
  8. {halib-0.1.67 → halib-0.1.73}/.gitignore +0 -0
  9. {halib-0.1.67 → halib-0.1.73}/GDriveFolder.txt +0 -0
  10. {halib-0.1.67 → halib-0.1.73}/LICENSE.txt +0 -0
  11. {halib-0.1.67 → halib-0.1.73}/MANIFEST.in +0 -0
  12. {halib-0.1.67 → halib-0.1.73}/guide_publish_pip.pdf +0 -0
  13. {halib-0.1.67 → halib-0.1.73}/halib/__init__.py +0 -0
  14. {halib-0.1.67 → halib-0.1.73}/halib/common.py +0 -0
  15. {halib-0.1.67 → halib-0.1.73}/halib/cuda.py +0 -0
  16. {halib-0.1.67 → halib-0.1.73}/halib/filetype/__init__.py +0 -0
  17. {halib-0.1.67 → halib-0.1.73}/halib/filetype/csvfile.py +0 -0
  18. {halib-0.1.67 → halib-0.1.73}/halib/filetype/jsonfile.py +0 -0
  19. {halib-0.1.67 → halib-0.1.73}/halib/filetype/textfile.py +0 -0
  20. {halib-0.1.67 → halib-0.1.73}/halib/filetype/videofile.py +0 -0
  21. {halib-0.1.67 → halib-0.1.73}/halib/filetype/yamlfile.py +0 -0
  22. {halib-0.1.67 → halib-0.1.73}/halib/online/__init__.py +0 -0
  23. {halib-0.1.67 → halib-0.1.73}/halib/online/gdrive.py +0 -0
  24. {halib-0.1.67 → halib-0.1.73}/halib/online/gdrive_mkdir.py +0 -0
  25. {halib-0.1.67 → halib-0.1.73}/halib/online/gdrive_test.py +0 -0
  26. {halib-0.1.67 → halib-0.1.73}/halib/online/projectmake.py +0 -0
  27. {halib-0.1.67 → halib-0.1.73}/halib/research/__init__.py +0 -0
  28. {halib-0.1.67 → halib-0.1.73}/halib/research/dataset.py +0 -0
  29. {halib-0.1.67 → halib-0.1.73}/halib/research/metrics.py +0 -0
  30. {halib-0.1.67 → halib-0.1.73}/halib/research/perfcalc.py +0 -0
  31. {halib-0.1.67 → halib-0.1.73}/halib/research/perftb.py +0 -0
  32. {halib-0.1.67 → halib-0.1.73}/halib/research/plot.py +0 -0
  33. {halib-0.1.67 → halib-0.1.73}/halib/research/torchloader.py +0 -0
  34. {halib-0.1.67 → halib-0.1.73}/halib/research/wandb_op.py +0 -0
  35. {halib-0.1.67 → halib-0.1.73}/halib/rich_color.py +0 -0
  36. {halib-0.1.67 → halib-0.1.73}/halib/system/__init__.py +0 -0
  37. {halib-0.1.67 → halib-0.1.73}/halib/system/cmd.py +0 -0
  38. {halib-0.1.67 → halib-0.1.73}/halib/system/filesys.py +0 -0
  39. {halib-0.1.67 → halib-0.1.73}/halib/utils/__init__.py +0 -0
  40. {halib-0.1.67 → halib-0.1.73}/halib/utils/dataclass_util.py +0 -0
  41. {halib-0.1.67 → halib-0.1.73}/halib/utils/dict_op.py +0 -0
  42. {halib-0.1.67 → halib-0.1.73}/halib/utils/gpu_mon.py +0 -0
  43. {halib-0.1.67 → halib-0.1.73}/halib/utils/listop.py +0 -0
  44. {halib-0.1.67 → halib-0.1.73}/halib/utils/tele_noti.py +0 -0
  45. {halib-0.1.67 → halib-0.1.73}/halib/utils/video.py +0 -0
  46. {halib-0.1.67 → halib-0.1.73}/halib.egg-info/dependency_links.txt +0 -0
  47. {halib-0.1.67 → halib-0.1.73}/halib.egg-info/requires.txt +0 -0
  48. {halib-0.1.67 → halib-0.1.73}/halib.egg-info/top_level.txt +0 -0
  49. {halib-0.1.67 → halib-0.1.73}/setup.cfg +0 -0
@@ -1,57 +1,24 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: halib
3
- Version: 0.1.67
3
+ Version: 0.1.73
4
4
  Summary: Small library for common tasks
5
5
  Author: Hoang Van Ha
6
6
  Author-email: hoangvanhauit@gmail.com
7
+ License: UNKNOWN
8
+ Platform: UNKNOWN
7
9
  Classifier: Programming Language :: Python :: 3
8
10
  Classifier: License :: OSI Approved :: MIT License
9
11
  Classifier: Operating System :: OS Independent
10
12
  Requires-Python: >=3.8
11
13
  Description-Content-Type: text/markdown
12
14
  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
- Requires-Dist: dataclass-wizard
43
- Dynamic: author
44
- Dynamic: author-email
45
- Dynamic: classifier
46
- Dynamic: description
47
- Dynamic: description-content-type
48
- Dynamic: license-file
49
- Dynamic: requires-dist
50
- Dynamic: requires-python
51
- Dynamic: summary
52
15
 
53
16
  Helper package for coding and automation
54
17
 
18
+ **Version 0.1.73**
19
+
20
+ + `research/base_exp`: add base experiment class to handle common experiment tasks, including performance calculation and saving results.
21
+
55
22
  **Version 0.1.67**
56
23
 
57
24
  + now use `uv` for venv management
@@ -188,3 +155,5 @@ New Features
188
155
  New Features
189
156
 
190
157
  + add support to upload local to google drive.
158
+
159
+
@@ -1,5 +1,9 @@
1
1
  Helper package for coding and automation
2
2
 
3
+ **Version 0.1.73**
4
+
5
+ + `research/base_exp`: add base experiment class to handle common experiment tasks, including performance calculation and saving results.
6
+
3
7
  **Version 0.1.67**
4
8
 
5
9
  + now use `uv` for venv management
@@ -0,0 +1,100 @@
1
+ import os
2
+ from rich.pretty import pprint
3
+ from abc import ABC, abstractmethod
4
+ from dataclass_wizard import YAMLWizard
5
+
6
+
7
+ class NamedConfig(ABC):
8
+ """
9
+ Base class for named configurations.
10
+ All configurations should have a name.
11
+ """
12
+
13
+ @abstractmethod
14
+ def get_name(self):
15
+ """
16
+ Get the name of the configuration.
17
+ This method should be implemented in subclasses.
18
+ """
19
+ pass
20
+
21
+
22
+ class ExpBaseConfig(ABC, YAMLWizard):
23
+ """
24
+ Base class for configuration objects.
25
+ What a cfg class must have:
26
+ 1 - a dataset cfg
27
+ 2 - a metric cfg
28
+ 3 - a method cfg
29
+ """
30
+
31
+ # Save to yaml fil
32
+ def save_to_outdir(
33
+ self, filename: str = "config.yaml", outdir=None, override: bool = False
34
+ ) -> None:
35
+ """
36
+ Save the configuration to the output directory.
37
+ """
38
+ if outdir is not None:
39
+ output_dir = outdir
40
+ else:
41
+ output_dir = self.get_outdir()
42
+ os.makedirs(output_dir, exist_ok=True)
43
+ assert (output_dir is not None) and (
44
+ os.path.isdir(output_dir)
45
+ ), f"Output directory '{output_dir}' does not exist or is not a directory."
46
+ file_path = os.path.join(output_dir, filename)
47
+ if os.path.exists(file_path) and not override:
48
+ pprint(
49
+ f"File '{file_path}' already exists. Use 'override=True' to overwrite."
50
+ )
51
+ else:
52
+ # method of YAMLWizard to_yaml_file
53
+ self.to_yaml_file(file_path)
54
+
55
+ @classmethod
56
+ @abstractmethod
57
+ # load from a custom YAML file
58
+ def from_custom_yaml_file(cls, yaml_file: str):
59
+ """Load a configuration from a custom YAML file."""
60
+ pass
61
+
62
+ @abstractmethod
63
+ def get_cfg_name(self):
64
+ """
65
+ Get the name of the configuration.
66
+ This method should be implemented in subclasses.
67
+ """
68
+ pass
69
+
70
+ @abstractmethod
71
+ def get_outdir(self):
72
+ """
73
+ Get the output directory for the configuration.
74
+ This method should be implemented in subclasses.
75
+ """
76
+ return None
77
+
78
+ @abstractmethod
79
+ def get_general_cfg(self):
80
+ """
81
+ Get the general configuration like output directory, log settings, SEED, etc.
82
+ This method should be implemented in subclasses.
83
+ """
84
+ pass
85
+
86
+ @abstractmethod
87
+ def get_dataset_cfg(self) -> NamedConfig:
88
+ """
89
+ Get the dataset configuration.
90
+ This method should be implemented in subclasses.
91
+ """
92
+ pass
93
+
94
+ @abstractmethod
95
+ def get_metric_cfg(self) -> NamedConfig:
96
+ """
97
+ Get the metric configuration.
98
+ This method should be implemented in subclasses.
99
+ """
100
+ pass
@@ -0,0 +1,99 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+ from ..research.base_config import ExpBaseConfig
4
+ from ..research.perfcalc import PerfCalc
5
+ from ..research.metrics import MetricsBackend
6
+
7
+ # ! SEE https://github.com/hahv/base_exp for sample usage
8
+ class BaseExperiment(PerfCalc, ABC):
9
+ """
10
+ Base class for experiments.
11
+ Orchestrates the experiment pipeline using a pluggable metrics backend.
12
+ """
13
+
14
+ def __init__(self, config: ExpBaseConfig):
15
+ self.config = config
16
+ self.metric_backend = None
17
+
18
+ # -----------------------
19
+ # PerfCalc Required Methods
20
+ # -----------------------
21
+ def get_dataset_name(self):
22
+ return self.config.get_dataset_cfg().get_name()
23
+
24
+ def get_experiment_name(self):
25
+ return self.config.get_cfg_name()
26
+
27
+ def get_metric_backend(self):
28
+ if not self.metric_backend:
29
+ self.metric_backend = self.prepare_metrics(self.config.get_metric_cfg())
30
+ return self.metric_backend
31
+
32
+ # -----------------------
33
+ # Abstract Experiment Steps
34
+ # -----------------------
35
+ @abstractmethod
36
+ def init_general(self, general_cfg):
37
+ """Setup general settings like SEED, logging, env variables."""
38
+ pass
39
+
40
+ @abstractmethod
41
+ def prepare_dataset(self, dataset_cfg):
42
+ """Load/prepare dataset."""
43
+ pass
44
+
45
+ @abstractmethod
46
+ def prepare_metrics(self, metric_cfg) -> MetricsBackend:
47
+ """
48
+ Prepare the metrics for the experiment.
49
+ This method should be implemented in subclasses.
50
+ """
51
+ pass
52
+
53
+ @abstractmethod
54
+ def exec_exp(self, *args, **kwargs):
55
+ """Run experiment process, e.g.: training/evaluation loop.
56
+ Return: raw_metrics_data, and extra_data as input for calc_and_save_exp_perfs
57
+ """
58
+ pass
59
+
60
+ def eval_exp(self):
61
+ """Optional: re-run evaluation from saved results."""
62
+ pass
63
+
64
+ # -----------------------
65
+ # Main Experiment Runner
66
+ # -----------------------
67
+ def run_exp(self, do_calc_metrics=True, *args, **kwargs):
68
+ """
69
+ Run the whole experiment pipeline.
70
+ Params:
71
+ + 'outfile' to save csv file results,
72
+ + 'outdir' to set output directory for experiment results.
73
+ + 'return_df' to return a DataFrame of results instead of a dictionary.
74
+
75
+ Full pipeline:
76
+ 1. Init
77
+ 2. Dataset
78
+ 3. Metrics Preparation
79
+ 4. Save Config
80
+ 5. Execute
81
+ 6. Calculate & Save Metrics
82
+ """
83
+ self.init_general(self.config.get_general_cfg())
84
+ self.prepare_dataset(self.config.get_dataset_cfg())
85
+
86
+ # Save config before running
87
+ self.config.save_to_outdir()
88
+
89
+ # Execute experiment
90
+ results = self.exec_exp(*args, **kwargs)
91
+ if do_calc_metrics:
92
+ metrics_data, extra_data = results
93
+ # Calculate & Save metrics
94
+ perf_results = self.calc_and_save_exp_perfs(
95
+ raw_metrics_data=metrics_data, extra_data=extra_data, *args, **kwargs
96
+ )
97
+ return perf_results
98
+ else:
99
+ return results
@@ -1,57 +1,24 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: halib
3
- Version: 0.1.67
3
+ Version: 0.1.73
4
4
  Summary: Small library for common tasks
5
5
  Author: Hoang Van Ha
6
6
  Author-email: hoangvanhauit@gmail.com
7
+ License: UNKNOWN
8
+ Platform: UNKNOWN
7
9
  Classifier: Programming Language :: Python :: 3
8
10
  Classifier: License :: OSI Approved :: MIT License
9
11
  Classifier: Operating System :: OS Independent
10
12
  Requires-Python: >=3.8
11
13
  Description-Content-Type: text/markdown
12
14
  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
- Requires-Dist: dataclass-wizard
43
- Dynamic: author
44
- Dynamic: author-email
45
- Dynamic: classifier
46
- Dynamic: description
47
- Dynamic: description-content-type
48
- Dynamic: license-file
49
- Dynamic: requires-dist
50
- Dynamic: requires-python
51
- Dynamic: summary
52
15
 
53
16
  Helper package for coding and automation
54
17
 
18
+ **Version 0.1.73**
19
+
20
+ + `research/base_exp`: add base experiment class to handle common experiment tasks, including performance calculation and saving results.
21
+
55
22
  **Version 0.1.67**
56
23
 
57
24
  + now use `uv` for venv management
@@ -188,3 +155,5 @@ New Features
188
155
  New Features
189
156
 
190
157
  + add support to upload local to google drive.
158
+
159
+
@@ -26,6 +26,8 @@ halib/online/gdrive_mkdir.py
26
26
  halib/online/gdrive_test.py
27
27
  halib/online/projectmake.py
28
28
  halib/research/__init__.py
29
+ halib/research/base_config.py
30
+ halib/research/base_exp.py
29
31
  halib/research/dataset.py
30
32
  halib/research/metrics.py
31
33
  halib/research/perfcalc.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.67",
11
+ version="0.1.73",
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
File without changes
File without changes
File without changes
File without changes