Skip to content

Commit c3ec5fe

Browse files
committed
Fix pyarrow necessity
1 parent cedcdda commit c3ec5fe

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

examples/async/datasets/read.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ def local_path(path: str) -> pathlib.Path:
1616

1717

1818
async def main() -> None:
19+
# This example needs to have pyarrow installed
20+
import pyarrow # pylint: disable=import-outside-toplevel,unused-import
21+
1922
sdk = AsyncYCloudML(folder_id='b1ghsjum2v37c2un8h64')
2023
sdk.setup_default_logging()
2124

@@ -27,7 +30,7 @@ async def main() -> None:
2730
name=NAME,
2831
)
2932
dataset = await dataset_draft.upload()
30-
print(f'new {dataset=}')
33+
print(f'Going to read {dataset=} records')
3134
async for record in dataset.read():
3235
print(record)
3336

examples/sync/datasets/read.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def local_path(path: str) -> pathlib.Path:
1515

1616

1717
def main() -> None:
18+
# This example needs to have pyarrow installed
19+
import pyarrow # pylint: disable=import-outside-toplevel,unused-import
20+
1821
sdk = YCloudML(folder_id='b1ghsjum2v37c2un8h64')
1922
sdk.setup_default_logging()
2023

@@ -26,7 +29,7 @@ def main() -> None:
2629
name=NAME,
2730
)
2831
dataset = dataset_draft.upload()
29-
print(f'new {dataset=}')
32+
print(f'Going to read {dataset=} records')
3033
for record in dataset.read():
3134
print(record)
3235

src/yandex_cloud_ml_sdk/_utils/pyarrow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from collections.abc import AsyncIterator, Iterator
55
from typing import Any
66

7-
import pyarrow.dataset as pd
8-
97
RecordType = dict[Any, Any]
108

119

@@ -27,6 +25,8 @@ def get_next() -> RecordType | None:
2725

2826

2927
def read_dataset_records_sync(path: str, batch_size: int | None) -> Iterator[RecordType]:
28+
import pyarrow.dataset as pd # pylint: disable=import-outside-toplevel
29+
3030
# we need use kwargs method to preserve original default value
3131
kwargs = {}
3232
if batch_size is not None:

0 commit comments

Comments
 (0)