ray/python
Jiao 2d2b5745ae
[5/X][Pipeline][Ray DAG] Make Ray InputNode more powerful with attr accessor (#22793)
- Enhanced ray dag InputNode to take arbitrary user input via `.execute()`.
  - If only one value is provided, like `dag.execute(1)`, return raw value;
  - Otherwise wrap user input into an `DAGInputData` object that can be accessed via index or key.
  - User can also pass list / dict object and just access them via index [0] or key ["key"]
- Introduced `InputAttrNode` that helps to connect partial attribute of user input to the DAG. 
- Added context manager syntax for `InputNode`.
- Add InputNode enforcements with tests, such as DAG level singleton, exception with messages, etc. 
- Enforce only simple int or str key
- Take care of JSON serialization for InputNode that carried original context manager info, ensure it's preserved.
- DAGNode UUID is also preserved in JSON serde.

## Next steps

On ray dag level we're proceeding with
```
with InputNode() as input:      # Probably better to rename it to DAGInput()
   a = Model.bind(input[0])
   b = Model.bind(input.x)
   dag = combine.bind(a, b)
```
But also enforces
   1) InputNode is always used in context manager as opposed to directly created
   2) There should be one and only one InputNode instance for each dag.
   3) No args passed by user to InputNode at ray dag level.

Then in serve we subclass a ServeInputNode() to enhance it like the following to support HTTP input validation and conversion:
```
with ServeInputNode(schema=MySchemaCls) as input:
   a = Model.bind(input[0])
   b = Model.bind(input.x)
   dag = combine.bind(a, b)
```

## Checks

- [x] I've run `scripts/format.sh` to lint the changes in this PR.
- [ ] I've included any doc changes needed for https://docs.ray.io/en/master/.
- [ ] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [x] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

Co-authored-by: Eric Liang <ekhliang@gmail.com>
Co-authored-by: mwtian <81660174+mwtian@users.noreply.github.com>
2022-03-06 20:02:42 -06:00
..
ray [5/X][Pipeline][Ray DAG] Make Ray InputNode more powerful with attr accessor (#22793) 2022-03-06 20:02:42 -06:00
requirements [RLlib] Update pettingzoo==1.15.0 supersuit==3.3.3 (#22519) 2022-03-01 11:23:27 +01:00
asv.conf.json [docs] Move all /latest links to /master (#11897) 2020-11-10 10:53:28 -08:00
build-wheel-macos-arm64.sh Upgrade cython to 0.29.26 for py310 (#21244) 2021-12-26 20:26:08 -08:00
build-wheel-macos.sh Upgrade cython to 0.29.26 for py310 (#21244) 2021-12-26 20:26:08 -08:00
build-wheel-manylinux2014.sh Upgrade cython to 0.29.26 for py310 (#21244) 2021-12-26 20:26:08 -08:00
build-wheel-windows.sh [CI] Migrate Windows Wheels to Buildkite (#21388) 2022-01-05 12:49:19 -08:00
MANIFEST.in Includes .pyi files in package data. (#21247) 2021-12-27 11:50:02 -08:00
README-building-wheels.md [build] Build wheels with manylinux2014 (#11621) 2020-11-03 19:36:32 -08:00
requirements.txt [ci] Fix grpcio 1.44 break test_output (#22494) 2022-02-22 13:59:25 -08:00
requirements_linters.txt [CI] Add support for Black formatting (#21281) 2022-01-03 10:06:41 -08:00
requirements_ml_docker.txt [Deps] Bump tensorflow on Docker image and add Codeowners (#20041) 2021-11-05 00:58:34 -07:00
setup.py [Usage Stats] Implement usage stats report "Turned off by default". (#22249) 2022-02-22 15:32:02 -08:00