Skip to content
Merged
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
1 change: 1 addition & 0 deletions cirro/sdk/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def create_sheet(self, sheet: Union[TableSheetInput, ViewSheetInput]) -> DataPor

diagnoses = project.create_sheet(
TableSheetInput(
sheet_type="TABLE",
name="Diagnoses",
namespace_name="default",
table_name="diagnoses",
Expand Down
16 changes: 8 additions & 8 deletions cirro/sdk/sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from pandas import DataFrame

from cirro_api_client.v1.models import ColumnDef, RowInsert, RowInsertValues, RowUpdate, RowUpdateValues, Sheet, \
SheetDetail, SheetJob, SheetQueryResponse, SheetType, SqlSortOrder, Status, TableSheetInput, Tag, ViewSheetInput
from cirro_api_client.v1.types import Unset
SheetDataRequest, SheetDetail, SheetJob, SheetQueryResponse, SheetSort, SheetType, SqlSortOrder, Status, \
TableSheetInput, Tag, ViewSheetInput
from cirro_api_client.v1.types import UNSET, Unset

from cirro.cirro_client import CirroApi
from cirro.sdk.asset import DataPortalAssets, DataPortalAsset
Expand Down Expand Up @@ -168,14 +169,13 @@ def to_dataframe(self,
Returns:
`pandas.DataFrame`
"""
sort = SheetSort(order_by=order_by if order_by is not None else UNSET,
order=order if order is not None else UNSET)
return query_to_dataframe(
lambda limit, page: self._client.sheets.get_data(
lambda limit, page: self._client.sheets.query_data(
project_id=self.project_id,
sheet_id=self.id,
limit=limit,
page=page,
order_by=order_by,
order=order
request=SheetDataRequest(limit=limit, page=page, sort=sort)
),
max_rows=max_rows
)
Expand Down Expand Up @@ -277,11 +277,11 @@ def update(self,
"""
detail = self._get_detail()
shared = {
"sheet_type": detail.sheet_type.value,
"name": self.name if name is None else name,
"namespace_name": detail.namespace_name,
"table_name": detail.table_name,
"description": self.description if description is None else description,
"audit_read_access": detail.audit_read_access,
"tags": detail.tags if tags is None else tags
}

Expand Down
41 changes: 7 additions & 34 deletions cirro/services/sheet.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from typing import List

from cirro_api_client.v1.api.sheets import get_sheets, get_sheet, create_sheet, update_sheet, delete_sheet, \
get_sheet_data, query_sheet_data, query_data, insert_sheet_data, update_sheet_data, delete_sheet_data, \
query_sheet_data, query_data, insert_sheet_data, update_sheet_data, delete_sheet_data, \
refresh_view, trigger_ingest, get_jobs
from cirro_api_client.v1.models import Sheet, SheetDetail, TableSheetInput, ViewSheetInput, CreateResponse, \
SheetUpdateResponse, SheetDataRequest, SheetQueryRequest, SheetQueryResponse, SheetDataUpdateResponse, \
RowInsert, RowUpdate, InsertRowsRequest, UpdateRowsRequest, DeleteRowsRequest, SheetIngestRequest, SheetJob, \
SqlSortOrder
from cirro_api_client.v1.types import UNSET
RowInsert, RowUpdate, InsertRowsRequest, UpdateRowsRequest, DeleteRowsRequest, SheetIngestRequest, SheetJob

from cirro.services.base import BaseService

Expand Down Expand Up @@ -83,46 +81,21 @@ def delete(self, project_id: str, sheet_id: str) -> None:
"""
delete_sheet.sync_detailed(project_id=project_id, sheet_id=sheet_id, client=self._api_client)

def get_data(self,
project_id: str,
sheet_id: str,
limit: int = 1000,
page: int = 1,
order_by: str = None,
order: SqlSortOrder = None) -> SheetQueryResponse:
def query_data(self, project_id: str, sheet_id: str, request: SheetDataRequest = None) -> SheetQueryResponse:
"""
Retrieve a page of rows from a sheet
Retrieve a page of rows from a sheet, with an optional sort and filter

The first column is always `_row_id`, which identifies the row for `update_rows` and `delete_rows`.

Args:
project_id (str): ID of the Project
sheet_id (str): ID of the Sheet
limit (int): Maximum number of rows to return (default 1,000)
page (int): Page to return (default 1)
order_by (str): Column to sort by
order (SqlSortOrder): Sort direction
"""
return get_sheet_data.sync(project_id=project_id,
sheet_id=sheet_id,
limit=limit,
page=page,
order_by=order_by if order_by is not None else UNSET,
order=order if order is not None else UNSET,
client=self._api_client)

def query_data(self, project_id: str, sheet_id: str, request: SheetDataRequest) -> SheetQueryResponse:
"""
Retrieve a page of rows from a sheet, with an optional sort and filter

Args:
project_id (str): ID of the Project
sheet_id (str): ID of the Sheet
request (cirro_api_client.v1.models.SheetDataRequest): Page, sort, and filter to apply
request (cirro_api_client.v1.models.SheetDataRequest): Page, sort, and filter to apply;
defaults to the first 1,000 rows, unsorted and unfiltered
"""
return query_sheet_data.sync(project_id=project_id,
sheet_id=sheet_id,
body=request,
body=request if request is not None else SheetDataRequest(),
client=self._api_client)

def raw_query(self,
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cirro"
version = "1.15.1"
version = "1.16.0"
description = "CLI tool and SDK for interacting with the Cirro platform"
authors = ["Cirro Bio <support@cirro.bio>"]
license = "MIT"
Expand All @@ -11,7 +11,7 @@ packages = [{include = "cirro"}]
[tool.poetry.dependencies]
python = ">3.11.0,<4.0"
attrs = ">=21.3.0"
cirro_api_client = "~1.7.2"
cirro_api_client = "~1.8.0"
click = "^8.5.0"
boto3 = "~=1.43"
questionary = "^2.0.1"
Expand Down
Loading
Loading