Skip to content

Commit

Permalink
Merge pull request #100 from mabel-dev/branching
Browse files Browse the repository at this point in the history
Branching
  • Loading branch information
joocer authored Jul 28, 2024
2 parents 80109af + bb70cce commit 6b688af
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 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__ = 134
__build__ = 135

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 4 additions & 0 deletions tarchia/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def __init__(self, root: str, commit: str):
super().__init__(message)


class UnableToReadBlobError(Exception):
"""Can't find a blob when trying to add to manifest"""


class AmbiguousTableError(Exception): # pragma: no cover
def __init__(self, table: str):
self.table = table
Expand Down
4 changes: 3 additions & 1 deletion tarchia/interfaces/storage/google_cloud_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ def read_blob(self, location: str, bucket_in_path: bool = False) -> bytes:
bucket_name = self.bucket_name
bucket = self.client.get_bucket(bucket_name)
blob = bucket.get_blob(location)
return blob.download_as_bytes()
if blob:
return blob.download_as_bytes()
return None
5 changes: 5 additions & 0 deletions tarchia/metadata/manifests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ def build_manifest_entry(path: str, expected_schema: Schema) -> ManifestEntry:

# Read the file bytes and initialize the Parquet file object
file_bytes = storage_provider.read_blob(blob_path, bucket_in_path=True)
if file_bytes is None:
from tarchia.exceptions import UnableToReadBlobError

raise UnableToReadBlobError(f"Unable to read {blob_path}.")

new_manifest_entry.file_size = len(file_bytes)
new_manifest_entry.sha256_checksum = sha256(file_bytes).hexdigest()

Expand Down
4 changes: 4 additions & 0 deletions tarchia/models/metadata_models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from enum import Enum
from typing import Any
from typing import List
Expand Down Expand Up @@ -149,6 +150,7 @@ class EventTypes(Enum):
format_version: int = Field(default=1)
disposition: TableDisposition = Field(default=TableDisposition.SNAPSHOT)
metadata: dict = Field(default_factory=dict)
created_at: int = int(time.time_ns() / 1e6)

def is_valid(self):
# only columns in the schema can be encrypted
Expand All @@ -167,6 +169,7 @@ class OwnerEntry(Eventable, TarchiaBaseModel):
type (OwnerType): The type of the owner.
user (str): The name of the user/group that owns this group.
memberships (List(str)): Identifiers to automatically map users to Owners
created_at (int): Timestamp this record was creted.
"""

class EventTypes(Enum):
Expand All @@ -180,6 +183,7 @@ class EventTypes(Enum):
type: OwnerType
steward: str
memberships: List[str]
created_at: int = int(time.time_ns() / 1e6)

def is_valid(self):
if not self.name.isidentifier():
Expand Down

0 comments on commit 6b688af

Please sign in to comment.