forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python sources refactoring (airbytehq#592)
- Loading branch information
1 parent
bd69601
commit bc56f02
Showing
65 changed files
with
606 additions
and
279 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ build | |
!tools/build | ||
.DS_Store | ||
data | ||
|
||
# Python | ||
*.egg-info | ||
__pycache__ |
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 @@ | ||
3.7.9 |
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 |
---|---|---|
@@ -1,4 +1 @@ | ||
* | ||
!Dockerfile | ||
!base.py | ||
!airbyte_protocol | ||
build |
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 @@ | ||
airbyte_protocol/models/yaml |
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
12 changes: 12 additions & 0 deletions
12
airbyte-integrations/base-python/airbyte_protocol/__init__.py
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,12 @@ | ||
from .integration import * | ||
from .logger import AirbyteLogger | ||
from .models import AirbyteCatalog | ||
from .models import AirbyteLogMessage | ||
from .models import AirbyteMessage | ||
from .models import AirbyteRecordMessage | ||
from .models import AirbyteStateMessage | ||
from .models import AirbyteStream | ||
|
||
# Must be the last one because the way we load the connector module creates a circular | ||
# dependency and models might not have been loaded yet | ||
from .entrypoint import AirbyteEntrypoint |
1 change: 0 additions & 1 deletion
1
airbyte-integrations/base-python/airbyte_protocol/airbyte_protocol/.gitignore
This file was deleted.
Oops, something went wrong.
125 changes: 0 additions & 125 deletions
125
airbyte-integrations/base-python/airbyte_protocol/airbyte_protocol/__init__.py
This file was deleted.
Oops, something went wrong.
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
75 changes: 75 additions & 0 deletions
75
airbyte-integrations/base-python/airbyte_protocol/integration.py
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,75 @@ | ||
import json | ||
import pkgutil | ||
from dataclasses import dataclass | ||
from typing import Generator | ||
|
||
from .models import AirbyteCatalog, AirbyteMessage | ||
|
||
|
||
class AirbyteSpec(object): | ||
@staticmethod | ||
def from_file(file): | ||
with open(file) as file: | ||
spec_text = file.read() | ||
return AirbyteSpec(spec_text) | ||
|
||
def __init__(self, spec_string): | ||
self.spec_string = spec_string | ||
|
||
|
||
class AirbyteCheckResponse(object): | ||
def __init__(self, successful, field_to_error): | ||
self.successful = successful | ||
self.field_to_error = field_to_error | ||
|
||
|
||
@dataclass | ||
class ConfigContainer: | ||
raw_config: object | ||
rendered_config: object | ||
raw_config_path: str | ||
rendered_config_path: str | ||
|
||
|
||
class Integration(object): | ||
def __init__(self): | ||
pass | ||
|
||
def spec(self, logger) -> AirbyteSpec: | ||
raw_spec = pkgutil.get_data(self.__class__.__module__.split('.')[0], 'spec.json') | ||
# we need to output a spec on a single line | ||
flattened_json = json.dumps(json.loads(raw_spec)) | ||
return AirbyteSpec(flattened_json) | ||
|
||
def read_config(self, config_path): | ||
with open(config_path, 'r') as file: | ||
contents = file.read() | ||
return json.loads(contents) | ||
|
||
# can be overridden to change an input file config | ||
def transform_config(self, raw_config): | ||
return raw_config | ||
|
||
def write_config(self, config_object, path): | ||
with open(path, 'w') as fh: | ||
fh.write(json.dumps(config_object)) | ||
|
||
def check(self, logger, config_container) -> AirbyteCheckResponse: | ||
raise Exception("Not Implemented") | ||
|
||
def discover(self, logger, config_container) -> AirbyteCatalog: | ||
raise Exception("Not Implemented") | ||
|
||
|
||
class Source(Integration): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
# Iterator<AirbyteMessage> | ||
def read(self, logger, config_container, catalog_path, state=None) -> Generator[AirbyteMessage, None, None]: | ||
raise Exception("Not Implemented") | ||
|
||
|
||
class Destination(Integration): | ||
def __init__(self): | ||
super().__init__() |
Oops, something went wrong.