Skip to content

Commit d73ba64

Browse files
committed
Add warning for AUTO_SELECT_SERIES usage and restore test case for missing data
1 parent 22c3291 commit d73ba64

File tree

2 files changed

+41
-36
lines changed

2 files changed

+41
-36
lines changed

ads/opctl/operator/lowcode/forecast/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ def operate(operator_config: ForecastOperatorConfig) -> ForecastResults:
8181
and not operator_config.spec.target_category_columns
8282
):
8383

84+
logger.warning(
85+
"AUTO_SELECT_SERIES cannot be run with a single-series dataset or when "
86+
"'target_category_columns' is not provided. Falling back to AUTO_SELECT."
87+
)
88+
8489
operator_config.spec.model = AUTO_SELECT
8590
model = ForecastOperatorModelFactory.get_model(operator_config, datasets)
8691
# For other cases, use the single selected model

tests/operators/forecast/test_datasets.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -414,43 +414,43 @@ def run_operator(
414414
# generate_train_metrics = True
415415

416416

417-
# def test_missing_data_autoselect_series():
418-
# """Test case for auto-select-series with missing data."""
419-
# data = {
420-
# "Date": pd.to_datetime(
421-
# [
422-
# "2023-01-01",
423-
# "2023-01-02",
424-
# "2023-01-03",
425-
# "2023-01-04",
426-
# "2023-01-05",
427-
# "2023-01-06",
428-
# "2023-01-07",
429-
# "2023-01-08",
430-
# "2023-01-09",
431-
# "2023-01-10",
432-
# ]
433-
# ),
434-
# "Y": [1, 2, np.nan, 4, 5, 6, 7, 8, 9, 10],
435-
# "Category": ["A", "A", "A", "A", "A", "A", "A", "A", "A", "A"],
436-
# }
437-
# df = pd.DataFrame(data)
417+
def test_missing_data_autoselect_series():
418+
"""Test case for auto-select-series with missing data."""
419+
data = {
420+
"Date": pd.to_datetime(
421+
[
422+
"2023-01-01",
423+
"2023-01-02",
424+
"2023-01-03",
425+
"2023-01-04",
426+
"2023-01-05",
427+
"2023-01-06",
428+
"2023-01-07",
429+
"2023-01-08",
430+
"2023-01-09",
431+
"2023-01-10",
432+
]
433+
),
434+
"Y": [1, 2, np.nan, 4, 5, 6, 7, 8, 9, 10],
435+
"Category": ["A", "A", "A", "A", "A", "A", "A", "A", "A", "A"],
436+
}
437+
df = pd.DataFrame(data)
438438

439-
# with tempfile.TemporaryDirectory() as tmpdirname:
440-
# output_data_path = f"{tmpdirname}/results"
441-
# yaml_i = deepcopy(TEMPLATE_YAML)
442-
# yaml_i["spec"]["model"] = "auto-select-series"
443-
# yaml_i["spec"]["historical_data"].pop("url")
444-
# yaml_i["spec"]["historical_data"]["data"] = df
445-
# yaml_i["spec"]["target_column"] = "Y"
446-
# yaml_i["spec"]["datetime_column"]["name"] = "Date"
447-
# yaml_i["spec"]["target_category_columns"] = ["Category"]
448-
# yaml_i["spec"]["horizon"] = 2
449-
# yaml_i["spec"]["output_directory"]["url"] = output_data_path
450-
451-
# operator_config = ForecastOperatorConfig.from_dict(yaml_i)
452-
# forecast_operate(operator_config)
453-
# check_output_for_errors(output_data_path)
439+
with tempfile.TemporaryDirectory() as tmpdirname:
440+
output_data_path = f"{tmpdirname}/results"
441+
yaml_i = deepcopy(TEMPLATE_YAML)
442+
yaml_i["spec"]["model"] = "auto-select-series"
443+
yaml_i["spec"]["historical_data"].pop("url")
444+
yaml_i["spec"]["historical_data"]["data"] = df
445+
yaml_i["spec"]["target_column"] = "Y"
446+
yaml_i["spec"]["datetime_column"]["name"] = "Date"
447+
yaml_i["spec"]["target_category_columns"] = ["Category"]
448+
yaml_i["spec"]["horizon"] = 2
449+
yaml_i["spec"]["output_directory"]["url"] = output_data_path
450+
451+
operator_config = ForecastOperatorConfig.from_dict(yaml_i)
452+
forecast_operate(operator_config)
453+
check_output_for_errors(output_data_path)
454454

455455

456456
if __name__ == "__main__":

0 commit comments

Comments
 (0)