Skip to content

How can I create attribute after create BentoService object? #2282

Answered by parano
kboseong asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @kboseong, exactly as @withsmilo suggested, in 0.13, there's no easy way to customize Service attributes per se: although it is possible to override the __init__ parameter of your BentoService class, but it must have a default value and you can't pass in parameters when starting the server. However, it looks like you can probably use the Artifact metadata to achieve what you need:

bento_svc = PytorchService()
bento_svc.pack('cls_predictor', model, metadata={"exp_name":"cls_baseline", "preprocessing":...})
bento_svc.save()
@artifacts([
    PytorchModelArtifact("cls_predictor"),
])
class PytorchService(BentoService):
    ...
    @api(input=JsonInput(), route="v1/predict", output=JsonOutput

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@kboseong
Comment options

Comment options

You must be logged in to vote
1 reply
@kboseong
Comment options

Answer selected by kboseong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants