@@ -413,5 +413,81 @@ def run_operator(
413413# generate_train_metrics = True
414414
415415
416+ @pytest .mark .parametrize ("allowed" , [["prophet" , "arima" ], ["prophet" ], ["arima" ], ["automlx" ], ["neuralprophet" ]])
417+ def test_auto_select_series_model_list_filter (allowed ):
418+ # Skip neuralprophet when running with NumPy 2.x due to upstream np.NaN usage
419+ if "neuralprophet" in allowed :
420+ try :
421+ import numpy as np # local import to avoid unused import in other tests
422+ major = int (str (np .__version__ ).split ("." )[0 ])
423+ except Exception :
424+ major = 0
425+ if major >= 2 :
426+ pytest .skip ("Skipping neuralprophet with NumPy >= 2.0 due to upstream incompatibility (uses np.NaN)." )
427+
428+ # Skip pure-arima case if pmdarima cannot be imported (e.g., binary incompatibility with current NumPy)
429+ if [str (m ).lower () for m in allowed ] == ["arima" ]:
430+ try :
431+ import pmdarima as pm # noqa: F401
432+ except Exception as e :
433+ pytest .skip (f"Skipping arima due to pmdarima import error: { e } " )
434+
435+ dataset_name = f"{ DATASET_PREFIX } dataset1.csv"
436+ dataset_i = pd .read_csv (dataset_name )
437+ target = "Y"
438+
439+ with tempfile .TemporaryDirectory () as tmpdirname :
440+ historical_data_path = f"{ tmpdirname } /primary_data.csv"
441+ test_data_path = f"{ tmpdirname } /test_data.csv"
442+ output_data_path = f"{ tmpdirname } /results"
443+ yaml_i = deepcopy (TEMPLATE_YAML )
444+
445+ # Train/Test split
446+ dataset_i [[DATETIME_COL , target ]][:- PERIODS ].to_csv (
447+ historical_data_path , index = False
448+ )
449+ dataset_i [[DATETIME_COL , target ]][- PERIODS :].to_csv (test_data_path , index = False )
450+
451+ # Prepare YAML
452+ yaml_i ["spec" ]["historical_data" ]["url" ] = historical_data_path
453+ yaml_i ["spec" ]["test_data" ] = {"url" : test_data_path }
454+ yaml_i ["spec" ]["output_directory" ]["url" ] = output_data_path
455+ yaml_i ["spec" ]["model" ] = "auto-select-series"
456+ yaml_i ["spec" ]["target_column" ] = target
457+ yaml_i ["spec" ]["datetime_column" ]["name" ] = DATETIME_COL
458+ yaml_i ["spec" ]["horizon" ] = PERIODS
459+ yaml_i ["spec" ]["generate_metrics" ] = True
460+ yaml_i ["spec" ]["model_kwargs" ] = {"model_list" : allowed }
461+
462+ # Run operator
463+ run (yaml_i , backend = "operator.local" , debug = False )
464+
465+ # Collect per-model metrics produced by auto-select-series
466+ result_files = os .listdir (output_data_path )
467+ train_metrics_files = [
468+ f for f in result_files if f .startswith ("metrics_" ) and f .endswith (".csv" )
469+ ]
470+ test_metrics_files = [
471+ f
472+ for f in result_files
473+ if f .startswith ("test_metrics_" ) and f .endswith (".csv" )
474+ ]
475+
476+ # Extract model names from filenames
477+ found_models = set ()
478+ for f in train_metrics_files :
479+ found_models .add (f [len ("metrics_" ) : - len (".csv" )])
480+ for f in test_metrics_files :
481+ found_models .add (f [len ("test_metrics_" ) : - len (".csv" )])
482+
483+ assert found_models , "No per-model metrics files were generated."
484+ # Ensure only allowed models are present
485+ assert found_models .issubset (set (allowed )), f"Found disallowed models in outputs: { found_models - set (allowed )} "
486+
487+ # Ensure disallowed models are absent
488+ known_models = {"prophet" , "arima" , "neuralprophet" , "automlx" , "autots" }
489+ disallowed = known_models - set (allowed )
490+ assert found_models .isdisjoint (disallowed ), f"Disallowed models present: { found_models & disallowed } "
491+
416492if __name__ == "__main__" :
417493 pass
0 commit comments