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] Fix traceback string for RayTaskErrors when deploying serve app #33120

Merged
merged 8 commits into from
Mar 13, 2023

Conversation

zcin
Copy link
Contributor

@zcin zcin commented Mar 8, 2023

Why are these changes needed?

If a syntax error occurs when Serve tries to import a Serve application and deploy it, the error will not show up correctly on serve status. Specifically it just shows ray.exceptions.RayTaskError(SyntaxError): <no detail available>. This makes it hard for users to debug.

This is because for some reason traceback.format_exc() does not get the traceback string correctly for RayTaskErrors; it seems to have it's own way of getting the traceback string here. So we need to change str(e).

Previously:

name: ''
app_status:
  status: DEPLOY_FAILED
  message: |
    Deployment failed:
    Traceback (most recent call last):
      File "/Users/cindyz/ray/python/ray/serve/_private/application_state.py", line 162, in update
        ray.get(finished[0])
      File "/Users/cindyz/ray/python/ray/_private/client_mode_hook.py", line 105, in wrapper
        return func(*args, **kwargs)
      File "/Users/cindyz/ray/python/ray/_private/worker.py", line 2384, in get
        raise value.as_instanceof_cause()
    ray.exceptions.RayTaskError(SyntaxError): <no detail available>
  deployment_timestamp: 1678228862.220114
deployment_statuses: []

With str(e):

name: ''
app_status:
  status: DEPLOY_FAILED
  message: |-
    Deployment failed:
    ray::run_graph() (pid=81000, ip=10.104.98.7)
      File "/Users/cindyz/ray/python/ray/serve/controller.py", line 859, in run_graph
        graph = import_attr(import_path)
      File "/Users/cindyz/miniforge3/envs/ray/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 839, in exec_module
      File "<frozen importlib._bootstrap_external>", line 976, in get_code
      File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/Users/cindyz/Desktop/fail.py", line 4
        print("yo")
        ^
    SyntaxError: invalid syntax
  deployment_timestamp: 1678228961.0310981
deployment_statuses: []

Related issue number

Closes #33118

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • 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 :(

Signed-off-by: Cindy Zhang <[email protected]>
@zcin zcin marked this pull request as ready for review March 8, 2023 01:14
@zcin
Copy link
Contributor Author

zcin commented Mar 8, 2023

Does anyone know how to get the lint checker to ignore a file?

@edoakes
Copy link
Contributor

edoakes commented Mar 8, 2023

@zcin you can add it to the excludes list here:

ray/.flake8

Line 1 in 35ffe75

[flake8]

self.app_msg = f"Deployment failed:\n{traceback.format_exc()}"
self.app_msg = f"Deployment failed:\n{str(e)}"
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this change the formatting & why is it required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added an example of how it changes the formatting in the PR description. I haven't dug into why yet (only saw this custom formatting function), I can look into it more later today.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh -- thanks for doing that :)

that's fine, let's leave a comment indicating that it is important and shouldn't be changed to traceback.format_exc() (which is more standard in my experience)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sg, will do!

Signed-off-by: Cindy Zhang <[email protected]>
Copy link
Contributor

@sihanwang41 sihanwang41 left a comment

Choose a reason for hiding this comment

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

thank you! nice fix

@zcin
Copy link
Contributor Author

zcin commented Mar 8, 2023

I'm not sure if it's possible to get linter to ignore a file with syntax error, since it can't even parse the file :(

@sihanwang41
Copy link
Contributor

I'm not sure if it's possible to get linter to ignore a file with syntax error, since it can't even parse the file :(

Can you give a try? https://docs.pylint.org/faq.html#how-can-i-tell-pylint-to-never-check-a-given-module

zcin added 2 commits March 8, 2023 15:44
Signed-off-by: Cindy Zhang <[email protected]>
@edoakes
Copy link
Contributor

edoakes commented Mar 9, 2023

@zcin looks like the linter error is now coming from black, I believe you can pass --exclude or --extend-exclude wherever we run the black command:
https://black.readthedocs.io/en/stable/usage_and_configuration/file_collection_and_discovery.html

@edoakes
Copy link
Contributor

edoakes commented Mar 9, 2023

This looks like the place:

BLACK_EXCLUDES=(

Signed-off-by: Cindy Zhang <[email protected]>
@ollie-iterators
Copy link

Something that could work if this doesn't is pylint: disable-next = ...

Signed-off-by: Cindy Zhang <[email protected]>
Signed-off-by: Cindy Zhang <[email protected]>
Comment on lines -152 to +158
'--force-exclude' 'python/ray/cloudpickle/*'
'--force-exclude' 'python/build/*'
'--force-exclude' 'python/ray/core/src/ray/gcs/*'
'--force-exclude' 'python/ray/thirdparty_files/*'
'--force-exclude' 'python/ray/_private/thirdparty/*'
'--force-exclude'
'python/ray/cloudpickle/*|'`
`'python/build/*|'`
`'python/ray/core/src/ray/gcs/*|'`
`'python/ray/thirdparty_files/*|'`
`'python/ray/_private/thirdparty/*|'`
`'python/ray/serve/tests/test_config_files/syntax_error\.py'
Copy link
Contributor Author

@zcin zcin Mar 11, 2023

Choose a reason for hiding this comment

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

I'm pretty sure --force-exclude only takes one regex string, so all the files need to be in that single regex string. When I tried adding python/ray/serve/tests/test_config_files/syntax_error.py as a --force-exclude here, the linter ignored syntax_error.py but started reformatting a bunch of files in python/ray/_private/thirdparty/*, so the last --force-exclude probably overrides all the previous ones. @ericl for approval on this code change?

Copy link
Contributor

@shrekris-anyscale shrekris-anyscale left a comment

Choose a reason for hiding this comment

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

Nice work!

@edoakes edoakes merged commit 9e2ee41 into ray-project:master Mar 13, 2023
@zcin zcin deleted the traceback-bug branch March 13, 2023 18:27
ProjectsByJackHe pushed a commit to ProjectsByJackHe/ray that referenced this pull request Mar 21, 2023
…pp (ray-project#33120)

If a syntax error occurs when Serve tries to import a Serve application and deploy it, the error will not show up correctly on `serve status`. Specifically it just shows `ray.exceptions.RayTaskError(SyntaxError): <no detail available>`. This makes it hard for users to debug.

This is because for some reason `traceback.format_exc()` does not get the traceback string correctly for `RayTaskError`s; it seems to have it's own way of getting the traceback string [here](https://github.com/ray-project/ray/blob/a892241ca7574af47f278a667e6493a4b03686d7/python/ray/exceptions.py#L163). So we need to change `str(e)`.

Previously:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |
    Deployment failed:
    Traceback (most recent call last):
      File "/Users/cindyz/ray/python/ray/serve/_private/application_state.py", line 162, in update
        ray.get(finished[0])
      File "/Users/cindyz/ray/python/ray/_private/client_mode_hook.py", line 105, in wrapper
        return func(*args, **kwargs)
      File "/Users/cindyz/ray/python/ray/_private/worker.py", line 2384, in get
        raise value.as_instanceof_cause()
    ray.exceptions.RayTaskError(SyntaxError): <no detail available>
  deployment_timestamp: 1678228862.220114
deployment_statuses: []
```

With `str(e)`:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |-
    Deployment failed:
    ray::run_graph() (pid=81000, ip=10.104.98.7)
      File "/Users/cindyz/ray/python/ray/serve/controller.py", line 859, in run_graph
        graph = import_attr(import_path)
      File "/Users/cindyz/miniforge3/envs/ray/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 839, in exec_module
      File "<frozen importlib._bootstrap_external>", line 976, in get_code
      File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/Users/cindyz/Desktop/fail.py", line 4
        print("yo")
        ^
    SyntaxError: invalid syntax
  deployment_timestamp: 1678228961.0310981
deployment_statuses: []
```

Signed-off-by: Jack He <[email protected]>
cadedaniel pushed a commit to cadedaniel/ray that referenced this pull request Mar 22, 2023
…pp (ray-project#33120)

If a syntax error occurs when Serve tries to import a Serve application and deploy it, the error will not show up correctly on `serve status`. Specifically it just shows `ray.exceptions.RayTaskError(SyntaxError): <no detail available>`. This makes it hard for users to debug. 

This is because for some reason `traceback.format_exc()` does not get the traceback string correctly for `RayTaskError`s; it seems to have it's own way of getting the traceback string [here](https://github.com/ray-project/ray/blob/a892241ca7574af47f278a667e6493a4b03686d7/python/ray/exceptions.py#L163). So we need to change `str(e)`. 

Previously:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |
    Deployment failed:
    Traceback (most recent call last):
      File "/Users/cindyz/ray/python/ray/serve/_private/application_state.py", line 162, in update
        ray.get(finished[0])
      File "/Users/cindyz/ray/python/ray/_private/client_mode_hook.py", line 105, in wrapper
        return func(*args, **kwargs)
      File "/Users/cindyz/ray/python/ray/_private/worker.py", line 2384, in get
        raise value.as_instanceof_cause()
    ray.exceptions.RayTaskError(SyntaxError): <no detail available>
  deployment_timestamp: 1678228862.220114
deployment_statuses: []
```

With `str(e)`:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |-
    Deployment failed:
    ray::run_graph() (pid=81000, ip=10.104.98.7)
      File "/Users/cindyz/ray/python/ray/serve/controller.py", line 859, in run_graph
        graph = import_attr(import_path)
      File "/Users/cindyz/miniforge3/envs/ray/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 839, in exec_module
      File "<frozen importlib._bootstrap_external>", line 976, in get_code
      File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/Users/cindyz/Desktop/fail.py", line 4
        print("yo")
        ^
    SyntaxError: invalid syntax
  deployment_timestamp: 1678228961.0310981
deployment_statuses: []
```
edoakes pushed a commit to edoakes/ray that referenced this pull request Mar 22, 2023
…pp (ray-project#33120)

If a syntax error occurs when Serve tries to import a Serve application and deploy it, the error will not show up correctly on `serve status`. Specifically it just shows `ray.exceptions.RayTaskError(SyntaxError): <no detail available>`. This makes it hard for users to debug.

This is because for some reason `traceback.format_exc()` does not get the traceback string correctly for `RayTaskError`s; it seems to have it's own way of getting the traceback string [here](https://github.com/ray-project/ray/blob/a892241ca7574af47f278a667e6493a4b03686d7/python/ray/exceptions.py#L163). So we need to change `str(e)`.

Previously:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |
    Deployment failed:
    Traceback (most recent call last):
      File "/Users/cindyz/ray/python/ray/serve/_private/application_state.py", line 162, in update
        ray.get(finished[0])
      File "/Users/cindyz/ray/python/ray/_private/client_mode_hook.py", line 105, in wrapper
        return func(*args, **kwargs)
      File "/Users/cindyz/ray/python/ray/_private/worker.py", line 2384, in get
        raise value.as_instanceof_cause()
    ray.exceptions.RayTaskError(SyntaxError): <no detail available>
  deployment_timestamp: 1678228862.220114
deployment_statuses: []
```

With `str(e)`:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |-
    Deployment failed:
    ray::run_graph() (pid=81000, ip=10.104.98.7)
      File "/Users/cindyz/ray/python/ray/serve/controller.py", line 859, in run_graph
        graph = import_attr(import_path)
      File "/Users/cindyz/miniforge3/envs/ray/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 839, in exec_module
      File "<frozen importlib._bootstrap_external>", line 976, in get_code
      File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/Users/cindyz/Desktop/fail.py", line 4
        print("yo")
        ^
    SyntaxError: invalid syntax
  deployment_timestamp: 1678228961.0310981
deployment_statuses: []
```

Signed-off-by: Edward Oakes <[email protected]>
peytondmurray pushed a commit to peytondmurray/ray that referenced this pull request Mar 22, 2023
…pp (ray-project#33120)

If a syntax error occurs when Serve tries to import a Serve application and deploy it, the error will not show up correctly on `serve status`. Specifically it just shows `ray.exceptions.RayTaskError(SyntaxError): <no detail available>`. This makes it hard for users to debug. 

This is because for some reason `traceback.format_exc()` does not get the traceback string correctly for `RayTaskError`s; it seems to have it's own way of getting the traceback string [here](https://github.com/ray-project/ray/blob/a892241ca7574af47f278a667e6493a4b03686d7/python/ray/exceptions.py#L163). So we need to change `str(e)`. 

Previously:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |
    Deployment failed:
    Traceback (most recent call last):
      File "/Users/cindyz/ray/python/ray/serve/_private/application_state.py", line 162, in update
        ray.get(finished[0])
      File "/Users/cindyz/ray/python/ray/_private/client_mode_hook.py", line 105, in wrapper
        return func(*args, **kwargs)
      File "/Users/cindyz/ray/python/ray/_private/worker.py", line 2384, in get
        raise value.as_instanceof_cause()
    ray.exceptions.RayTaskError(SyntaxError): <no detail available>
  deployment_timestamp: 1678228862.220114
deployment_statuses: []
```

With `str(e)`:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |-
    Deployment failed:
    ray::run_graph() (pid=81000, ip=10.104.98.7)
      File "/Users/cindyz/ray/python/ray/serve/controller.py", line 859, in run_graph
        graph = import_attr(import_path)
      File "/Users/cindyz/miniforge3/envs/ray/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 839, in exec_module
      File "<frozen importlib._bootstrap_external>", line 976, in get_code
      File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/Users/cindyz/Desktop/fail.py", line 4
        print("yo")
        ^
    SyntaxError: invalid syntax
  deployment_timestamp: 1678228961.0310981
deployment_statuses: []
```
scottsun94 pushed a commit to scottsun94/ray that referenced this pull request Mar 28, 2023
…pp (ray-project#33120)

If a syntax error occurs when Serve tries to import a Serve application and deploy it, the error will not show up correctly on `serve status`. Specifically it just shows `ray.exceptions.RayTaskError(SyntaxError): <no detail available>`. This makes it hard for users to debug. 

This is because for some reason `traceback.format_exc()` does not get the traceback string correctly for `RayTaskError`s; it seems to have it's own way of getting the traceback string [here](https://github.com/ray-project/ray/blob/a892241ca7574af47f278a667e6493a4b03686d7/python/ray/exceptions.py#L163). So we need to change `str(e)`. 

Previously:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |
    Deployment failed:
    Traceback (most recent call last):
      File "/Users/cindyz/ray/python/ray/serve/_private/application_state.py", line 162, in update
        ray.get(finished[0])
      File "/Users/cindyz/ray/python/ray/_private/client_mode_hook.py", line 105, in wrapper
        return func(*args, **kwargs)
      File "/Users/cindyz/ray/python/ray/_private/worker.py", line 2384, in get
        raise value.as_instanceof_cause()
    ray.exceptions.RayTaskError(SyntaxError): <no detail available>
  deployment_timestamp: 1678228862.220114
deployment_statuses: []
```

With `str(e)`:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |-
    Deployment failed:
    ray::run_graph() (pid=81000, ip=10.104.98.7)
      File "/Users/cindyz/ray/python/ray/serve/controller.py", line 859, in run_graph
        graph = import_attr(import_path)
      File "/Users/cindyz/miniforge3/envs/ray/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 839, in exec_module
      File "<frozen importlib._bootstrap_external>", line 976, in get_code
      File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/Users/cindyz/Desktop/fail.py", line 4
        print("yo")
        ^
    SyntaxError: invalid syntax
  deployment_timestamp: 1678228961.0310981
deployment_statuses: []
```
cassidylaidlaw pushed a commit to cassidylaidlaw/ray that referenced this pull request Mar 28, 2023
…pp (ray-project#33120)

If a syntax error occurs when Serve tries to import a Serve application and deploy it, the error will not show up correctly on `serve status`. Specifically it just shows `ray.exceptions.RayTaskError(SyntaxError): <no detail available>`. This makes it hard for users to debug. 

This is because for some reason `traceback.format_exc()` does not get the traceback string correctly for `RayTaskError`s; it seems to have it's own way of getting the traceback string [here](https://github.com/ray-project/ray/blob/a892241ca7574af47f278a667e6493a4b03686d7/python/ray/exceptions.py#L163). So we need to change `str(e)`. 

Previously:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |
    Deployment failed:
    Traceback (most recent call last):
      File "/Users/cindyz/ray/python/ray/serve/_private/application_state.py", line 162, in update
        ray.get(finished[0])
      File "/Users/cindyz/ray/python/ray/_private/client_mode_hook.py", line 105, in wrapper
        return func(*args, **kwargs)
      File "/Users/cindyz/ray/python/ray/_private/worker.py", line 2384, in get
        raise value.as_instanceof_cause()
    ray.exceptions.RayTaskError(SyntaxError): <no detail available>
  deployment_timestamp: 1678228862.220114
deployment_statuses: []
```

With `str(e)`:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |-
    Deployment failed:
    ray::run_graph() (pid=81000, ip=10.104.98.7)
      File "/Users/cindyz/ray/python/ray/serve/controller.py", line 859, in run_graph
        graph = import_attr(import_path)
      File "/Users/cindyz/miniforge3/envs/ray/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 839, in exec_module
      File "<frozen importlib._bootstrap_external>", line 976, in get_code
      File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/Users/cindyz/Desktop/fail.py", line 4
        print("yo")
        ^
    SyntaxError: invalid syntax
  deployment_timestamp: 1678228961.0310981
deployment_statuses: []
```
elliottower pushed a commit to elliottower/ray that referenced this pull request Apr 22, 2023
…pp (ray-project#33120)

If a syntax error occurs when Serve tries to import a Serve application and deploy it, the error will not show up correctly on `serve status`. Specifically it just shows `ray.exceptions.RayTaskError(SyntaxError): <no detail available>`. This makes it hard for users to debug.

This is because for some reason `traceback.format_exc()` does not get the traceback string correctly for `RayTaskError`s; it seems to have it's own way of getting the traceback string [here](https://github.com/ray-project/ray/blob/a892241ca7574af47f278a667e6493a4b03686d7/python/ray/exceptions.py#L163). So we need to change `str(e)`.

Previously:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |
    Deployment failed:
    Traceback (most recent call last):
      File "/Users/cindyz/ray/python/ray/serve/_private/application_state.py", line 162, in update
        ray.get(finished[0])
      File "/Users/cindyz/ray/python/ray/_private/client_mode_hook.py", line 105, in wrapper
        return func(*args, **kwargs)
      File "/Users/cindyz/ray/python/ray/_private/worker.py", line 2384, in get
        raise value.as_instanceof_cause()
    ray.exceptions.RayTaskError(SyntaxError): <no detail available>
  deployment_timestamp: 1678228862.220114
deployment_statuses: []
```

With `str(e)`:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |-
    Deployment failed:
    ray::run_graph() (pid=81000, ip=10.104.98.7)
      File "/Users/cindyz/ray/python/ray/serve/controller.py", line 859, in run_graph
        graph = import_attr(import_path)
      File "/Users/cindyz/miniforge3/envs/ray/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 839, in exec_module
      File "<frozen importlib._bootstrap_external>", line 976, in get_code
      File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/Users/cindyz/Desktop/fail.py", line 4
        print("yo")
        ^
    SyntaxError: invalid syntax
  deployment_timestamp: 1678228961.0310981
deployment_statuses: []
```

Signed-off-by: elliottower <[email protected]>
ProjectsByJackHe pushed a commit to ProjectsByJackHe/ray that referenced this pull request May 4, 2023
…pp (ray-project#33120)

If a syntax error occurs when Serve tries to import a Serve application and deploy it, the error will not show up correctly on `serve status`. Specifically it just shows `ray.exceptions.RayTaskError(SyntaxError): <no detail available>`. This makes it hard for users to debug.

This is because for some reason `traceback.format_exc()` does not get the traceback string correctly for `RayTaskError`s; it seems to have it's own way of getting the traceback string [here](https://github.com/ray-project/ray/blob/a892241ca7574af47f278a667e6493a4b03686d7/python/ray/exceptions.py#L163). So we need to change `str(e)`.

Previously:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |
    Deployment failed:
    Traceback (most recent call last):
      File "/Users/cindyz/ray/python/ray/serve/_private/application_state.py", line 162, in update
        ray.get(finished[0])
      File "/Users/cindyz/ray/python/ray/_private/client_mode_hook.py", line 105, in wrapper
        return func(*args, **kwargs)
      File "/Users/cindyz/ray/python/ray/_private/worker.py", line 2384, in get
        raise value.as_instanceof_cause()
    ray.exceptions.RayTaskError(SyntaxError): <no detail available>
  deployment_timestamp: 1678228862.220114
deployment_statuses: []
```

With `str(e)`:
```
name: ''
app_status:
  status: DEPLOY_FAILED
  message: |-
    Deployment failed:
    ray::run_graph() (pid=81000, ip=10.104.98.7)
      File "/Users/cindyz/ray/python/ray/serve/controller.py", line 859, in run_graph
        graph = import_attr(import_path)
      File "/Users/cindyz/miniforge3/envs/ray/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 839, in exec_module
      File "<frozen importlib._bootstrap_external>", line 976, in get_code
      File "<frozen importlib._bootstrap_external>", line 906, in source_to_code
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/Users/cindyz/Desktop/fail.py", line 4
        print("yo")
        ^
    SyntaxError: invalid syntax
  deployment_timestamp: 1678228961.0310981
deployment_statuses: []
```

Signed-off-by: Jack He <[email protected]>
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.

[Serve] Syntax error when deploying serve app will show as no detail available upon fetching serve status
5 participants