[FIX] Pre-compute schema before Ray Dataset transform to prevent empty schema error#834
Open
K2alyan wants to merge 2 commits into
Open
[FIX] Pre-compute schema before Ray Dataset transform to prevent empty schema error#834K2alyan wants to merge 2 commits into
K2alyan wants to merge 2 commits into
Conversation
…y schema error When forecasting with exogenous variables on a Ray distributed Dataset, calling fa.get_schema() on the post-transform Dataset could return an empty schema, causing triad.collections.schema.SchemaError: Schema can't be empty. Fix by capturing the schema and column names from the original Dataset before the transform and appending _in_sample:bool explicitly, matching the pattern used in _get_schema(). Removes the xfail mark from test_forecast_x_dataframe in test_ray.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
forecast()withX_dfon a Ray distributed Dataset crashed with:The crash happened in
_distributed_forecastwhenX_dfis not None:fa.get_schema()called on a Ray Dataset afterfa.transformcan return an empty schema in some Fugue/Ray version combinations, because Ray Datasets do not always propagate Arrow schema metadata through Fugue's transform pipeline the same way Spark/Dask do. Passing an empty schema to the nextfa.transformcall triggersSchemaError: Schema can't be empty.Fix
Pre-compute the schema and column list before transforming
df(when the original Ray Dataset has a reliable schema), then append_in_sample:boolexplicitly. This is the same.copy()+.append()pattern already used in_get_schema()in this file.Behavior is identical for Spark and Dask (where
fa.get_schemaworks post-transform). For Ray it removes the crash.Test plan
@pytest.mark.xfailfromtest_forecast_x_dataframeinnixtla_tests/nixtla_client/test_ray.pypytest nixtla_tests/nixtla_client/test_ray.py -m ray_run— all tests including the previously-failingtest_forecast_x_dataframeshould pass