MCPcopy Create free account
hub / github.com/Open-Bee/DataStudio / _format_message

Method _format_message

datastudio/utils/logging.py:187–210  ·  view source on GitHub ↗

Format message with additional key-value pairs.

(self, msg: Any, **kwargs)

Source from the content-addressed store, hash-verified

185 return cls._instance
186
187 def _format_message(self, msg: Any, **kwargs) -> str:
188 """Format message with additional key-value pairs."""
189 if isinstance(msg, dict):
190 parts = []
191 for k, v in msg.items():
192 if k:
193 if isinstance(v, float):
194 parts.append(f"{k}={v:.4f}")
195 else:
196 parts.append(f"{k}={v}")
197 else:
198 parts.append(str(v))
199 msg_str = ", ".join(parts)
200 else:
201 msg_str = str(msg)
202
203 if kwargs:
204 extra = ", ".join(
205 f"{k}={v:.4f}" if isinstance(v, float) else f"{k}={v}"
206 for k, v in kwargs.items()
207 )
208 msg_str = f"{msg_str}, {extra}" if msg_str else extra
209
210 return msg_str
211
212 def _log_to_wandb(self, data: Dict, step: Optional[int] = None) -> None:
213 """Log metrics to wandb."""

Callers 5

debugMethod · 0.95
infoMethod · 0.95
warningMethod · 0.95
errorMethod · 0.95
criticalMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected