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

[Serve][Doc] Update docs about input schema, and json_request adapter #24191

Merged
merged 6 commits into from
Apr 27, 2022

Conversation

simon-mo
Copy link
Contributor

Why are these changes needed?

This PR dives into more detail about the input schema type. In particular:

Related issue number

Closes #23484

Checks

  • 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
    • Unit tests
    • Release tests
    • This PR is not tested :(

@@ -16,15 +16,15 @@ kernelspec:

# Deployment Graph

```{note}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

trailing whitespace, hard to revert but good for code quality, so i kept these changes.

@@ -394,31 +420,21 @@ more info on these options.

Now we're done! The full example below covers the full example for you to try out.

```{code-cell} ipython3
:tags: [remove-cell]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should show some of these so when people copy the full example from the web page, the code works end to end

# Each serve dag has a driver deployment as ingress that can be user provided.
serve_dag = DAGDriver.options(route_prefix="/my-dag").bind(dag)
serve_dag = DAGDriver.options(route_prefix="/my-dag", num_replicas=2).bind(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

verified locally running this example works end to end. we should convert this to a Python file and run in CI (but in a separate PR)

doc/source/serve/deployment-graph.md Outdated Show resolved Hide resolved
```{note}
We expect each DAG has a driver class implementation as root, similar to the example below. This is where HTTP ingress are configured and implemented. We provide a default `DAGDriver` to handle simple HTTP parsing, but in this example we put up a custom implementation.
Serve provides a default DAGDriver implementation that accepts HTTP request and orchestrate the deployment graph execution. You can import it from `from ray.serve.drivers import DAGDriver`.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should also mention user has all the freedom they want to provide their own DAGDriver implementation as ingress just as if what they would do today, and what we did here is to facilitate holding dag instance by providing a default template.

Realistically i think there'll be decent # of users who start with our default implementation then add their own code to it rather than our DAGDriver covers everything they need ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's in two paragraph below.

@jiaodong
Copy link
Member

does our CI provide a default link to the documentation based on latest commit to review the whole webpage ? i remember seeing it from my last iteration of the documentation

@simon-mo
Copy link
Contributor Author

https://ray--24191.org.readthedocs.build/en/24191/

yes just click the docs/readthedocs:ray" details page
image

@jiaodong
Copy link
Member

content looks good to me, do you want to change input_schema to http_adapter in this PR then ? It covers code, tests and documentation changes already

input_schema=json_request,
)
handle = serve.run(dag)
assert ray.get(handle.predict.remote([1, 2])) == [1, 2]
Copy link
Member

Choose a reason for hiding this comment

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

can you try it with an example that passes multiple objects to dag.execute(1, 2, [3,4]) ? I remember default DAGDriver will throw due to mismatched signature that lead to different behaviors between ray dag and serve dag regarding InputNode handling

@jiaodong jiaodong added the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Apr 27, 2022
@simon-mo simon-mo removed the @author-action-required The PR author is responsible for the next step. Remove tag to send back to the reviewer. label Apr 27, 2022
input_schema=json_request,
)
handle = serve.run(dag)
assert ray.get(handle.predict.remote([1, 2, [3, 4]])) == [1, 2, [3, 4]]
Copy link
Member

Choose a reason for hiding this comment

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

sorry i actually meant handle.predict.remote(1, 2, [3, 4]) so it's multiple args that will spawn InputAttributeNode rather than dealing with one python object. You can see them in https://sourcegraph.com/github.com/ray-project/ray/-/blob/python/ray/experimental/dag/tests/test_input_node.py?L225

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't make sense for typical DAGDriver here. The input is still a single item because predict and http request has a single value representing the input. As you can see in the dag users can still write input[0] to index into input node.

Copy link
Member

Choose a reason for hiding this comment

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

how about we use the same internal data wrapper as ray dag's execute ? https://sourcegraph.com/github.com/ray-project/ray/-/blob/python/ray/experimental/dag/input_node.py?L255

I understand eventually InputNode translate to one python object, but it's better if we can minimize the churn from user's dev flow if they find out they need to change input syntax / structure from ray core to serve dag. I'm not suggesting what we have now is already optimal, but they should be the same class.

Copy link
Member

@jiaodong jiaodong left a comment

Choose a reason for hiding this comment

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

synced offline and agreed on doing *args **kwargs unpacking on default DAGDriver

@simon-mo simon-mo merged commit ee52895 into ray-project:master Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] DAGDriver should support partial access of InputNode
3 participants