-
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.
- Loading branch information
Ken Payne
authored
Apr 14, 2023
1 parent
36a9719
commit 1f16873
Showing
17 changed files
with
305 additions
and
32 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.vscode/ | ||
.DS_Store | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,3 +1,5 @@ | ||
LAKE_MANIFEST_FILENAME = "manifest.json" | ||
TAP_MANIFEST_FILENAME = "manifest.json" | ||
STREAM_MANIFEST_FILENAME = "manifest.json" | ||
from singerlake.singerlake import SingerLake | ||
|
||
__all__ = [ | ||
"SingerLake", | ||
] |
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 |
---|---|---|
@@ -1,6 +1,42 @@ | ||
from __future__ import annotations | ||
|
||
import json | ||
from pathlib import Path | ||
from typing import Any, List, Mapping | ||
|
||
import base58 | ||
import farmhash | ||
import numpy as np | ||
|
||
from singerlake.store import BaseStore | ||
|
||
|
||
class SingerLake: | ||
"""Singer Lake.""" | ||
|
||
def __init__(self, store: BaseStore): | ||
self.store = store | ||
|
||
def hash_stream_schema(self, stream_schema: Mapping[str, Any]) -> str: | ||
"""Calculate a unique short-hash for given schema.""" | ||
data = json.dumps(stream_schema, sort_keys=True) | ||
int64_hash_bytes = ( | ||
np.uint64(farmhash.fingerprint64(data)).astype("int64").tobytes() | ||
) | ||
return base58.b58encode(int64_hash_bytes).decode("utf-8") | ||
|
||
def write_files( | ||
self, | ||
tap_id: str, | ||
stream_id: str, | ||
stream_schema: Mapping[str, Any], | ||
files: List[Path], | ||
) -> None: | ||
"""Write files to the Lake.""" | ||
stream_schema_hash = self.hash_stream_schema(stream_schema=stream_schema) | ||
self.store.add_files_to_stream( | ||
tap_id=tap_id, | ||
stream_id=stream_id, | ||
stream_schema_hash=stream_schema_hash, | ||
files=files, | ||
) |
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,7 @@ | ||
from .base import BaseStore | ||
from .local import LocalStore | ||
|
||
__all__ = ["BaseStore", "LocalStore"] | ||
__all__ = [ | ||
"BaseStore", | ||
"LocalStore", | ||
] |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
LAKE_MANIFEST_FILENAME = "manifest.json" | ||
TAP_MANIFEST_FILENAME = "manifest.json" | ||
STREAM_MANIFEST_FILENAME = "manifest.json" |
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
Binary file not shown.
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,25 @@ | ||
{ | ||
"type": "SCHEMA", | ||
"stream": "entry", | ||
"schema": { | ||
"type": "object", | ||
"properties": { | ||
"id": { "type": "string" }, | ||
"from": { "type": "string", "format": "date-time" }, | ||
"to": { "type": "string", "format": "date-time" }, | ||
"forecast": { "type": "integer" }, | ||
"index": { "type": "string" }, | ||
"region_id": { "type": "integer" }, | ||
"_sdc_extracted_at": { | ||
"type": ["null", "string"], | ||
"format": "date-time" | ||
}, | ||
"_sdc_received_at": { "type": ["null", "string"], "format": "date-time" }, | ||
"_sdc_deleted_at": { "type": ["null", "string"], "format": "date-time" }, | ||
"_sdc_batched_at": { "type": ["null", "string"], "format": "date-time" }, | ||
"_sdc_table_version": { "type": ["null", "integer"] }, | ||
"_sdc_sequence": { "type": ["null", "integer"] } | ||
} | ||
}, | ||
"key_properties": ["id"] | ||
} |
Binary file added
BIN
+284 KB
tests/example_files/generationmix-20230414T155444-20230414T155444.singer.gz
Binary file not shown.
Oops, something went wrong.