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

Add exception handler for model server and Add ability to specify custom handler #3405

Merged

Conversation

sivanantha321
Copy link
Member

@sivanantha321 sivanantha321 commented Feb 3, 2024

What this PR does / why we need it:

  • Handles Model server shutdown properly when exception occured.
  • Provides a way to add custom exception handler to the event loop

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #3404

Type of changes
Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Feature/Issue validation/testing:

Please describe the tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced.
Please also list any relevant details for your test configuration.

  • Test A
    Before:
Traceback (most recent call last):
  File "/home/ubuntu/go/src/github.com/kserve/kserve/python/sklearnserver/sklearnserver/__main__.py", line 41, in <module>
    kserve.ModelServer(registered_models=SKLearnModelRepository(args.model_dir), workers=6).start(
  File "/home/ubuntu/go/src/github.com/kserve/kserve/python/kserve/kserve/model_server.py", line 229, in start
    asyncio.run(servers_task())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/ubuntu/go/src/github.com/kserve/kserve/python/kserve/kserve/model_server.py", line 227, in servers_task
    await asyncio.gather(*servers)
  File "/home/ubuntu/go/src/github.com/kserve/kserve/python/kserve/kserve/model_server.py", line 214, in serve
    raise RuntimeError("Some Exception")
RuntimeError: Some Exception
Exception ignored in: <function Server.__del__ at 0x7f90add16170>
Traceback (most recent call last):
  File "/home/ubuntu/go/src/github.com/kserve/kserve/.venv/lib/python3.10/site-packages/grpc/aio/_server.py", line 185, in __del__
  File "src/python/grpcio/grpc/_cython/_cygrpc/aio/common.pyx.pxi", line 118, in grpc._cython.cygrpc.schedule_coro_threadsafe
  File "src/python/grpcio/grpc/_cython/_cygrpc/aio/common.pyx.pxi", line 110, in grpc._cython.cygrpc.schedule_coro_threadsafe
  File "/usr/lib/python3.10/asyncio/base_events.py", line 436, in create_task
  File "/usr/lib/python3.10/asyncio/base_events.py", line 515, in _check_closed
RuntimeError: Event loop is closed
sys:1: RuntimeWarning: coroutine 'AioServer.shutdown' was never awaited

After:

Traceback (most recent call last):
  File "/home/ubuntu/go/src/github.com/kserve/kserve/python/sklearnserver/sklearnserver/__main__.py", line 41, in <module>
    kserve.ModelServer(registered_models=SKLearnModelRepository(args.model_dir), workers=6).start(
  File "/home/ubuntu/go/src/github.com/kserve/kserve/python/kserve/kserve/model_server.py", line 224, in start
    asyncio.run(servers_task())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/ubuntu/go/src/github.com/kserve/kserve/python/kserve/kserve/model_server.py", line 222, in servers_task
    await asyncio.gather(*servers)
  File "/home/ubuntu/go/src/github.com/kserve/kserve/python/kserve/kserve/model_server.py", line 209, in serve
    raise RuntimeError("Some Exception")
RuntimeError: Some Exception
  • Logs

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Checklist:

  • Have you added unit/e2e tests that prove your fix is effective or that this feature works?
  • Has code been commented, particularly in hard-to-understand areas?
  • Have you made corresponding changes to the documentation?

Release note:

Add exception handler for model server and Add ability to specify custom exception handler

@sivanantha321 sivanantha321 changed the title Add exception handler for model server and Add ability to specify custom handlers Add exception handler for model server and Add ability to specify custom handler Feb 3, 2024
@sivanantha321 sivanantha321 force-pushed the add-exception-handler-model-server branch 3 times, most recently from b30f693 to 4313416 Compare February 3, 2024 16:12
@rachitchauhan43
Copy link
Contributor

@sivanantha321 : Possible to get a unit test case around this feature to test that custom exception handler is indeed getting added ?

Copy link
Contributor

@rachitchauhan43 rachitchauhan43 left a comment

Choose a reason for hiding this comment

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

Left a comment regarding unit test , rest LGTM

@sivanantha321 sivanantha321 force-pushed the add-exception-handler-model-server branch from 4313416 to 01c618b Compare February 6, 2024 14:50
@sivanantha321
Copy link
Member Author

@sivanantha321 : Possible to get a unit test case around this feature to test that custom exception handler is indeed getting added ?

I tried. But I am not able to get it to work.

…tom exception handler

Signed-off-by: Sivanantham Chinnaiyan <sivanantham.chinnaiyan@ideas2it.com>
@sivanantha321 sivanantha321 force-pushed the add-exception-handler-model-server branch from 01c618b to 9955d28 Compare February 6, 2024 15:59
Copy link

oss-prow-bot bot commented Feb 7, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rachitchauhan43, sivanantha321

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@oss-prow-bot oss-prow-bot bot added the approved label Feb 7, 2024
@oss-prow-bot oss-prow-bot bot merged commit 5172dc8 into kserve:master Feb 7, 2024
60 checks passed
timothyjlaurent pushed a commit to timothyjlaurent/kserve that referenced this pull request Feb 21, 2024
…tom handler (kserve#3405)

Add exception handler for model server and Add ability to specify custom exception handler

Signed-off-by: Sivanantham Chinnaiyan <sivanantham.chinnaiyan@ideas2it.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add exception handler for model server
3 participants