(self, operator: HasRun[P, R], start_batch: int = 0, batch_size: int = 32, batch_cache: bool = False)
| 26 | 这样 help(bw.run) 时能看到原 operator 的文档。 |
| 27 | """ |
| 28 | def __init__(self, operator: HasRun[P, R], start_batch: int = 0, batch_size: int = 32, batch_cache: bool = False) -> None: |
| 29 | self._operator = operator |
| 30 | self._logger = get_logger() |
| 31 | self._batch_size = batch_size |
| 32 | self._batch_cache = batch_cache |
| 33 | self.start_batch = start_batch |
| 34 | |
| 35 | # 动态拷贝 operator.run 的 __doc__ 和 inspect.signature |
| 36 | orig = operator.run |
| 37 | sig = inspect.signature(orig) |
| 38 | # wrapped = wraps(orig)(self.run) # 先 wrap docstring, __name__… |
| 39 | # wrapped.__signature__ = sig # 再贴上准确的 signature |
| 40 | # 把它绑到实例上覆盖掉 class method,这样 help(instance.run) 能看到原文档 |
| 41 | # object.__setattr__(self, "run", wrapped) |
| 42 | |
| 43 | def run(self, *args: P.args, **kwargs: P.kwargs) -> List[R]: |
| 44 | # —— 1. 提取 storage —— |
nothing calls this directly
no test coverage detected