Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

necessary changes to allow graph execution in dataloader #152

Merged
merged 4 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion merlin/dag/executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def _build_input_data(self, node, transformable, capture_dtypes=False):
else:
# If there are no parents, this is an input node,
# so pull columns directly from root data
input_data = transformable[node_input_cols + list(addl_input_cols)]
addl_input_cols = list(addl_input_cols) if addl_input_cols else []
input_data = transformable[node_input_cols + addl_input_cols]

return input_data

Expand Down Expand Up @@ -161,6 +162,10 @@ def _transform_data(self, node, input_data, capture_dtypes=False):

if is_list:
col_dtype = list_val_dtype(col_series)
if hasattr(col_dtype, "as_numpy_dtype"):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where having a "merlin" dtype would have been very helpful. We can avoid this code kludge.

col_dtype = col_dtype.as_numpy_dtype()
elif hasattr(col_series, "numpy"):
col_dtype = col_series[0].cpu().numpy().dtype

output_data_schema = output_col_schema.with_dtype(
col_dtype, is_list=is_list, is_ragged=is_list
Expand Down
2 changes: 2 additions & 0 deletions merlin/dag/ops/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,6 @@ def compute_output_schema(
The schemas of the columns produced by this operator
"""
selector = col_selector or self.selector
if selector.all:
selector = ColumnSelector(input_schema.column_names)
return super().compute_output_schema(input_schema, selector, prev_output_schema)
11 changes: 11 additions & 0 deletions tests/unit/dag/ops/test_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,14 @@ def test_selection_output_schema(df):
result_schema = op.compute_output_schema(schema, ColumnSelector())

assert result_schema.column_names == ["x", "y"]


@pytest.mark.parametrize("engine", ["parquet"])
def test_selection_wildcard_output_schema(df):
selector = ColumnSelector("*")
schema = Schema([ColumnSchema(col) for col in df.columns])
op = SelectionOp(selector)

result_schema = op.compute_output_schema(schema, ColumnSelector())

assert result_schema.column_names == schema.column_names