Skip to content

Commit

Permalink
working commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Payne committed Sep 22, 2023
1 parent 387567a commit a2deff4
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/singerlake/store/path_manager/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ def get_stream_file_path(self, stream_file: "SingerFile") -> GenericPath:
self.get_stream_path(
tap_id=stream_file.tap_id, stream_id=stream_file.stream_id
)
.extend(self.hash_stream_schema(stream_file.schema))
.extend(stream_file.filename)
.extend(self.hash_stream_schema(stream_file.schema_))
.extend(stream_file.name)
)
6 changes: 3 additions & 3 deletions src/singerlake/stream/file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pathlib import Path
from uuid import uuid4

from pydantic import BaseModel
from pydantic import BaseModel, Field

import singerlake.singer.utils as su

Expand All @@ -21,7 +21,7 @@ class SingerFile(BaseModel):
"""Singer file object."""

tap_id: str
schema: dict
schema_: dict = Field(alias="schema")
parent_dir: Path
partition: tuple[int, ...]
min_time_extracted: datetime
Expand All @@ -41,7 +41,7 @@ def name(self):
@property
def stream_id(self):
"""Return the stream ID."""
return self.schema["stream"]
return self.schema_["stream"]

@property
def path(self):
Expand Down
2 changes: 1 addition & 1 deletion src/singerlake/stream/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ def record_writer(self):

def commit(self):
"""Commit stream files to storage."""
self.singerlake.store.commit_stream_files(tap=self.tap, stream_files=self.files)
self.singerlake.store.commit_stream_files(stream_files=self.files)
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ def _clean_lake_dir(lake_root: Path, lake_manifest: dict):
lake_manifest,
open(lake_root / "manifest.json", "w", encoding="utf-8"),
)
(lake_root / "raw").mkdir(parents=True, exist_ok=True)
(lake_root / "raw" / "tap-carbon-intensity").mkdir(parents=True, exist_ok=True)
json.dump(
{
"tap_id": "tap-carbon-intensity",
"streams": ["entry", "generationmix", "region"],
},
open(
lake_root / "raw" / "tap-carbon-intensity" / "manifest.json",
"w",
encoding="utf-8",
),
)


@pytest.fixture(scope="session")
Expand All @@ -69,6 +82,7 @@ def write_singerlake(write_singerlake_config: dict):
lake_root = singerlake.store.get_lake_root()
if lake_root.exists():
_clean_lake_dir(lake_root, {"lake_id": "merry-lizard"})

yield singerlake
singerlake.clean_working_dir()
_clean_lake_dir(lake_root, {"lake_id": "merry-lizard"})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"tap_id": "tap-carbon-intensity", "streams": ["entry", "generationmix", "region"]}
1 change: 1 addition & 0 deletions tests/test_singerlake.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ def test_stream_commit(write_singerlake):
/ "raw"
/ "tap-carbon-intensity"
/ "entry"
/ "Y8Mjkb4i9yM"
)
assert stream_files_path.exists()

0 comments on commit a2deff4

Please sign in to comment.