Hi All! I have a question about building multi-se...
# ask-for-help
d
Hi All! I have a question about building multi-service containers. How do I write my
bentofile.yaml
if I want
bentoml build
to containerize multiple services? I've tried:
Copy code
services:
   service: "service:ServiceA"
   service: "service:ServiceB"
include:
- "service_a.py" #where ServiceA is defined
- "service_b.py" #where ServiceB is defined
- "utils.py"
- "preprocessing.py"
but get the following error:
Copy code
Error: [bentos] `build` failed: Missing required build config field "service", which indicates import path of target bentoml.Service instance. e.g.: "service: fraud_detector.py:svc"
I know I could make a combined service using bentoml.depends, but was wondering if the above described configuration was also possible?
c
hi @Dimitri Falco, are you looking to run both service in the same container?
the services field can only have one
service
, which should be your “entry service”, and it’s the only service that will be exposed
other dependency services will only be accessed by the entry service
as you suggested, you can potentially build an entry service that calls into the other two dependency services
d
@Chaoyu Thanks for the quick response. Yes, I did want them to be run in the same container. Is the only way to do that so through a entry service that combines both? Follow up questions to that: • If I use the
@bentoml.service
decorator for both dependency services, could I set one to cpu and the other to gpu within the same container? Or would they have to be done in separate containers for that to happen? • If I do go the independent container route, is there a way to use
bentoml build
to containerize both independently? Thanks in advance!
c
@Dimitri Falco • yes, but it won’t automatically restrict the resources tho. the decorator is mainly for exposing resource requirements for infra side to respect (e.g. Docker/K8s or BentoCloud). • yes, you can build two independent containers - with the current version of BentoML, you will need to have two different
bentofile.yaml
With the upcoming 1.4 release, you can do this more easily https://github.com/bentoml/BentoML/pull/5177/files
Copy code
bentoml build service.py:ServiceA
bentoml build service.py:ServiceB
d
@Chaoyu ah interesting, if I have two different bentofile.yaml does it automatically recognize there are two and build both? Like if I have a root directory called "services" and inside it two directories called "ServiceA" and "ServiceB" and each of them have their own
bentofile.yaml
, does running
bentoml build
at the root directory containerize both?