55import pandas as pd
66import pytest
77
8- if not sys .version_info >= ( 3 , 12 ) :
8+ if sys .platform != "win32" :
99 import ray
1010from dask .distributed import Client
1111from fugue_dask import DaskExecutionEngine
@@ -185,17 +185,47 @@ def test_distribute_cv_predictions(df):
185185
186186
187187# # | eval: false
188+ @pytest .fixture (scope = "module" )
189+ def ray_session ():
190+ """Initialize Ray once for all tests in this module and shutdown afterwards."""
191+ if sys .platform == "win32" :
192+ yield None
193+ return
194+
195+ # Initialize Ray with runtime environment to exclude large files
196+ if not ray .is_initialized ():
197+ ray .init (
198+ num_cpus = 2 ,
199+ ignore_reinit_error = True ,
200+ include_dashboard = False ,
201+ _metrics_export_port = None ,
202+ runtime_env = {
203+ "working_dir" : None , # Don't upload working directory for local testing
204+ },
205+ )
206+
207+ yield ray
208+
209+ # Cleanup: shutdown Ray after all tests in this module complete
210+ if ray .is_initialized ():
211+ ray .shutdown ()
212+
213+
188214@pytest .fixture
189- def ray_df ():
215+ def ray_df (ray_session ):
216+ """Generate test data as Ray Dataset."""
217+ if sys .platform == "win32" :
218+ pytest .skip ("Ray is in beta for Windows." )
219+
190220 # Generate Synthetic Panel Data.
191- df = generate_series (10 ).reset_index ()
221+ df = generate_series (5 ).reset_index ()
192222 df ["unique_id" ] = df ["unique_id" ].astype (str )
193223 df = ray .data .from_pandas (df ).repartition (2 )
194224 return df
195225
196226
197227@pytest .mark .skipif (
198- sys .version_info >= ( 3 , 12 ), reason = "This test is not compatible with Python 3.12+ "
228+ sys .platform == "win32" , reason = "Ray is in beta for Windows. "
199229)
200230def test_ray_cv_predictions (ray_df ):
201231 df = ray_df
@@ -231,7 +261,7 @@ def test_ray_cv_predictions(ray_df):
231261
232262
233263@pytest .mark .skipif (
234- sys .version_info >= ( 3 , 12 ), reason = "This test is not compatible with Python 3.12+ "
264+ sys .platform == "win32" , reason = "Ray is in beta for Windows. "
235265)
236266def test_ray_cv_fallback_model (ray_df ):
237267 df = ray_df
@@ -249,7 +279,7 @@ def test_ray_cv_fallback_model(ray_df):
249279 pd .testing .assert_frame_equal (fcst_fugue .astype (fcst_stats .dtypes ), fcst_stats )
250280
251281@pytest .mark .skipif (
252- sys .version_info >= ( 3 , 12 ), reason = "This test is not compatible with Python 3.12+ "
282+ sys .platform == "win32" , reason = "Ray is in beta for Windows. "
253283)
254284def test_ray_distributed_exogenous_regressors (df_w_ex ):
255285 df_w_ex , train_df , test_df , xreg = df_w_ex
0 commit comments