Skip to content

Commit

Permalink
Add a custom constructor for extractors (#399)
Browse files Browse the repository at this point in the history
The `__init__` method is somewhat clunky to override in subclasses,
since you have to remember to take in the correct parameters and call
`super(...)`` correctly. I propose this instead as a way to define the
tasks for an extractor

``` python
class MyExtractor(Extractor):

    def __init_tasks__(self):
        self.add_task(...)
        self.add_task(...)
```
  • Loading branch information
mathialo authored Nov 27, 2024
1 parent 88f370e commit 1ce72a2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cognite/extractorutils/unstable/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def __init__(

self._current_task: ContextVar[str | None] = ContextVar("current_task", default=None)

self.__init_tasks__()

def __init_tasks__(self) -> None:
pass

def _set_runtime_message_queue(self, queue: Queue) -> None:
self._runtime_messages = queue

Expand Down

0 comments on commit 1ce72a2

Please sign in to comment.