Logging
zenml.logging
Logging utilities.
Attributes
STEP_LOGS_STORAGE_INTERVAL_SECONDS: int = 15
module-attribute
STEP_LOGS_STORAGE_MAX_MESSAGES: int = 100
module-attribute
STEP_LOGS_STORAGE_MERGE_INTERVAL_SECONDS: int = 10 * 60
module-attribute
Modules
step_logging
ZenML logging handler.
Classes
StepLogsStorage(logs_uri: str, artifact_store: BaseArtifactStore, max_messages: int = STEP_LOGS_STORAGE_MAX_MESSAGES, time_interval: int = STEP_LOGS_STORAGE_INTERVAL_SECONDS, merge_files_interval: int = STEP_LOGS_STORAGE_MERGE_INTERVAL_SECONDS)
Helper class which buffers and stores logs to a given URI.
Initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logs_uri
|
str
|
the URI of the log file or folder. |
required |
artifact_store
|
BaseArtifactStore
|
Artifact Store from the current step context |
required |
max_messages
|
int
|
the maximum number of messages to save in the buffer. |
STEP_LOGS_STORAGE_MAX_MESSAGES
|
time_interval
|
int
|
the amount of seconds before the buffer gets saved automatically. |
STEP_LOGS_STORAGE_INTERVAL_SECONDS
|
merge_files_interval
|
int
|
the amount of seconds before the created files get merged into a single file. |
STEP_LOGS_STORAGE_MERGE_INTERVAL_SECONDS
|
Source code in src/zenml/logging/step_logging.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
merge_log_files(merge_all_files: bool = False) -> None
Merges all log files into one in the given URI.
Called on the logging context exit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
merge_all_files
|
bool
|
whether to merge all files or only raw files |
False
|
Source code in src/zenml/logging/step_logging.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
|
save_to_file(force: bool = False) -> None
Method to save the buffer to the given URI.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force
|
bool
|
whether to force a save even if the write conditions not met. |
False
|
Source code in src/zenml/logging/step_logging.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
|
write(text: str) -> None
Main write method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
the incoming string. |
required |
Source code in src/zenml/logging/step_logging.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
StepLogsStorageContext(logs_uri: str, artifact_store: BaseArtifactStore)
Context manager which patches stdout and stderr during step execution.
Initializes and prepares a storage object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logs_uri
|
str
|
the URI of the logs file. |
required |
artifact_store
|
BaseArtifactStore
|
Artifact Store from the current step context. |
required |
Source code in src/zenml/logging/step_logging.py
424 425 426 427 428 429 430 431 432 433 434 435 |
|
Functions
fetch_logs(zen_store: BaseZenStore, artifact_store_id: Union[str, UUID], logs_uri: str, offset: int = 0, length: int = 1024 * 1024 * 16) -> str
Fetches the logs from the artifact store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
zen_store
|
BaseZenStore
|
The store in which the artifact is stored. |
required |
artifact_store_id
|
Union[str, UUID]
|
The ID of the artifact store. |
required |
logs_uri
|
str
|
The URI of the artifact. |
required |
offset
|
int
|
The offset from which to start reading. |
0
|
length
|
int
|
The amount of bytes that should be read. |
1024 * 1024 * 16
|
Returns:
Type | Description |
---|---|
str
|
The logs as a string. |
Raises:
Type | Description |
---|---|
DoesNotExistException
|
If the artifact does not exist in the artifact store. |
Source code in src/zenml/logging/step_logging.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
prepare_logs_uri(artifact_store: BaseArtifactStore, step_name: str, log_key: Optional[str] = None) -> str
Generates and prepares a URI for the log file or folder for a step.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
artifact_store
|
BaseArtifactStore
|
The artifact store on which the artifact will be stored. |
required |
step_name
|
str
|
Name of the step. |
required |
log_key
|
Optional[str]
|
The unique identification key of the log file. |
None
|
Returns:
Type | Description |
---|---|
str
|
The URI of the log storage (file or folder). |
Source code in src/zenml/logging/step_logging.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
remove_ansi_escape_codes(text: str) -> str
Auxiliary function to remove ANSI escape codes from a given string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
the input string |
required |
Returns:
Type | Description |
---|---|
str
|
the version of the input string where the escape codes are removed. |
Source code in src/zenml/logging/step_logging.py
53 54 55 56 57 58 59 60 61 62 63 |
|