mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-31 14:34:40 +00:00
make options
an explicit kwarg
Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
This commit is contained in:
parent
1553a125dc
commit
34393e51a2
@ -14,6 +14,8 @@ class BaseModelWithOptions(Protocol):
|
||||
@classmethod
|
||||
def get_options_type(cls) -> Type[BaseOptions]: ...
|
||||
|
||||
def __init__(self, *, options: BaseOptions, **kwargs): ...
|
||||
|
||||
|
||||
class BasePageModel(ABC):
|
||||
@abstractmethod
|
||||
|
@ -22,6 +22,7 @@ _log = logging.getLogger(__name__)
|
||||
class BaseOcrModel(BasePageModel, BaseModelWithOptions):
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
enabled: bool,
|
||||
artifacts_path: Optional[Path],
|
||||
options: OcrOptions,
|
||||
|
@ -39,10 +39,10 @@ class BaseFactory(Generic[A], metaclass=ABCMeta):
|
||||
def classes(self):
|
||||
return self._classes
|
||||
|
||||
def create_instance(self, options: BaseOptions, *args, **kwargs) -> A:
|
||||
def create_instance(self, options: BaseOptions, **kwargs) -> A:
|
||||
try:
|
||||
_cls = self._classes[type(options)]
|
||||
return _cls(*args, **kwargs)
|
||||
return _cls(options=options, **kwargs)
|
||||
except KeyError:
|
||||
raise RuntimeError(self._err_msg_on_class_not_found(options.kind))
|
||||
|
||||
|
@ -32,6 +32,7 @@ class PictureDescriptionBaseModel(
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
*,
|
||||
enabled: bool,
|
||||
enable_remote_services: bool,
|
||||
artifacts_path: Optional[Union[Path, str]],
|
||||
|
Loading…
Reference in New Issue
Block a user