-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for new runtime and base class (#360)
The idea here is to split the responsibilities of the current base class into two: A runtime and an extractor. The runtime is responsible for parsing command line arguments, loading config files and so on, before spawning the extractor in a separate process. The runtime will automatically restart the extractor if it crashes, but can also be asked by the extractor to restart it - for example after a config change. The extractor class is then only responsible for running the extractor application itself, making it much cleaner. Also drops 3.9 support
- Loading branch information
Showing
11 changed files
with
457 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ __pycache__/ | |
# Local test files | ||
test.py | ||
test.yaml | ||
local-test.yaml | ||
pyrightconfig.json | ||
|
||
# Tokens, etc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Example of how you would build an extractor with the new base class | ||
""" | ||
|
||
from cognite.extractorutils.unstable.configuration.models import ExtractorConfig | ||
|
||
from .base import Extractor | ||
from .runtime import Runtime | ||
|
||
|
||
class MyConfig(ExtractorConfig): | ||
parameter_one: int | ||
parameter_two: str | ||
|
||
|
||
class MyExtractor(Extractor[MyConfig]): | ||
NAME = "Test extractor" | ||
EXTERNAL_ID = "test-extractor" | ||
DESCRIPTION = "Test of the new runtime" | ||
VERSION = "1.0.0" | ||
CONFIG_TYPE = MyConfig | ||
|
||
def run(self) -> None: | ||
self.logger.info("Started!") | ||
if not self.cancellation_token.wait(10): | ||
raise ValueError("Oops") | ||
|
||
|
||
if __name__ == "__main__": | ||
runtime = Runtime(MyExtractor) | ||
runtime.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from enum import Enum | ||
|
||
|
||
class RuntimeMessage(Enum): | ||
RESTART = 1 |
Oops, something went wrong.