ModelRunner
dorsal.file.model_runner.ModelRunner
Initializes the ModelRunner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline_config
|
str | list[dict[str, Any]] | None
|
Configuration for models to run after the base model. - str: "default", uses the default built-in pipeline. - str: Any string other than "default" is a file path to a JSON file containing the pipeline configuration list. - list: A direct list of configuration dictionaries. An empty list [] means only the base model will be run with its effective options. - None: No pipeline will be set up. Useful for when you only need |
'default'
|
debug
|
bool
|
If True, enables timing of model executions. |
False
|
testing
|
bool
|
If True, supresses warning about the pipeline_config being set to None |
False
|
Source code in venv/lib/python3.13/site-packages/dorsal/file/model_runner.py
run_single_model
run_single_model(
annotation_model,
validation_model,
file_path,
base_model_result=None,
schema_id=None,
options=None,
ignore_linter_errors=False,
)
Runs a single annotation model and validates its output.
This is the core execution unit for all models in the pipeline, including the base model.
- Populates Model: Injects base file info (size, media type, etc.) into the model instance before running.
- Runs Model: Calls the model's
.main()method. - Validates Output: (Optional) Validates the output against the provided Pydantic or JSON Schema validator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
annotation_model
|
Type[AnnotationModel]
|
The AnnotationModel class to execute. |
required |
validation_model
|
Type[BaseModel] | JsonSchemaValidator | None
|
The Pydantic model or JsonSchemaValidator to validate the output against. |
required |
file_path
|
str
|
The absolute path to the file being processed. |
required |
base_model_result
|
'RunModelResult' | None
|
The result from the initial FileCoreAnnotationModel.
This is |
None
|
schema_id
|
str | None
|
The target schema ID for this annotation. |
None
|
options
|
dict[str, Any] | None
|
A dictionary of options to pass to the model's |
None
|
Returns:
| Type | Description |
|---|---|
'RunModelResult'
|
A RunModelResult object containing the model's output or an error. |
Source code in venv/lib/python3.13/site-packages/dorsal/file/model_runner.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | |
dorsal.file.model_runner.model_debug_timer
Decorates method - provides execution time.
- Stores execution time of each model in time_taken instance mapping
- Requires: self.debug = True on ModelRunner instance