Skip to content

Commit

Permalink
Merge pull request #97 from mabel-dev/branching
Browse files Browse the repository at this point in the history
Branching
  • Loading branch information
joocer authored Jul 27, 2024
2 parents 0e7c06d + 8d27dc6 commit 368e64e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tarchia/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__build__ = 131
__build__ = 132

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
13 changes: 7 additions & 6 deletions tarchia/api/v1/data_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from tarchia.models import StageFilesRequest
from tarchia.models import Transaction
from tarchia.utils import config
from tarchia.utils import get_base_url
from tarchia.utils.constants import COMMITS_ROOT
from tarchia.utils.constants import HISTORY_ROOT
from tarchia.utils.constants import IDENTIFIER_REG_EX
Expand Down Expand Up @@ -207,7 +208,7 @@ async def commit_transaction(request: Request, commit_request: CommitRequest):
from tarchia.utils import generate_uuid
from tarchia.utils.catalogs import identify_table

base_url = request.url.scheme + "://" + request.url.netloc
base_url = get_base_url(request)
timestamp = int(time.time_ns() / 1e6)
uuid = generate_uuid()

Expand All @@ -234,12 +235,12 @@ async def commit_transaction(request: Request, commit_request: CommitRequest):
# get the commit we're based on
old_commit = load_old_commit(storage_provider, commit_root, transaction.parent_commit_sha)
old_manifest = (
get_manifest(old_commit.get("manifest_path"), storage_provider, None)
if old_commit.get("manifest_path")
get_manifest(old_commit.manifest_path, storage_provider, None)
if old_commit.manifest_path
else []
)

new_manifest = build_new_manifest(old_manifest, transaction, catalog_entry.current_schema)
new_manifest = build_new_manifest(old_manifest, transaction, transaction.table_schema)
manifest_path = f"{manifest_root}/manifest-{uuid}.avro"
write_manifest(
location=manifest_path, storage_provider=storage_provider, entries=new_manifest
Expand All @@ -257,8 +258,8 @@ async def commit_transaction(request: Request, commit_request: CommitRequest):
parent_commit_sha=transaction.parent_commit_sha,
last_updated_ms=timestamp,
manifest_path=manifest_path,
table_schema=catalog_entry.current_schema,
encryption=catalog_entry.encryption,
table_schema=transaction.table_schema,
encryption=transaction.encryption,
added_files=transaction.additions,
removed_files=transaction.deletions,
)
Expand Down
2 changes: 1 addition & 1 deletion tarchia/metadata/manifests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def write_manifest(location: str, storage_provider: StorageProvider, entries: Li

import fastavro

from ..models.manifest_models import MANIFEST_SCHEMA
from tarchia.models.manifest_models import MANIFEST_SCHEMA

stream = BytesIO()

Expand Down
6 changes: 3 additions & 3 deletions tests/components/test_transaction_signing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
from tarchia.api.v1.data_management import encode_and_sign_transaction
from tarchia.api.v1.data_management import verify_and_decode_transaction
from tarchia.exceptions import TransactionError
from tarchia.models import Transaction
from tarchia.models import Transaction, Schema, Column


def test_transaction_signing_happy():
payload = Transaction(transaction_id="1", expires_at=0, table_id="1", table="1", owner="1")
payload = Transaction(transaction_id="1", expires_at=0, table_id="1", table="1", owner="1", table_schema=Schema(columns=[Column(name="test", type="VARCHAR")]), encryption=None)

signed_transaction = encode_and_sign_transaction(payload)
verified_transaction = verify_and_decode_transaction(signed_transaction)
Expand All @@ -32,7 +32,7 @@ def test_transaction_signing_very_wrong_transactions():
verify_and_decode_transaction(None)

signed_transaction = encode_and_sign_transaction(
Transaction(transaction_id="1", expires_at=0, table_id="1", table="1", owner="1")
Transaction(transaction_id="1", expires_at=0, table_id="1", table="1", owner="1", table_schema=Schema(columns=[Column(name="test", type="VARCHAR")]), encryption=None)
)
# ensure the transaction is valid
verify_and_decode_transaction(signed_transaction)
Expand Down
1 change: 1 addition & 0 deletions tests/endpoints/test_transaction_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
- cannot truncate after adding
- after transaction, table GET returns the latest
- cannot add a file with mismatched columns
- test updating encryption details
"""

0 comments on commit 368e64e

Please sign in to comment.