Skip to content

Conversation

@aniketmaurya
Copy link
Collaborator

@aniketmaurya aniketmaurya commented May 23, 2025

What does this PR do?

Errors will be nicely rendered if rich is enabled. This will help in debugging.

Example

import litserve as ls

ls.configure_logging(use_rich=True)

class SimpleLitAPI(ls.LitAPI):
    def setup(self, device):
        self.model1 = lambda x: x**2
        self.model2 = lambda x: x**3

    def decode_request(self, request):
        return request["input"]

    def predict(self, x):
        a = self.model1(x)
        b = self.model2(x)
        c = a + b
        return {"output": c}

    def encode_response(self, output):
        return {"output": output}

if __name__ == "__main__":
    server = ls.LitServer(SimpleLitAPI(enable_async=True))
    server.run(port=8000)
image
Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

- Added `use_rich` parameter to `configure_logging` function to enable Rich logging if available.
- Implemented fallback to default logging if Rich is not installed, with appropriate warnings.
- Improved logging setup for better flexibility and user experience.
@codecov
Copy link

codecov bot commented May 23, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 86%. Comparing base (fb96478) to head (ba9e7eb).
Report is 1 commits behind head on main.

Additional details and impacted files
@@         Coverage Diff         @@
##           main   #510   +/-   ##
===================================
- Coverage    86%    86%   -0%     
===================================
  Files        37     37           
  Lines      2372   2384   +12     
===================================
+ Hits       2040   2049    +9     
- Misses      332    335    +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aniketmaurya aniketmaurya enabled auto-merge (squash) May 23, 2025 20:56
@aniketmaurya aniketmaurya merged commit 32c2a97 into main May 23, 2025
21 checks passed
@aniketmaurya aniketmaurya deleted the enable-rich-handler branch May 23, 2025 21:06
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.

2 participants