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

feat: add @bentoml.on_startup decorator #5194

Merged
merged 2 commits into from
Jan 23, 2025

Conversation

devin-ai-integration[bot]
Copy link
Contributor

feat: add @bentoml.on_startup decorator

Added @bentoml.on_startup decorator to mirror existing lifecycle hook functionality. The main difference from "@bentoml.on_shutdown" is that these hooks run on service startup rather than shutdown.

Changes:

  • Added on_startup decorator in _bentoml_sdk/decorators.py
  • Exposed decorator in bentoml/init.py
  • Implemented startup hook handling in new-style services
  • No code modifications needed for legacy services

Implementation details:

  • Follows same pattern as existing on_shutdown decorator
  • Uses bentoml_startup_hook attribute to mark methods
  • Supports both sync and async hooks
  • Uses existing logging patterns to announce hook execution

Link to Devin run: https://app.devin.ai/sessions/0ce5869203a9499696f2174a85c1490e

Added @bentoml.on_startup decorator to mirror existing lifecycle hook functionality:
- Added on_startup decorator in _bentoml_sdk/decorators.py
- Exposed decorator in bentoml/__init__.py
- Implemented startup hook handling in new-style services

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration devin-ai-integration bot requested a review from a team as a code owner January 23, 2025 01:33
@devin-ai-integration devin-ai-integration bot requested review from ssheng and removed request for a team January 23, 2025 01:33
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

@frostming frostming left a comment

Choose a reason for hiding this comment

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

You forget to expose the decorator in _bentoml_sdk/__init__.py, also please add docs for this new decorator.

@frostming frostming linked an issue Jan 23, 2025 that may be closed by this pull request
Copy link
Contributor

@frostming frostming left a comment

Choose a reason for hiding this comment

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

This is very nice, LGTM.

Copy link

Code Coverage

Package Statements
bentoml 54.37% (9756 / 17941)
Summary 54.37% (9756 / 17941)

@frostming frostming merged commit b64e9b4 into main Jan 23, 2025
53 checks passed
@frostming frostming deleted the devin/1737595967-add-on-startup-decorator branch January 23, 2025 01:48
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.

bug: async initialization not supported
1 participant