Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use "record" OpenAPI to replace the "data" OpenAPI #677

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions graviti/manager/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
get_commit,
get_commit_sheet,
get_revision,
list_commit_data,
list_commit_records,
list_commit_sheets,
list_commits,
)
Expand Down Expand Up @@ -92,9 +92,9 @@ def _load(self) -> None:
def _repr_head(self) -> str:
return f'{self.__class__.__name__}("{self.commit_id}")'

def _list_data(self, offset: int, limit: int, sheet_name: str) -> Dict[str, Any]:
def _list_records(self, offset: int, limit: int, sheet_name: str) -> Dict[str, Any]:
_workspace = self._dataset.workspace
return list_commit_data( # type: ignore[no-any-return]
return list_commit_records( # type: ignore[no-any-return]
_workspace.access_key,
_workspace.url,
_workspace.name,
Expand All @@ -103,7 +103,7 @@ def _list_data(self, offset: int, limit: int, sheet_name: str) -> Dict[str, Any]
sheet=sheet_name,
offset=offset,
limit=limit,
)["data"]
)["records"]

def _list_sheets(self) -> Dict[str, Any]:
if self.commit_id is None:
Expand Down
10 changes: 5 additions & 5 deletions graviti/manager/draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
create_draft,
get_draft,
get_draft_sheet,
list_draft_data,
list_draft_records,
list_draft_sheets,
list_drafts,
update_draft,
Expand Down Expand Up @@ -95,9 +95,9 @@ def __init__(
def _repr_head(self) -> str:
return f'{self.__class__.__name__}("#{self.number}: {self.title}")'

def _list_data(self, offset: int, limit: int, sheet_name: str) -> Dict[str, Any]:
def _list_records(self, offset: int, limit: int, sheet_name: str) -> Dict[str, Any]:
_workspace = self._dataset.workspace
return list_draft_data( # type: ignore[no-any-return]
return list_draft_records( # type: ignore[no-any-return]
_workspace.access_key,
_workspace.url,
_workspace.name,
Expand All @@ -106,7 +106,7 @@ def _list_data(self, offset: int, limit: int, sheet_name: str) -> Dict[str, Any]
sheet=sheet_name,
offset=offset,
limit=limit,
)["data"]
)["records"]

def _list_sheets(self) -> Dict[str, Any]:
_workspace = self._dataset.workspace
Expand Down Expand Up @@ -274,7 +274,7 @@ def upload(self, jobs: int = 8, quiet: bool = False) -> None:
factory = LazyLowerCaseFactory(
len(df),
LIMIT,
partial(self._list_data, sheet_name=name),
partial(self._list_records, sheet_name=name),
pa.struct([pa.field(RECORD_KEY, pa.string()), *patype]),
)
df._refresh_data_from_factory( # pylint: disable=protected-access)
Expand Down
4 changes: 2 additions & 2 deletions graviti/manager/sheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __delitem__(self, key: str) -> None:
def __iter__(self) -> Iterator[str]:
return self._get_data().__iter__()

def _list_data(self, offset: int, limit: int, sheet_name: str) -> Dict[str, Any]:
def _list_records(self, offset: int, limit: int, sheet_name: str) -> Dict[str, Any]:
raise NotImplementedError

def _list_sheets(self) -> Dict[str, Any]:
Expand All @@ -94,7 +94,7 @@ def _init_dataframe(self, sheet_name: str) -> DataFrame:
factory = LazyLowerCaseFactory(
sheet["record_count"],
LIMIT,
partial(self._list_data, sheet_name=sheet_name),
partial(self._list_records, sheet_name=sheet_name),
pa.struct([pa.field(RECORD_KEY, pa.string()), *patype]),
)
df = DataFrame._from_factory( # pylint: disable=protected-access
Expand Down
16 changes: 8 additions & 8 deletions graviti/operation/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from graviti.file import File, FileBase, RemoteFile
from graviti.openapi import (
RECORD_KEY,
add_data,
add_records,
copy_objects,
delete_data,
update_data,
delete_records,
update_records,
update_schema,
)
from graviti.operation.common import get_schema
Expand Down Expand Up @@ -155,14 +155,14 @@ def execute(
_upload_files(local_files, dataset.object_permission_manager, file_pbar, jobs)

_workspace = dataset.workspace
add_data(
add_records(
_workspace.access_key,
_workspace.url,
_workspace.name,
dataset.name,
draft_number=draft_number,
sheet=sheet,
data=batch.to_pylist(_to_backend=True),
records=batch.to_pylist(_to_backend=True),
)
data_pbar.update(len(batch))

Expand Down Expand Up @@ -266,14 +266,14 @@ def execute(
_upload_files(local_files, dataset.object_permission_manager, file_pbar, jobs)

_workspace = dataset.workspace
update_data(
update_records(
_workspace.access_key,
_workspace.url,
_workspace.name,
dataset.name,
draft_number=draft_number,
sheet=sheet,
data=batch.to_pylist(_to_backend=True),
records=batch.to_pylist(_to_backend=True),
)
data_pbar.update(len(batch))

Expand Down Expand Up @@ -311,7 +311,7 @@ def execute( # pylint: disable=unused-argument

"""
_workspace = dataset.workspace
delete_data(
delete_records(
_workspace.access_key,
_workspace.url,
_workspace.name,
Expand Down