Skip to content

Commit

Permalink
[Doc] [Serve] Add workaround to Serve docs for broken dependency (ray…
Browse files Browse the repository at this point in the history
…-project#33136)

The protobuf version in the latest Ray ML images is causing issues when importing certain libraries. This is the second sub-issue of ray-project#32775.

This PR adds a runtime_env-based workaround to the Serve examples to unblock users if they run into this issue. We will cherry pick this into the 2.3.1 branch and revert this PR on master once the underlying issue in the images is fixed on master.

This PR is based on ray-project#33024, thanks @kevin85421 for reporting and opening the PR!
  • Loading branch information
architkulkarni authored Mar 8, 2023
1 parent ac2230f commit b38b45f
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
29 changes: 28 additions & 1 deletion doc/source/serve/tutorials/batch.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,31 @@ Finally, let's run the script.
$ python tutorial_batch.py
```

You should get a similar output like before!
You should get a similar output like before!

## Troubleshooting

If you see the following error:

```console
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
```

You can downgrade the protobuf package to 3.20.x or lower in your Docker image, or tell Ray to do it at runtime by specifying a [runtime environment](runtime-environments):

Open a new YAML file called `batch_env.yaml` for runtime environment.

```yaml
pip:
- protobuf==3.20.3
```
Then, run the following command to deploy the model with the runtime environment.
```console
$ serve run --runtime-env batch_env.yaml tutorial_batch:generator
```
29 changes: 29 additions & 0 deletions doc/source/serve/tutorials/serve-ml-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,39 @@ Now that we've defined our Serve deployment, let's prepare it so that it can be
:::

Finally, we can deploy our model to Ray Serve through the terminal.

```console
$ serve run tutorial_tensorflow:mnist_model
```

:::{note}
If you see the following error:

```console
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
```

You can downgrade the protobuf package to 3.20.x or lower in your Docker image, or tell Ray to do it at runtime by specifying a [runtime environment](runtime-environments):

Open a new YAML file called `tf_env.yaml` for runtime environment.

```yaml
pip:
- protobuf==3.20.3
```
Then, run the following command to deploy the model with the runtime environment.
```console
$ serve run --runtime-env tf_env.yaml tutorial_tensorflow:mnist_model
```

:::

Let's query it! While Serve is running, open a separate terminal window, and run the following in an interactive Python shell or a separate Python script:

```python
Expand Down

0 comments on commit b38b45f

Please sign in to comment.