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] Java documentation #26321

Merged
merged 15 commits into from
Aug 12, 2022
Merged

[Serve] Java documentation #26321

merged 15 commits into from
Aug 12, 2022

Conversation

liuyang-my
Copy link
Contributor

@liuyang-my liuyang-my commented Jul 6, 2022

Why are these changes needed?

Now we have commit Ray Serve Java API. Users can use Java to deploy and access Ray Serve Deployment end-to-end. But there is no relevant documents. This PR will commit the documents about Ray Serve Java user case.

Related issue number

#22726

Closes #27580

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 :(

@simon-mo
Copy link
Contributor

Great start. Here's my recommendation:

Location

Content: doc/source/serve/getting_started_java.md

This page should be converted to end to end tutorial runnable by user. Imagine user just copy and past and it should work.
The general structure make sense; please add a page about using handle to call.

Content: doc/source/serve/managing-deployments-java.md

This page should cover more "how do I do X using the API". Because this is new, we should also discuss

  • Why should user consider this?
  • What's the benefit of using the Java API
  • Cross Language API
  • Future roadmap

@simon-mo simon-mo changed the title [WIP]Java Ray Serve docs [Serve] Java documentation Aug 2, 2022
Copy link
Contributor

@simon-mo simon-mo left a comment

Choose a reason for hiding this comment

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

Seems like the code is duplicated. You can use the literalinclude directive to embed the file without copying them https://myst-parser.readthedocs.io/en/latest/faq/index.html?highlight=literalinclude#include-a-file-from-outside-the-docs-folder-like-readme-md

doc/source/serve/managing-java-deployments.md Outdated Show resolved Hide resolved
doc/source/serve/managing-java-deployments.md Outdated Show resolved Hide resolved
doc/source/serve/managing-java-deployments.md Outdated Show resolved Hide resolved
doc/source/serve/tutorials/java.md Outdated Show resolved Hide resolved
doc/source/serve/tutorials/java.md Outdated Show resolved Hide resolved
@simon-mo simon-mo added the @external-author-action-required Alternate tag for PRs where the author doesn't have labeling permission. label Aug 2, 2022
@simon-mo
Copy link
Contributor

simon-mo commented Aug 5, 2022

Java is one of the mainstream programming languages for production services. Ray Serve natively supports Java API for creating, updating, and managing deployments. You can create Ray Serve deployments using Java and call them via Python, or vice versa.

This section should help you:

Copy link
Contributor

Choose a reason for hiding this comment

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

This section helps you to:

## Creating a Deployment

By specifying the full name of the class, we can create and deploy a deployment of the class.

Copy link
Contributor

Choose a reason for hiding this comment

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

By specifying the full name of the class as an argument to Serve.deployment() method, as shown in the code below, we can create and deploy our deployment of the class.

## Querying a Deployment

A deployed deployment can be found by its name.

Copy link
Contributor

Choose a reason for hiding this comment

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

The subheading seems a bit confusing. You are not querying per se. Rather, you are fetching an instance of the deployment. Perhaps, it ought to read: "Accessing your Deployment."


## Querying a Deployment

A deployed deployment can be found by its name.
Copy link
Contributor

Choose a reason for hiding this comment

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

Read awkward.

Once a deployment is deployed, you can fetch its instance by name.

```

## Configuring a Deployment

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a sentence here:

There are a couple of deployment configuration Serve supports:

  • ability to scale out by increasing number of deployment replicas
  • ability to assign resources such as CPU and GPUs.

The next two sections describe how to configure your deployments.

# Java Tutorial

First of all, using Java Ray Serve needs the following dependency in you `pom.xml`:

Copy link
Contributor

Choose a reason for hiding this comment

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

To use Java Ray Serve, you need the following dependency in your pom.xml.

```

> NOTE: After installing Ray, the Java jar of Ray Serve has been included locally. The `provided` scope could ensure the Java code using Ray Serve can be compiled and will not cause version conflicts when deployed on the cluster.

Copy link
Contributor

Choose a reason for hiding this comment

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

After installing Ray, the Java jar of Ray Serve is included locally.

:start-after: docs-deploy-start
```

The `Deployment.create` makes a `Deployment` object named "strategy". After executing `Deployment.deploy`, this "strategy" deployment is deployed in the instance of Ray Serve with 4 replicas, and we can access it for distributed parallel computing.
Copy link
Contributor

Choose a reason for hiding this comment

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

The Deployment.create makes a Deployment object named "strategy."

:start-after: docs-deploy-start
```

The `Deployment.create` makes a `Deployment` object named "strategy". After executing `Deployment.deploy`, this "strategy" deployment is deployed in the instance of Ray Serve with 4 replicas, and we can access it for distributed parallel computing.
Copy link
Contributor

Choose a reason for hiding this comment

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

4 replicas --> four replicas

```

At present, the calculation of each bank's each indicator is still in series, and just sended to Ray for execution. We can make the calculation concurrent, which not only improves the calculation efficiency, but also solves the bottleneck of single machine.

Copy link
Contributor

Choose a reason for hiding this comment

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

what does "is still in series," mean? Might want to clarify. Do you mean serial?

Copy link
Contributor

Choose a reason for hiding this comment

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

just sended to Ray --> sent to Ray

## Calling Ray Serve Deployment with HTTP

Another way to call a deployment is through the HTTP request. But there are now two limitations for the Java deployments:

Copy link
Contributor

Choose a reason for hiding this comment

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

Another way to test or call a deployment is ...

```

Now, the complete usage of `HttpStrategyCalcOnRayServe` is like this:

Copy link
Contributor

Choose a reason for hiding this comment

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

Finally, the complete usage ....

@liuyang-my liuyang-my requested a review from a team as a code owner August 11, 2022 05:08
@simon-mo simon-mo removed the request for review from sriram-anyscale August 11, 2022 05:08
@simon-mo
Copy link
Contributor

@dmatrix addressed!

@simon-mo simon-mo removed the @external-author-action-required Alternate tag for PRs where the author doesn't have labeling permission. label Aug 11, 2022
Copy link
Contributor

@dmatrix dmatrix left a comment

Choose a reason for hiding this comment

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

suggested minor nit otherwise LGTM

```

At present, the calculation of each bank's each indicator is still in series, and just sended to Ray for execution. We can make the calculation concurrent, which not only improves the calculation efficiency, but also solves the bottleneck of single machine.

Copy link
Contributor

Choose a reason for hiding this comment

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

just sended to Ray --> sent to Ray

Signed-off-by: simon-mo <[email protected]>
@simon-mo
Copy link
Contributor

Need Java code owner here as well. @WangTaoTheTonic, @kfstorm or @jovany-wang can you please approve?

@simon-mo simon-mo merged commit 6b886d3 into ray-project:master Aug 12, 2022
@kfstorm kfstorm deleted the serve-java-doc branch August 15, 2022 08:37
Stefan-1313 pushed a commit to Stefan-1313/ray_mod that referenced this pull request Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
serve Ray Serve Related Issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[serve][docs] Basic Java Documentation
4 participants