Skip to content

Commit

Permalink
branching
Browse files Browse the repository at this point in the history
  • Loading branch information
joocer committed Jul 25, 2024
1 parent 1f09b85 commit d467f9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 4 additions & 0 deletions tarchia/api/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from fastapi import APIRouter

from .branch_management import router as branch_router
from .commit_management import router as commit_router
from .data_management import router as data_router
from .owner_management import router as owner_router
from .search import router as search_router
from .table_management import router as table_router

v1_router = APIRouter(prefix="/v1")
v1_router.include_router(branch_router, tags=["Branch Management"])
v1_router.include_router(commit_router, tags=["Commit Management"])
v1_router.include_router(data_router, tags=["Data Management"])
v1_router.include_router(owner_router, tags=["Owner Management"])
v1_router.include_router(search_router, tags=["Search"])
v1_router.include_router(table_router, tags=["Table Management"])
12 changes: 6 additions & 6 deletions tarchia/api/v1/data_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ def xor_hex_strings(hex_strings: List[str]) -> str:
return result_bytes.hex()


@router.post("/tables/{owner}/{table}/commits/{commit}/pull/start")
@router.post("/tables/{owner}/{table}/commits/{commit_sha}/pull/start")
async def start_transaction(
owner: str = Path(description="The owner of the table.", pattern=IDENTIFIER_REG_EX),
table: str = Path(description="The name of the table.", pattern=IDENTIFIER_REG_EX),
commit: Union[str, Literal["head"]] = Path(description="The commit to retrieve."),
commit_sha: Union[str, Literal["head"]] = Path(description="The commit to retrieve."),
):
from tarchia.interfaces.storage import storage_factory
from tarchia.utils import build_root
Expand All @@ -156,12 +156,12 @@ async def start_transaction(
catalog_entry = identify_table(owner=owner, table=table)
table_id = catalog_entry.table_id

if commit == "head":
commit = catalog_entry.current_commit_sha
if commit_sha == "head":
commit_sha = catalog_entry.current_commit_sha

commit_root = build_root(COMMITS_ROOT, owner=owner, table_id=catalog_entry.table_id)
storage_provider = storage_factory()
parent_commit = load_old_commit(storage_provider, commit_root, commit)
parent_commit = load_old_commit(storage_provider, commit_root, commit_sha)

if parent_commit is None:
raise TransactionError("Commit not found")
Expand All @@ -173,7 +173,7 @@ async def start_transaction(
table_id=table_id,
table=table,
owner=owner,
parent_commit_sha=commit,
parent_commit_sha=commit_sha,
additions=[],
deletions=[],
truncate=False,
Expand Down
1 change: 0 additions & 1 deletion tarchia/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@
from .request_models import CreateOwnerRequest
from .request_models import CreateTableRequest
from .request_models import StageFilesRequest
from .request_models import TableRequest
from .request_models import UpdateMetadataRequest
from .request_models import UpdateValueRequest

0 comments on commit d467f9a

Please sign in to comment.