forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add write operator in new logical plan (ray-project#32440)
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
- Loading branch information
Showing
5 changed files
with
66 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from typing import Callable, Iterator | ||
|
||
from ray.data._internal.execution.interfaces import TaskContext | ||
from ray.data.block import Block, RowUDF | ||
from ray.data.datasource import Datasource | ||
|
||
|
||
def generate_write_fn( | ||
datasource: Datasource, **write_args | ||
) -> Callable[[Iterator[Block], TaskContext, RowUDF], Iterator[Block]]: | ||
# If the write op succeeds, the resulting Dataset is a list of | ||
# WriteResult (one element per write task). Otherwise, an error will | ||
# be raised. The Datasource can handle execution outcomes with the | ||
# on_write_complete() and on_write_failed(). | ||
def fn(blocks: Iterator[Block], ctx, fn) -> Iterator[Block]: | ||
return [[datasource.write(blocks, ctx, **write_args)]] | ||
|
||
return fn |
This file contains 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
This file contains 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