medcat.pipeline.speed_utils
Classes:
-
AveragingTimedComponent– -
AveragingTimedObject– -
AveragingTimedTokenizer– -
BaseTimedComponent– -
BaseTimedObject– -
BaseTimedObjectProtocol– -
BaseTimedTokenizer– -
PerDocTimedObject– -
ProfiledComponent– -
ProfiledObject– -
ProfiledTokenizer– -
TimedComponent–Wraps a component and logs the time spent in it.
-
TimedComponentProtocol– -
TimedTokenizer– -
TimedTokenizerProtocol–
Functions:
-
context_manager_with_logging– -
pipeline_per_doc_timer–Time the pipeline on a per document basis.
-
pipeline_timer_averaging_docs–Time the pipeline on a multi doc basis.
-
profile_pipeline_component–Time a specific component of the pipeline.
Attributes:
-
logger–
AveragingTimedComponent
AveragingTimedComponent(component: BaseComponent, condition: Callable[[int, float], bool])
Bases: AveragingTimedObject
Source code in medcat-v2/medcat/pipeline/speed_utils.py
175 176 177 178 179 | |
AveragingTimedObject
AveragingTimedObject(component: Union[BaseComponent, BaseTokenizer], condition: Callable[[int, float], bool])
Bases: BaseTimedObject
Source code in medcat-v2/medcat/pipeline/speed_utils.py
135 136 137 138 139 | |
AveragingTimedTokenizer
AveragingTimedTokenizer(component: BaseTokenizer, condition: Callable[[int, float], bool])
Bases: AveragingTimedObject
Source code in medcat-v2/medcat/pipeline/speed_utils.py
191 192 193 194 195 | |
BaseTimedComponent
Bases: Protocol
BaseTimedObject
BaseTimedObject(component: Union[BaseComponent, BaseTokenizer])
Attributes:
Source code in medcat-v2/medcat/pipeline/speed_utils.py
63 64 | |
full_name
property
full_name
BaseTimedObjectProtocol
BaseTimedTokenizer
Bases: Protocol
PerDocTimedObject
PerDocTimedObject(component: Union[BaseComponent, BaseTokenizer])
Bases: BaseTimedObject
Methods:
-
time_it–
Source code in medcat-v2/medcat/pipeline/speed_utils.py
63 64 | |
time_it
time_it(to_run: Callable[[], MutableDocument]) -> MutableDocument
Source code in medcat-v2/medcat/pipeline/speed_utils.py
102 103 104 105 106 107 | |
ProfiledComponent
ProfiledComponent(component: BaseComponent)
Bases: ProfiledObject
Source code in medcat-v2/medcat/pipeline/speed_utils.py
228 229 230 231 | |
ProfiledObject
ProfiledObject(component: Union[BaseComponent, BaseTokenizer])
Bases: BaseTimedObject
Methods:
Source code in medcat-v2/medcat/pipeline/speed_utils.py
207 208 209 | |
show_stats
show_stats(limit: int = 20)
Source code in medcat-v2/medcat/pipeline/speed_utils.py
221 222 223 | |
ProfiledTokenizer
ProfiledTokenizer(component: BaseTokenizer)
Bases: ProfiledObject
Source code in medcat-v2/medcat/pipeline/speed_utils.py
242 243 244 245 | |
TimedComponent
TimedComponent(component: BaseComponent)
Bases: PerDocTimedObject
Wraps a component and logs the time spent in it.
Source code in medcat-v2/medcat/pipeline/speed_utils.py
113 114 115 116 | |
TimedComponentProtocol
TimedTokenizer
TimedTokenizer(component: BaseTokenizer)
Bases: PerDocTimedObject
Source code in medcat-v2/medcat/pipeline/speed_utils.py
124 125 126 127 | |
TimedTokenizerProtocol
context_manager_with_logging
context_manager_with_logging(func)
Source code in medcat-v2/medcat/pipeline/speed_utils.py
40 41 42 43 44 45 46 | |
pipeline_per_doc_timer
pipeline_per_doc_timer(pipeline: Pipeline, timer_init: Callable[[BaseComponent], TimedComponentProtocol] = TimedComponent, tknzer_timer_init: Callable[[BaseTokenizer], TimedTokenizerProtocol] = TimedTokenizer)
Time the pipeline on a per document basis.
Parameters:
-
(pipelinePipeline) –The pipeline to time.
-
(timer_initCallable[[BaseComponent], TimedComponentProtocol]), default:TimedComponent) –The initialiser for the timer. Defaults to TimedComponent.
-
(tknzer_timer_initCallable[[BaseTokenizer], TimedTokenizerProtocol, default:TimedTokenizer) –The initialiser for the timer for the tokenizer. Defaults to TimedTokenizer.
Yields:
-
Pipeline–The same pipeline.
Source code in medcat-v2/medcat/pipeline/speed_utils.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
pipeline_timer_averaging_docs
pipeline_timer_averaging_docs(pipeline: Pipeline, show_frequency_docs: int = -1, show_frequency_secs: float = -1)
Time the pipeline on a multi doc basis.
This can be set to show timings after a certain number of docs or after a certain time spent. The default configuration averages over 100 documents
Parameters:
-
(pipelinePipeline) –The pipeline to time.
-
(show_frequency_docsint, default:-1) –The number of documents to average over, or (if set to -1) use seconds instead. Defaults to -1 if secs frequency set and to 100 otherwise.
-
(show_frequency_secsfloat, default:-1) –The frequency in seconds for showing the average timings for each component. Defaults to -1.
Raises:
-
ValueError–If one of the frequencies is 0.
-
ValueError–If both document and time frequencies are specified.
Yields:
-
Pipeline–The same pipeline.
Source code in medcat-v2/medcat/pipeline/speed_utils.py
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 | |
profile_pipeline_component
profile_pipeline_component(pipeline: Pipeline, comp_type: Union[CoreComponentType, Type[AddonType], Literal['tokenizer']], limit: int = 20)
Time a specific component of the pipeline.
This can profile either a core component or an addon component. But notably, in case of addon components, all components of the same type will be profiled.
Parameters:
-
(pipelinePipeline) –The pipeline to time.
-
(comp_typeUnion[CoreComponentType, Type[AddonType], Literal['tokenizer']]) –The type of component to profile. This can be either a core component or an addon component, ot the tokenizer.
-
(limitint, default:20) –The number of function calls to show in output. Defaults to 20.
Yields:
-
Pipeline–The same pipeline.
Source code in medcat-v2/medcat/pipeline/speed_utils.py
371 372 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 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | |