nshtrainer 1.0.0b24__py3-none-any.whl → 1.0.0b25__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.
@@ -64,6 +64,32 @@ class LoggerLightningModuleMixin(mixin_base_type(LightningModule)):
64
64
 
65
65
  self._logger_prefix_stack = deque[_LogContextKwargs]()
66
66
 
67
+ @property
68
+ def logging_enabled(self) -> bool:
69
+ # Logging is disabled in barebones mode.
70
+ if (trainer := self._trainer) is not None and trainer.barebones:
71
+ # Warn the user once that logging is disabled in barebones mode.
72
+ if not hasattr(self, "_barebones_logging_warned"):
73
+ rank_zero_warn(
74
+ "Logging is disabled in barebones mode. "
75
+ "This is to reduce the overhead of logging in barebones mode. "
76
+ "If you want to enable logging, set `barebones=False` in the Trainer.",
77
+ )
78
+ self._barebones_logging_warned = True
79
+ return False
80
+
81
+ # If no loggers are registered, then logging is disabled.
82
+ if not self.logger:
83
+ return False
84
+
85
+ # Check if the topmost non-null context is disabled
86
+ for context in reversed(self._logger_prefix_stack):
87
+ if context.disabled is not None:
88
+ return not context.disabled
89
+
90
+ # Otherwise, logging is enabled.
91
+ return True
92
+
67
93
  @contextmanager
68
94
  def log_context(
69
95
  self,
@@ -121,22 +147,14 @@ class LoggerLightningModuleMixin(mixin_base_type(LightningModule)):
121
147
  metric_attribute: str | None = None,
122
148
  rank_zero_only: bool = False,
123
149
  ) -> None:
150
+ # If logging is disabled, then do nothing.
151
+ if not self.logging_enabled:
152
+ return
153
+
124
154
  # join all prefixes
125
155
  prefix = "".join(c.prefix for c in self._logger_prefix_stack if c.prefix)
126
156
  name = f"{prefix}{name}"
127
157
 
128
- # check for disabled context:
129
- # if the topmost non-null context is disabled, then we don't log
130
- for c in reversed(self._logger_prefix_stack):
131
- if c.disabled is not None:
132
- if c.disabled:
133
- rank_zero_warn(
134
- f"Skipping logging of {name} due to disabled context"
135
- )
136
- return
137
- else:
138
- break
139
-
140
158
  fn_kwargs = _LogContextKwargs()
141
159
  for c in self._logger_prefix_stack:
142
160
  fn_kwargs = fn_kwargs.copy_from(c)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nshtrainer
3
- Version: 1.0.0b24
3
+ Version: 1.0.0b25
4
4
  Summary:
5
5
  Author: Nima Shoghi
6
6
  Author-email: nimashoghi@gmail.com
@@ -106,7 +106,7 @@ nshtrainer/model/__init__.py,sha256=3G-bwPPSRStWdsdwG9-rn0bXcRpEiP1BiQpF_qavtls,
106
106
  nshtrainer/model/base.py,sha256=JL3AmH17GQjQIoMrZl3O0vUI7dj5ZsO5iEJgoLPyzHw,10356
107
107
  nshtrainer/model/mixins/callback.py,sha256=Ea_legORzs0N078j0N9RJivDVeWH5KtXDpdJS75IwIo,3098
108
108
  nshtrainer/model/mixins/debug.py,sha256=1LX9KzeFX9JDPs_a6YCdYDZXLhEk_5rBO2aCqlfBy7w,2087
109
- nshtrainer/model/mixins/logger.py,sha256=LQDJJbiv30PlWX6rTT_EhjNBNfUFfcvGz5sX4MnOCzI,5330
109
+ nshtrainer/model/mixins/logger.py,sha256=27H99FuLaxc6_dDLG2pid4E_5E0-eLGnc2Ifpt0HYIM,6066
110
110
  nshtrainer/nn/__init__.py,sha256=sANhrZpeN5syLKOsmXMwhaFl2SBFPWcLaEe1EH22TWQ,1463
111
111
  nshtrainer/nn/mlp.py,sha256=2W8bzE96DzCMzGm6WPiPhNFQfhqaoG3GXPn_oKBnlUM,5988
112
112
  nshtrainer/nn/module_dict.py,sha256=9plb8aQUx5TUEPhX5jI9u8LrpTeKe7jZAHi8iIqcN8w,2365
@@ -135,6 +135,6 @@ nshtrainer/util/seed.py,sha256=diMV8iwBKN7Xxt5pELmui-gyqyT80_CZzomrWhNss0k,316
135
135
  nshtrainer/util/slurm.py,sha256=HflkP5iI_r4UHMyPjw9R4dD5AHsJUpcfJw5PLvGYBRM,1603
136
136
  nshtrainer/util/typed.py,sha256=Xt5fUU6zwLKSTLUdenovnKK0N8qUq89Kddz2_XeykVQ,164
137
137
  nshtrainer/util/typing_utils.py,sha256=MjY-CUX9R5Tzat-BlFnQjwl1PQ_W2yZQoXhkYHlJ_VA,442
138
- nshtrainer-1.0.0b24.dist-info/METADATA,sha256=kJJwb8hMUOHfif2qiEB70hCSllpUOt48s-n8SRFkRJY,937
139
- nshtrainer-1.0.0b24.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
140
- nshtrainer-1.0.0b24.dist-info/RECORD,,
138
+ nshtrainer-1.0.0b25.dist-info/METADATA,sha256=ocf8xtYy2GBLpulyx5XepoiHYvjtHGnmMrLhDhvDQAQ,937
139
+ nshtrainer-1.0.0b25.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
140
+ nshtrainer-1.0.0b25.dist-info/RECORD,,