Hi, I am seeing the mention of <diamond-shape dep...
# ask-for-help
a
Hi, I am seeing the mention of diamond-shape dependencies in the docs. Does that mean I should expect a "common" dependency not to be called twice by default or should I code this logic myself? For example, I have 4 models depending on the same initial preprocessing & tokenizer, will bentoml "detect this" if I do 4 services that all depends on the same preprocessing ? Thanks for your help
j
Hello, in this case your code would be something like
Copy code
@service
class ModelA
    ....


@service
class ModelB
    ....


@service
class ModelC
    ....


@service
class ModelD
    ....


@service
class EntryService
    model_a = depends(ModelA)
    model_b = depends(ModelB)
    model_c = depends(ModelC)
    model_d = depends(ModelD)

    def preprocessing(self, ...)

    @bentoml.api
    def prediction(self, ...)
        data = self.preprocessing(...)
        predict = self.model_a(data)

    # and other endpoints
👍 1
a
ok, that's what we are already doing. preprocessed = self.preprocessing() results = await asyncio.gather( self.model_a, self.mode_b, ... ) Thanks!
j
looks good! feel free to reach out if you need more help
🙏 1