nnlogging 0.1.2__py3-none-any.whl → 0.1.4__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.
Files changed (46) hide show
  1. nnlogging/__init__.py +3 -15
  2. nnlogging/exceptions/__init__.py +15 -0
  3. nnlogging/exceptions/branch_exists.py +29 -0
  4. nnlogging/exceptions/branch_not_found.py +29 -0
  5. nnlogging/exceptions/task_exists.py +31 -0
  6. nnlogging/exceptions/task_not_found.py +29 -0
  7. nnlogging/global_.py +322 -0
  8. nnlogging/options/__init__.py +31 -0
  9. nnlogging/options/branch_config.py +19 -0
  10. nnlogging/options/log_option.py +34 -0
  11. nnlogging/options/logger_config.py +16 -0
  12. nnlogging/options/rich_console.py +44 -0
  13. nnlogging/options/rich_handler.py +47 -0
  14. nnlogging/options/rich_progress.py +62 -0
  15. nnlogging/options/run_config.py +27 -0
  16. nnlogging/options/task_option.py +17 -0
  17. nnlogging/options/track_option.py +19 -0
  18. nnlogging/shell.py +92 -273
  19. nnlogging/shell_funcs/__init__.py +4 -0
  20. nnlogging/shell_funcs/branch_.py +79 -0
  21. nnlogging/{utils/shell_funcs → shell_funcs}/logger_.py +55 -62
  22. nnlogging/shell_funcs/run_.py +84 -0
  23. nnlogging/{utils/shell_funcs → shell_funcs}/task_.py +42 -42
  24. nnlogging/typings/aliases.py +8 -56
  25. nnlogging/typings/exts.py +15 -0
  26. nnlogging/typings/protocols.py +43 -1
  27. nnlogging/utils/factories.py +112 -0
  28. nnlogging/utils/helpers.py +61 -26
  29. {nnlogging-0.1.2.dist-info → nnlogging-0.1.4.dist-info}/METADATA +25 -32
  30. nnlogging-0.1.4.dist-info/RECORD +31 -0
  31. nnlogging/shell_protocol.py +0 -86
  32. nnlogging/typings/__init__.py +0 -41
  33. nnlogging/typings/exceptions.py +0 -10
  34. nnlogging/typings/generics.py +0 -23
  35. nnlogging/utils/__init__.py +0 -83
  36. nnlogging/utils/exception/__init__.py +0 -11
  37. nnlogging/utils/exception/branch_exists.py +0 -49
  38. nnlogging/utils/exception/branch_not_found.py +0 -49
  39. nnlogging/utils/exception/task_exists.py +0 -54
  40. nnlogging/utils/exception/task_not_found.py +0 -49
  41. nnlogging/utils/factory_funcs/rich_.py +0 -154
  42. nnlogging/utils/factory_funcs/shell_.py +0 -192
  43. nnlogging/utils/shell_funcs/branch_.py +0 -164
  44. nnlogging/utils/shell_funcs/run_.py +0 -97
  45. nnlogging-0.1.2.dist-info/RECORD +0 -24
  46. {nnlogging-0.1.2.dist-info → nnlogging-0.1.4.dist-info}/WHEEL +0 -0
@@ -1,164 +0,0 @@
1
- from collections.abc import Collection
2
- from logging import Formatter as LoggingFormatter
3
- from typing import Literal
4
-
5
- from rich.highlighter import Highlighter as RichHighlighter
6
- from rich.progress import ProgressColumn as RichProgressColumn
7
- from rich.theme import Theme as RichTheme
8
-
9
- from nnlogging.shell_protocol import ShellProtocol
10
- from nnlogging.typings import FormatTimeCallable, Omitable, Sink
11
- from nnlogging.utils.exception import (
12
- raise_branch_exists_error,
13
- raise_branch_not_found_error,
14
- )
15
- from nnlogging.utils.factory_funcs.shell_ import BranchConfig, get_branch
16
- from nnlogging.utils.helpers import evolve_
17
-
18
-
19
- def branch_configure(
20
- inst: ShellProtocol,
21
- /,
22
- config: BranchConfig | None = None,
23
- *,
24
- markup: Omitable[bool] = ...,
25
- highlighter: Omitable[RichHighlighter] = ...,
26
- width: Omitable[int | None] = ...,
27
- height: Omitable[int | None] = ...,
28
- emoji: Omitable[bool] = ...,
29
- color_system: Omitable[Literal["auto", "standard", "truecolor"] | None] = ...,
30
- theme: Omitable[RichTheme] = ...,
31
- soft_wrap: Omitable[bool] = ...,
32
- force_terminal: Omitable[bool | None] = ...,
33
- force_jupyter: Omitable[bool | None] = ...,
34
- force_interactive: Omitable[bool | None] = ...,
35
- level: Omitable[str | int] = ...,
36
- show_level: Omitable[bool] = ...,
37
- show_time: Omitable[bool] = ...,
38
- show_path: Omitable[bool] = ...,
39
- log_time_format: Omitable[str | FormatTimeCallable] = ...,
40
- omit_repeated_times: Omitable[bool] = ...,
41
- rich_tracebacks: Omitable[bool] = ...,
42
- tracebacks_show_locals: Omitable[bool] = ...,
43
- log_message_format: Omitable[str | LoggingFormatter] = ...,
44
- columns: Omitable[Collection[str | RichProgressColumn]] = ...,
45
- transient: Omitable[bool] = ...,
46
- refresh_per_second: Omitable[float] = ...,
47
- speed_estimate_period: Omitable[float] = ...,
48
- default_column_markup: Omitable[bool] = ...,
49
- ):
50
- inst.branch_config = evolve_(
51
- config or inst.branch_config,
52
- markup=markup,
53
- highlighter=highlighter,
54
- width=width,
55
- height=height,
56
- emoji=emoji,
57
- color_system=color_system,
58
- theme=theme,
59
- soft_wrap=soft_wrap,
60
- force_terminal=force_terminal,
61
- force_jupyter=force_jupyter,
62
- force_interactive=force_interactive,
63
- level=level,
64
- show_level=show_level,
65
- show_time=show_time,
66
- show_path=show_path,
67
- log_time_format=log_time_format,
68
- omit_repeated_times=omit_repeated_times,
69
- rich_tracebacks=rich_tracebacks,
70
- tracebacks_show_locals=tracebacks_show_locals,
71
- log_message_format=log_message_format,
72
- columns=columns,
73
- transient=transient,
74
- refresh_per_second=refresh_per_second,
75
- speed_estimate_period=speed_estimate_period,
76
- default_column_markup=default_column_markup,
77
- )
78
-
79
-
80
- def branch_add(
81
- inst: ShellProtocol,
82
- /,
83
- name: str,
84
- sink: Sink | None = None,
85
- *,
86
- markup: Omitable[bool] = ...,
87
- highlighter: Omitable[RichHighlighter] = ...,
88
- width: Omitable[int | None] = ...,
89
- height: Omitable[int | None] = ...,
90
- emoji: Omitable[bool] = ...,
91
- color_system: Omitable[Literal["auto", "standard", "truecolor"] | None] = ...,
92
- theme: Omitable[RichTheme] = ...,
93
- soft_wrap: Omitable[bool] = ...,
94
- force_terminal: Omitable[bool | None] = ...,
95
- force_jupyter: Omitable[bool | None] = ...,
96
- force_interactive: Omitable[bool | None] = ...,
97
- level: Omitable[str | int] = ...,
98
- show_level: Omitable[bool] = ...,
99
- show_time: Omitable[bool] = ...,
100
- show_path: Omitable[bool] = ...,
101
- log_time_format: Omitable[str | FormatTimeCallable] = ...,
102
- omit_repeated_times: Omitable[bool] = ...,
103
- rich_tracebacks: Omitable[bool] = ...,
104
- tracebacks_show_locals: Omitable[bool] = ...,
105
- log_message_format: Omitable[str | LoggingFormatter] = ...,
106
- ):
107
- if name in inst.branches:
108
- raise_branch_exists_error(
109
- inst,
110
- name,
111
- stacklevel=6,
112
- )
113
- else:
114
- branch = get_branch(
115
- inst.branch_config,
116
- sink=sink,
117
- markup=markup,
118
- highlighter=highlighter,
119
- width=width,
120
- height=height,
121
- emoji=emoji,
122
- color_system=color_system,
123
- theme=theme,
124
- soft_wrap=soft_wrap,
125
- force_terminal=force_terminal,
126
- force_jupyter=force_jupyter,
127
- force_interactive=force_interactive,
128
- level=level,
129
- show_level=show_level,
130
- show_time=show_time,
131
- show_path=show_path,
132
- log_time_format=log_time_format,
133
- omit_repeated_times=omit_repeated_times,
134
- rich_tracebacks=rich_tracebacks,
135
- tracebacks_show_locals=tracebacks_show_locals,
136
- log_message_format=log_message_format,
137
- )
138
- inst.branches[name] = branch
139
- if inst.logger is not None:
140
- # TODO: add branch-add-hint
141
- inst.logger.addHandler(branch["handler"])
142
-
143
-
144
- def branch_remove(
145
- inst: ShellProtocol,
146
- /,
147
- name: str,
148
- ):
149
- if name not in inst.branches:
150
- raise_branch_not_found_error(
151
- inst,
152
- name,
153
- stacklevel=6,
154
- )
155
- else:
156
- branch = inst.branches[name]
157
- branch["handler"].close()
158
- branch["tasks"].clear()
159
- if branch["progress"] is not None:
160
- branch["progress"].stop()
161
- if inst.logger is not None:
162
- # TODO: add branch-remove-hint
163
- inst.logger.removeHandler(branch["handler"])
164
- del inst.branches[name]
@@ -1,97 +0,0 @@
1
- from aim import Repo as AimRepo
2
- from aim.sdk.types import AimObject
3
-
4
- from nnlogging.shell_protocol import ShellProtocol
5
- from nnlogging.typings import Omitable
6
- from nnlogging.utils.factory_funcs.shell_ import RunConfig, get_aim_run
7
- from nnlogging.utils.helpers import evolve_
8
-
9
-
10
- def _run_open(
11
- inst: ShellProtocol,
12
- /,
13
- ):
14
- if inst.run is None:
15
- inst.run = get_aim_run(inst.run_config)
16
-
17
-
18
- def _run_close(
19
- inst: ShellProtocol,
20
- /,
21
- ):
22
- if inst.run is not None:
23
- inst.run.close()
24
- del inst.run
25
- inst.run = None
26
-
27
-
28
- def run_configure(
29
- inst: ShellProtocol,
30
- /,
31
- config: RunConfig | None = None,
32
- *,
33
- experiment: Omitable[str | None] = ...,
34
- repo: Omitable[str | AimRepo | None] = ...,
35
- system_tracking_interval: Omitable[float | None] = ...,
36
- capture_terminal_logs: Omitable[bool] = ...,
37
- log_system_params: Omitable[bool] = ...,
38
- run_hash: Omitable[str | None] = ...,
39
- read_only: Omitable[bool] = ...,
40
- force_resume: Omitable[bool] = ...,
41
- ):
42
- _run_close(inst)
43
- inst.run_config = evolve_(
44
- config or inst.run_config,
45
- experiment=experiment,
46
- repo=repo,
47
- system_tracking_interval=system_tracking_interval,
48
- capture_terminal_logs=capture_terminal_logs,
49
- log_system_params=log_system_params,
50
- run_hash=run_hash,
51
- read_only=read_only,
52
- force_resume=force_resume,
53
- )
54
-
55
-
56
- def update_metadata(
57
- inst: ShellProtocol,
58
- /,
59
- label: str,
60
- metadata: AimObject,
61
- ):
62
- _run_open(inst)
63
- assert inst.run is not None
64
- inst.run[label] = metadata
65
-
66
-
67
- def add_tag(inst: ShellProtocol, /, tag: str):
68
- _run_open(inst)
69
- assert inst.run is not None
70
- inst.run.add_tag(tag)
71
-
72
-
73
- def remove_tag(inst: ShellProtocol, /, tag: str):
74
- _run_open(inst)
75
- assert inst.run is not None
76
- inst.run.remove_tag(tag)
77
-
78
-
79
- def track(
80
- inst: ShellProtocol,
81
- /,
82
- value: object,
83
- *,
84
- name: str | None = None,
85
- step: int | None = None,
86
- epoch: int | None = None,
87
- context: AimObject = None,
88
- ):
89
- _run_open(inst)
90
- assert inst.run is not None
91
- inst.run.track(
92
- value,
93
- name=name, # pyright: ignore[reportArgumentType]
94
- step=step, # pyright: ignore[reportArgumentType]
95
- epoch=epoch, # pyright: ignore[reportArgumentType]
96
- context=context,
97
- )
@@ -1,24 +0,0 @@
1
- nnlogging/__init__.py,sha256=OrVcKC5BXu4t5rIwI_6208xbnl1HLtjTCFYCjJJxiUQ,211
2
- nnlogging/shell.py,sha256=YEYScKtaH03hGGqWkddCi1u8IrTqd38BLvCbXeEfc3s,12321
3
- nnlogging/shell_protocol.py,sha256=134PlZbAAscAIE4AoaWH0SVblCFydjMDTfjTr7t8DA4,1684
4
- nnlogging/typings/__init__.py,sha256=7ar5136odVB9vOj5MTQ6_AYuodoWOGduMSveEpVtF1Y,774
5
- nnlogging/typings/aliases.py,sha256=EpLqeOss5u5-zpu-tbv6g-LZ21mFyKO0PpyXmDLrCUs,2080
6
- nnlogging/typings/exceptions.py,sha256=rCmrwA599Uy7iOVnX12_Q8B0FMydyJX7zgOLBWxWDUM,174
7
- nnlogging/typings/generics.py,sha256=olwknb77voWiIydEM62aMuU5kQPyS74zoyX7Ncr9cig,680
8
- nnlogging/typings/protocols.py,sha256=osKmzyQ9Qzz_woxbd2eM9wDvPZ6hJZvupQ2cdkOM0H8,341
9
- nnlogging/utils/__init__.py,sha256=h1iOvGhiFAwO9ypaME_IQi2R0YWvFBr7tvxh1VL_d5A,1751
10
- nnlogging/utils/helpers.py,sha256=8KTHeyQJR36Wnm8CRG7fZsx-IX6kXU4CsSkrTEgyZ0E,785
11
- nnlogging/utils/exception/__init__.py,sha256=aFAbufsmio0Yndq6H7zEEoWGNA2kfO7F3ZL1p6iGYzQ,365
12
- nnlogging/utils/exception/branch_exists.py,sha256=kUvBWsfYIw3u7aAbEp7GWy8f2RdZL3SMtjJga7-NGVk,1122
13
- nnlogging/utils/exception/branch_not_found.py,sha256=K-eaA6nzlM6DWR76adPPoATD5tI49oxBmuEf2ctIeho,1133
14
- nnlogging/utils/exception/task_exists.py,sha256=ce2mMg2cno8fGLnTMqPZMB9IYjmU_trOf0OtaP45vxA,1240
15
- nnlogging/utils/exception/task_not_found.py,sha256=5Gayr_R8Z85QHYh_BlNslW_cHVOO2HljuFe_RVZQ7BU,1113
16
- nnlogging/utils/factory_funcs/rich_.py,sha256=RVI46Ncxk5aoMTbbQmf_mIB664IkYACXOiVOqwHLLt0,4473
17
- nnlogging/utils/factory_funcs/shell_.py,sha256=iv7NV0cfcuuHeq8YE70iCMmiV_2nTppQTnVJbjfGOjg,6372
18
- nnlogging/utils/shell_funcs/branch_.py,sha256=IfCCQ0CXEYxR0AkLbG-qmem8h7noogNk46zcUV64q4k,5615
19
- nnlogging/utils/shell_funcs/logger_.py,sha256=EKLHk7SoP5owbmoU5nRFEVO_xpod7wU0sT9EqxeLOgs,4667
20
- nnlogging/utils/shell_funcs/run_.py,sha256=jMaFUEuKq7M6X4HhTxCwDHPaDsZGw2rcVG7-SbZx4ok,2337
21
- nnlogging/utils/shell_funcs/task_.py,sha256=C-RHlhYt_6HXifsDalw4iMMLFmZbLjWOdxMGRXAL2zo,3206
22
- nnlogging-0.1.2.dist-info/METADATA,sha256=ItxmLpxl7TKpkl9Oh3YSQ60ob74HD5NMrrmuQ8RaybM,4533
23
- nnlogging-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
- nnlogging-0.1.2.dist-info/RECORD,,