Hello, is it possible to use bentoml service as tr...
# ask-for-help
s
Hello, is it possible to use bentoml service as training process API, where API endpoint receives data as. json file and store trained model in bento Model store?
c
It is possible and we usually recommend using the
@task
abstraction for this. https://docs.bentoml.com/en/latest/guides/services.html#tasks You may also want to limit the concurrency to 1 in case of OOM issues. https://docs.bentoml.com/en/latest/bentocloud/how-tos/autoscaling.html#concurrency
s
@Chaoyu Thanks for the quick response! So based on the Task document, I'm guessing the barebone API code structure would look like following?
Copy code
import bentoml

@bentoml.service(
    traffic={
        "concurrency": 1,
    }
)
class MachineLearningService:

    @bentoml.task
    def get_train_data_train_model(self, data: dict) -> dict:
        # Process training
        return data
    
    @bentoml.api
    def predict(self, data: dict) -> dict:
        # Process predict
        return data
c
yes looks right!
🏁 1