Skip to content

Commit f42f647

Browse files
authored
Remove deprecated input-prep helpers and sklearn dependency (#506)
*Issue #, if available:* *Description of changes:* - Remove deprecated helpers in `_deprecated.py` - Add informative error messages for deprecated methods - Move `pandas[pyarrow]` to `extras`, install just `pandas` for the main package - Remove `sklearn` dependency By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent ec362e3 commit f42f647

6 files changed

Lines changed: 49 additions & 312 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ dependencies = [
1919
"accelerate>=1.1.0,<2",
2020
"numpy>=1.21,<3",
2121
"einops>=0.7.0,<1",
22-
"scikit-learn>=1.6.0,<2",
23-
"pandas[pyarrow]>=2.0,<2.4",
22+
"pandas>=2.0,<2.4",
2423
]
2524
classifiers = [
2625
"Programming Language :: Python :: 3",
@@ -44,6 +43,7 @@ extras = [
4443
"boto3>=1.10,<2",
4544
"peft>=0.18.1,<1",
4645
"fev>=0.6.1",
46+
"pandas[pyarrow]>=2.0,<2.4",
4747
]
4848
test = [
4949
"pytest~=8.0",
@@ -61,7 +61,6 @@ dev = [
6161
"joblib",
6262
"fev>=0.6.1",
6363
"rich",
64-
"pandas>=2.0,<2.4",
6564
]
6665

6766
[project.urls]

src/chronos/base.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
1313

1414
import numpy as np
15+
import pandas as pd
1516
import torch
1617

1718
if TYPE_CHECKING:
1819
import datasets
1920
import fev
20-
import pandas as pd
2121
from transformers import PreTrainedModel
2222

2323

@@ -134,7 +134,7 @@ def predict_quantiles(
134134

135135
def predict_df(
136136
self,
137-
df: "pd.DataFrame",
137+
df: pd.DataFrame,
138138
*,
139139
id_column: str = "item_id",
140140
timestamp_column: str = "timestamp",
@@ -144,7 +144,7 @@ def predict_df(
144144
validate_inputs: bool = True,
145145
freq: str | None = None,
146146
**predict_kwargs,
147-
) -> "pd.DataFrame":
147+
) -> pd.DataFrame:
148148
"""
149149
Perform forecasting on time series data in a long-format pandas DataFrame.
150150
@@ -185,12 +185,7 @@ def predict_df(
185185
- "predictions": The point predictions generated by the model
186186
- One column for predictions at each quantile level in `quantile_levels`
187187
"""
188-
try:
189-
import pandas as pd
190-
191-
from .df_utils import convert_df_input_to_list_of_dicts_input
192-
except ImportError:
193-
raise ImportError("pandas is required for predict_df. Please install it with `pip install pandas`.")
188+
from .df_utils import convert_df_input_to_list_of_dicts_input
194189

195190
if not isinstance(target, str):
196191
raise ValueError(

src/chronos/chronos2/_deprecated.py

Lines changed: 0 additions & 259 deletions
This file was deleted.

src/chronos/chronos2/dataset.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
from torch.utils.data import IterableDataset
1313

1414
from chronos.chronos2 import preprocess
15-
from chronos.chronos2._deprecated import (
16-
convert_list_of_tensors_input_to_list_of_dicts_input,
17-
convert_tensor_input_to_list_of_dicts_input,
18-
prepare_inputs,
19-
validate_and_prepare_single_dict_input,
20-
)
2115
from chronos.chronos2.preprocess import PreparedInput
2216

2317
__all__ = [
@@ -27,11 +21,6 @@
2721
"convert_fev_window_to_list_of_dicts_input",
2822
"left_pad_and_cat_2D",
2923
"validate_prepared_schema",
30-
# Deprecated re-exports — prefer chronos.chronos2.preprocess.from_* for new code.
31-
"convert_list_of_tensors_input_to_list_of_dicts_input",
32-
"convert_tensor_input_to_list_of_dicts_input",
33-
"prepare_inputs",
34-
"validate_and_prepare_single_dict_input",
3524
]
3625

3726
if TYPE_CHECKING:
@@ -434,3 +423,32 @@ def __iter__(self) -> Iterator:
434423
yield batch
435424
else:
436425
yield from self._generate_sequential_batches()
426+
427+
@classmethod
428+
def convert_inputs(cls, *args, **kwargs):
429+
raise RuntimeError(
430+
"`Chronos2Dataset.convert_inputs` has been deprecated. "
431+
"Please use the `chronos.chronos2.preprocess` module instead."
432+
)
433+
434+
435+
# Deprecated methods
436+
def validate_and_prepare_single_dict_task(*args, **kwargs):
437+
raise RuntimeError(
438+
"`validate_and_prepare_single_dict_task` has been deprecated. "
439+
"Please use `chronos.chronos2.preprocess.from_list_of_dicts` instead."
440+
)
441+
442+
443+
def convert_list_of_tensors_input_to_list_of_dicts_input(*args, **kwargs):
444+
raise RuntimeError(
445+
"`convert_list_of_tensors_input_to_list_of_dicts_input` has been deprecated. "
446+
"Please use `chronos.chronos2.preprocess.from_list_of_tensors` instead."
447+
)
448+
449+
450+
def convert_tensor_input_to_list_of_dicts_input(*args, **kwargs):
451+
raise RuntimeError(
452+
"`convert_tensor_input_to_list_of_dicts_input` has been deprecated. "
453+
"Please use `chronos.chronos2.preprocess.from_tensor` instead."
454+
)

0 commit comments

Comments
 (0)