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(code): improve abstractions #28

Merged
merged 1 commit into from
Dec 14, 2024
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
2 changes: 1 addition & 1 deletion src/bikes/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Components related to external operations."""
"""Components related to external operations (inputs and outputs)."""
3 changes: 2 additions & 1 deletion src/bikes/io/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ class ParquetReader(Reader):
KIND: T.Literal["ParquetReader"] = "ParquetReader"

path: str
backend: T.Literal["pyarrow", "numpy_nullable"] = "pyarrow"

@T.override
def read(self) -> pd.DataFrame:
# can't limit rows at read time
data = pd.read_parquet(self.path)
data = pd.read_parquet(self.path, dtype_backend="pyarrow")
if self.limit is not None:
data = data.head(self.limit)
return data
Expand Down
2 changes: 1 addition & 1 deletion src/bikes/io/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def run_context(self, run_config: RunConfig) -> T.Generator[mlflow.ActiveRun, No
run (str): run parameters.

Yields:
T.Generator[mlflow.ActiveRun, None, None]: active run context. Will be closed as the end of context.
T.Generator[mlflow.ActiveRun, None, None]: active run context. Will be closed at the end of context.
"""
with mlflow.start_run(
run_name=run_config.name,
Expand Down
2 changes: 1 addition & 1 deletion src/bikes/utils/signers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class Signer(abc.ABC, pdt.BaseModel, strict=True, frozen=True, extra="forbid"):
"""Base class for generating model signatures.

Allow to switch between model signing strategies.
Allow switching between model signing strategies.
e.g., automatic inference, manual model signature, ...

https://mlflow.org/docs/latest/models.html#model-signature-and-input-example
Expand Down
4 changes: 3 additions & 1 deletion src/bikes/utils/splitters.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ def split(
targets: schemas.Targets,
groups: Index | None = None,
) -> TrainTestSplits:
splitter = model_selection.TimeSeriesSplit(n_splits=self.n_splits, test_size=self.test_size)
splitter = model_selection.TimeSeriesSplit(
n_splits=self.n_splits, test_size=self.test_size, gap=self.gap
)
yield from splitter.split(inputs)

@T.override
Expand Down