Skip to content

Commit f04ef22

Browse files
feat: FK Models (#584)
Co-authored-by: Antoine Bon <[email protected]>
1 parent a36a117 commit f04ef22

File tree

14 files changed

+2367
-375
lines changed

14 files changed

+2367
-375
lines changed

mostlyai/sdk/_data/file/base.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import re
1919
import time
2020
from abc import abstractmethod
21-
from collections.abc import Generator, Iterable
21+
from collections.abc import Generator, Iterable, Iterator
2222
from enum import Enum
2323
from pathlib import Path
2424
from typing import Any
@@ -375,6 +375,17 @@ def handle_if_exists(self, if_exists: str = "fail") -> str:
375375
return "a"
376376
return "w"
377377

378+
def iter_partitions(self) -> Iterator[tuple[int, Path, pd.DataFrame]]:
379+
"""Iterate over dataset partitions yielding (index, file_path, dataframe)."""
380+
for idx, file_path in enumerate(self.dataset.files):
381+
data = pd.read_parquet(file_path)
382+
yield idx, Path(file_path), data
383+
384+
@property
385+
def files(self) -> list[Path]:
386+
"""Get the list of partition files."""
387+
return [Path(f) for f in self.dataset.files]
388+
378389

379390
class FileContainer(DataContainer):
380391
SCHEMES = ["http", "https"]

0 commit comments

Comments
 (0)