-
Notifications
You must be signed in to change notification settings - Fork 805
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
Allow access to artifacts in the service __init__(self) during pack process #1037
Comments
We encountered the same problem again where we need to load a json config file within the same package but couldn't. We had to use the same workaround for our config, which is awkward. I see |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is now possible in BentoML 1.0, where models are first saved in local model store before the Bento build process. User can also create a custom Runner class, and define the model initialization process:
|
Is your feature request related to a problem? Please describe.
In BentoML service class, we don't have access to artifacts during
pack
process, e.g.self.artifacts.my_artifact
, in the__init__(self)
method. The reason to have access to the artifacts in the init is so that I can pass the artifact to my class initialization, e.g.self._provider = Provider(self.artifacts.my_artifact)
. Later in the servicepredict
method, I can access my class this way, e.g.self._provider.fetch_predicted_value
, where the predicted value is computed value from the prediction produced bymy_artifact
.Describe the solution you'd like
In slack discussion message thread, a
service_init
callback is proposed to allow the above service initialization.Describe alternatives you've considered
In slack discussion message thread, a couple solutions were proposed. I ended up using
@property
decorator for my use case. It is a bit more code but it achieved the end result described above and made my code simpler.The text was updated successfully, but these errors were encountered: